youtube-dl: fixed downloading from sites that provide encrypted content (m3u8)

This commit is contained in:
jaskaranSM 2020-03-28 17:37:17 +05:30 committed by lzzy12
parent 7c304d449a
commit 6262b26fe5
3 changed files with 19 additions and 5 deletions

View File

@ -30,6 +30,16 @@ def exit_clean_up(signal, frame):
LOGGER.warning("Force Exiting before the cleanup finishes!")
sys.exit(1)
def get_path_size(path):
if os.path.isfile(path):
return os.path.getsize(path)
total_size = 0
for root, dirs, files in os.walk(path):
for f in files:
abs_path = os.path.join(root, f)
total_size += os.path.getsize(abs_path)
return total_size
def tar(org_path):
tar_path = org_path + ".tar"

View File

@ -72,13 +72,15 @@ class YoutubeDLHelper(DownloadHelper):
if 'entries' in result:
video = result['entries'][0]
for v in result['entries']:
self.size += float(v['filesize'])
if v.get('filesize'):
self.size += float(v['filesize'])
self.name = video.get('playlist_title')
self.vid_id = video.get('id')
self.is_playlist = True
else:
video = result
self.size = int(video.get('filesize'))
if video.get('filesize'):
self.size = int(video.get('filesize'))
self.name = f"{video.get('title')}.{video.get('ext')}"
self.vid_id = video.get('id')
return video

View File

@ -59,10 +59,12 @@ class MirrorListener(listeners.MirrorListeners):
else:
path = f'{DOWNLOAD_DIR}{self.uid}/{download_dict[self.uid].name()}'
up_name = pathlib.PurePath(path).name
LOGGER.info(f"Upload Name : {up_name}")
drive = gdriveTools.GoogleDriveHelper(up_name, self)
if size == 0:
size = fs_utils.get_path_size(m_path)
upload_status = UploadStatus(drive, size, self.uid)
with download_dict_lock:
LOGGER.info(f"Upload Name : {up_name}")
drive = gdriveTools.GoogleDriveHelper(up_name, self)
upload_status = UploadStatus(drive, size, self.uid)
download_dict[self.uid] = upload_status
update_all_messages()
drive.upload(up_name)