Skip to content

Commit

Permalink
Fix blank output_dir crash
Browse files Browse the repository at this point in the history
Workaround for #42.
If output_dir is initialized to None (for whatever reason, could be from
a CLI argument, or bogus config file override) fall back to using
current working directory to store the concat file.
  • Loading branch information
glubsy committed May 24, 2022
1 parent ee2a9fe commit c543a5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions livestream_saver/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ def __init__(
ext = "mp4"
else:
ext = "m4a" if datatype == "audio" else "mp4"

if not output_dir:
logger.warning(
f"{__class__.name} got empty output_dir arg! Falling back to CWD."
)
output_dir = Path()
self._final_file: Path = output_dir / \
f"{video_id}_{datatype}_ffmpeg.{ext}"

Expand Down
5 changes: 3 additions & 2 deletions livestream_saver/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def create_output_dir(output_dir: Path, video_id: Optional[str]) -> Path:
return capture_dirpath

def get_system_ua():
# TODO dynamically generate instead of static strings
SYSTEM = system()
if SYSTEM == 'Windows':
return 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0'
Expand All @@ -63,8 +64,8 @@ def get_system_ua():

def is_wanted_based_on_metadata(
data: Iterable[Optional[str]],
allow_re: re.Pattern = None,
block_re: re.Pattern = None
allow_re: Optional[re.Pattern] = None,
block_re: Optional[re.Pattern] = None
) -> bool:
"""Test each RE against each item in data (title, description...)"""
if allow_re is None and block_re is None:
Expand Down

0 comments on commit c543a5a

Please sign in to comment.