youtube-dl: fixed downloading from sites that provide encrypted content (m3u8)
This commit is contained in:
parent
7c304d449a
commit
6262b26fe5
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -72,12 +72,14 @@ class YoutubeDLHelper(DownloadHelper):
|
|||
if 'entries' in result:
|
||||
video = result['entries'][0]
|
||||
for v in result['entries']:
|
||||
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
|
||||
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')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
with download_dict_lock:
|
||||
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:
|
||||
download_dict[self.uid] = upload_status
|
||||
update_all_messages()
|
||||
drive.upload(up_name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue