Skip to content

Commit

Permalink
Reenable compat-options in the query and remove mimetype and print
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenshin9977 committed Oct 15, 2021
1 parent 422b8af commit 49bfcdb
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ytdlp_handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import mimetypes
import PySimpleGUI
import yt_dlp

Expand Down Expand Up @@ -38,7 +37,7 @@ def _gen_query(h: int, browser: str, audio_only: bool, path: str, start: str, en
keep_on_top=True)
options = {'noplaylist': True, 'overwrites': True, 'progress_hooks': [download_progress_bar],
'trim_file_name': 250, 'outtmpl': os.path.join(path, "%(title).100s - %(uploader)s.%(ext)s")}
# options["compat_opts"] = "no-direct-merge"
options["compat_opts"] = "no-direct-merge"
video_format = ""
acodecs = ["aac", "mp3"] if audio_only else ["aac", "mp3", "mp4a"]
for acodec in acodecs:
Expand Down Expand Up @@ -73,14 +72,12 @@ def _gen_query(h: int, browser: str, audio_only: bool, path: str, start: str, en

def download_progress_bar(d):
global CANCELED, DL_PROGRESS_WINDOW, TIME_LAST_UPDATE
media_type = mimetypes.guess_type(d['filename'])[0].split('/')[0]
speed = '-' if 'speed' not in d.keys() or d['speed'] is None else Quantity(d['speed'], 'B/s').render(prec=2)
downloaded = '-' if 'speed' not in d.keys() or d['speed'] is None else Quantity(d['downloaded_bytes'], 'B')
total = Quantity(d['total_bytes'], 'B') if 'total_bytes' in d.keys() else Quantity(d['total_bytes_estimate'], 'B')
event, _ = DL_PROGRESS_WINDOW.read(timeout=10)
if d['status'] == 'finished':
file_tuple = os.path.split(os.path.abspath(d['filename']))
# print("Done downloading {}".format(file_tuple[1]))
DL_PROGRESS_WINDOW.close()
elif d['status'] == 'downloading':
if event == get_text(GuiField.cancel_button):
Expand All @@ -93,4 +90,4 @@ def download_progress_bar(d):
delta_ms = (now - TIME_LAST_UPDATE).seconds * 1000 + (now - TIME_LAST_UPDATE).microseconds // 1000
if delta_ms >= 200:
DL_PROGRESS_WINDOW['PROGINFOS2'].update(f"{get_text(GuiField.ff_speed)}: {speed}")
TIME_LAST_UPDATE = now
TIME_LAST_UPDATE = now

0 comments on commit 49bfcdb

Please sign in to comment.