From 707b2da9349c1afbdffbf7bf04be6b6f16e98cc2 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Fri, 30 Aug 2024 08:05:16 +0200 Subject: [PATCH] Improve types --- twitchdl/commands/download.py | 4 ++-- twitchdl/naming.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/twitchdl/commands/download.py b/twitchdl/commands/download.py index beecdef..3bdcd45 100644 --- a/twitchdl/commands/download.py +++ b/twitchdl/commands/download.py @@ -48,7 +48,7 @@ def download_one(video: str, args: DownloadOptions): raise ConsoleError(f"Invalid input: {video}") -def _join_vods(playlist_path: Path, target: str, overwrite: bool, video: Video): +def _join_vods(playlist_path: Path, target: Path, overwrite: bool, video: Video): description = video["description"] or "" description = description.strip() @@ -81,7 +81,7 @@ def _join_vods(playlist_path: Path, target: str, overwrite: bool, video: Video): raise ConsoleError("Joining files failed") -def _concat_vods(vod_paths: List[Path], target: str): +def _concat_vods(vod_paths: List[Path], target: Path): tool = "type" if platform.system() == "Windows" else "cat" command = [tool] + [str(p) for p in vod_paths] diff --git a/twitchdl/naming.py b/twitchdl/naming.py index 2f4d5dd..6c5b287 100644 --- a/twitchdl/naming.py +++ b/twitchdl/naming.py @@ -41,9 +41,12 @@ def clip_placeholders(clip: Clip) -> Dict[str, str]: date, time = clip["createdAt"].split("T") game = clip["game"]["name"] if clip["game"] else "Unknown" - url = clip["videoQualities"][0]["sourceURL"] - _, ext = os.path.splitext(url) - ext = ext.lstrip(".") + if clip["videoQualities"]: + url = clip["videoQualities"][0]["sourceURL"] + _, ext = os.path.splitext(url) + ext = ext.lstrip(".") + else: + ext = "mp4" return { "channel": clip["broadcaster"]["displayName"],