Skip to content

Commit 8967938

Browse files
Merge branch 'master' into proxy
2 parents 5e2024b + b74e149 commit 8967938

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

safaribooks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,16 @@ def process_arguments(arguments):
11161116
if parsed_args.no_cookies:
11171117
arguments.error("invalid option: `--no-cookies` is valid only if you use the `--cred` option")
11181118

1119+
if len(parsed_args.bookid) > 0:
1120+
bookID = parsed_args.bookid.split("/")[-1] # Only get book ID from URL
1121+
print(f"bookID: {bookID}")
1122+
if str.isdecimal(bookID):
1123+
parsed_args.bookid = bookID
1124+
else:
1125+
arguments.error("Invalid book ID")
1126+
else:
1127+
arguments.error("Book ID must not be empty")
1128+
11191129
if parsed_args.proxy:
11201130
proxy_regex = r"http[s]?://[a-zA-Z0-9.-]+:\d{4}" # Matches proxy URL
11211131
pattern = re.compile(proxy_regex)

0 commit comments

Comments
 (0)