Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu1845 committed Jun 6, 2022
1 parent fc27c3f commit 85f1c78
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 66 deletions.
130 changes: 65 additions & 65 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion twspace_dl/twspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self, metadata: dict) -> None:
"url": "",
"title": "",
"creator_name": "",
"creator_id": "",
"creator_screen_name": "",
"start_date": "",
"state": "",
Expand Down Expand Up @@ -54,6 +55,9 @@ def __init__(self, metadata: dict) -> None:
self["state"] = root["state"]
self["available_for_replay"] = root["is_space_available_for_replay"]
self["media_key"] = root["media_key"]
self["creator_id"] = twitter.user_id(
"https://twitter.com/" + creator_info["screen_name"]
)

@staticmethod
def _metadata(space_id) -> dict:
Expand Down Expand Up @@ -158,7 +162,7 @@ def sterilize_fn(value: str) -> str:
def format(self, format_str: str) -> str:
"""Use metadata to fill in the fields in format str"""
actual_format_str = os.path.basename(format_str)
abs_dir = os.path.dirname(format_str)
abs_dir = os.path.dirname(format_str) % self
basename = self.sterilize_fn(actual_format_str % self)
return os.path.join(abs_dir, basename)

Expand Down
1 change: 1 addition & 0 deletions twspace_dl/twspace_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def download(self) -> None:
subprocess.run(cmd_old, check=True)
except subprocess.CalledProcessError as err:
raise RuntimeError(" ".join(err.cmd)) from err
os.makedirs(os.path.dirname(self.filename), exist_ok=True)
shutil.move(filename_old, self.filename + ".m4a")

logging.info("Finished downloading")

0 comments on commit 85f1c78

Please sign in to comment.