Skip to content

Commit

Permalink
Short circuit empty urls
Browse files Browse the repository at this point in the history
Handles empty urls returned by the api faster in factory.

Removes failing imgur test.
Replaces failing erome test.
  • Loading branch information
OMEGARAZER committed May 25, 2023
1 parent 8b2344d commit d19e7e9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions bdfrx/site_downloaders/download_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
class DownloadFactory:
@staticmethod
def pull_lever(url: str) -> type[BaseDownloader]: # noqa: PLR0911,PLR0912
if not url:
raise NotADownloadableLinkError("No url provided by the reddit API")
sanitised_url = DownloadFactory.sanitise_url(url).lower()
if re.match(r"(i\.|m\.|o\.)?imgur", sanitised_url):
return Imgur
Expand Down
19 changes: 11 additions & 8 deletions tests/site_downloaders/test_erome.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
(
("https://www.erome.com/a/vqtPuLXh", (r"https://[a-z]\d+.erome.com/\d{3}/vqtPuLXh/KH2qBT99_480p.mp4",)),
(
"https://www.erome.com/a/ORhX0FZz",
"https://www.erome.com/a/9E50Xkb6",
(
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9IYQocM9_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/9eEDc8xm_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/EvApC7Rp_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/LruobtMs_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/TJNmSUU5_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/X11Skh6Z_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{3}/ORhX0FZz/bjlTkpn7_480p.mp4",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/hUpc1d21.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/3zZF7uv4.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/h6C03hNq.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/AHQuZh9j.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/Ram0NmDU.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/dY82guy1.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/3x8bp9lF.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/lxyFSUMQ.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/vPIb29UR.jpeg",
r"https://[a-z]\d+.erome.com/\d{4}/9E50Xkb6/w1BJtyh5.jpeg",
),
),
),
Expand Down
1 change: 0 additions & 1 deletion tests/site_downloaders/test_imgur.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def test_get_id(test_url: str, expected: str):
("https://imgur.com/a/1qzfWtY/gifv", ("65fbc7ba5c3ed0e3af47c4feef4d3735",)),
("https://imgur.com/a/1qzfWtY/mp4", ("65fbc7ba5c3ed0e3af47c4feef4d3735",)),
("https://imgur.com/a/1qzfWtY/spqr", ("65fbc7ba5c3ed0e3af47c4feef4d3735",)),
("https://i.imgur.com/expO7Rc.gifv", ("e309f98158fc98072eb2ae68f947f421",)),
("https://i.imgur.com/a/aqpiMuL.gif", ("5b2a9a5218bf43dc26ba41389410c981",)),
),
)
Expand Down

0 comments on commit d19e7e9

Please sign in to comment.