Skip to content

Commit

Permalink
fix #32
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu1845 committed Jan 15, 2022
1 parent 6213896 commit 0695505
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions twspace_dl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,23 @@ def twspace(args: argparse.Namespace) -> None:

logging.basicConfig(level=logging.DEBUG if args.verbose else logging.INFO)

if args.input_url:
twspace_dl = TwspaceDL.from_space_url(args.input_url, args.output)
elif args.user_url:
if args.user_url:
if args.input_cookie_file:
auth_token = load_from_file(args.input_cookie_file)
twspace_dl = TwspaceDL.from_user_avatar(
args.user_url, args.output, auth_token
)
else:
twspace_dl = TwspaceDL.from_user_tweets(args.user_url, args.output)
else:
elif args.input_metadata:
with open(args.input_metadata, "r", encoding="utf-8") as metadata_io:
metadata = json.load(metadata_io)
twspace_dl = TwspaceDL(
metadata["data"]["audioSpace"]["metadata"]["rest_id"], args.output
)
twspace_dl.metadata = metadata
else:
twspace_dl = TwspaceDL.from_space_url(args.input_url, args.output)

if args.from_dynamic_url:
twspace_dl.dyn_url = args.from_dynamic_url
Expand Down
5 changes: 4 additions & 1 deletion twspace_dl/twspace_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def from_space_url(cls, url: str, format_str: str):
space_id = "no_id"
format_str = "no_info"
else:
space_id = re.findall(r"(?<=spaces/)\w*", url)[0]
try:
space_id = re.findall(r"(?<=spaces/)\w*", url)[0]
except IndexError as err:
raise ValueError("Input URL is not valid") from err
return cls(space_id, format_str)

@classmethod
Expand Down

0 comments on commit 0695505

Please sign in to comment.