forked from ankitsejwal/Lyndor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideos.py
More file actions
executable file
·45 lines (39 loc) · 1.88 KB
/
videos.py
File metadata and controls
executable file
·45 lines (39 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
''' Downloads videos and subtitles '''
import os
import sys
import install
import cookies
import message
def download(url, cookie_path, course_folder):
''' This function downloads all the videos in course folder'''
os.chdir(course_folder)
COOKIE = install.read_settings_json('credentials', 'use_cookie_for_download')
SUBTITLE = install.read_settings_json('preferences', 'download_subtitles')
EXTERNAL_DOWNLOADER = install.read_settings_json('preferences', 'ext-downloader-aria2-installed')
USERNAME = install.read_settings_json('credentials', 'username')
PASSWORD = install.read_settings_json('credentials', 'password')
try:
subtitles = ' --all-subs ' if SUBTITLE else ' ' # Checking subtitle preferences
# Output name of videos/subtitles
output = ' -o ' +'"'+ course_folder + "/%(playlist_index)s - %(title)s.%(ext)s" + '"'
# Extername downloader option
ext_downloader = ' --external-downloader aria2c' if EXTERNAL_DOWNLOADER else ''
cookie = ' --cookies ' + '"' + cookie_path + '"' #cookie
username = ' -u ' + USERNAME #username
password = ' -p ' + PASSWORD #password
# Checking cookie preferences
if COOKIE:
cookies.edit_cookie(cookie_path, message.NETSCAPE) # Edit cookie file
os.system('youtube-dl' + cookie + output + subtitles + url + ext_downloader)
else:
os.system('youtube-dl' + username + password + output + subtitles + url + ext_downloader)
except KeyboardInterrupt:
sys.exit('Program Interrupted')
def read_bulk_download():
''' Read Bulk Download.txt '''
os.chdir(install.read_settings_json('preferences', 'location'))
bulk_download = open('Bulk Download.txt', 'r')
urls = bulk_download.readlines()
return urls