Skip to content

Commit

Permalink
Fix regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Serene-Arc authored and aliparlakci committed Nov 16, 2021
1 parent 8c3af70 commit 53562f4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bdfr/site_downloaders/download_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class DownloadFactory:
@staticmethod
def pull_lever(url: str) -> Type[BaseDownloader]:
sanitised_url = DownloadFactory.sanitise_url(url)
if re.match(r'(i\.)?imgur.*\.gif.*$', sanitised_url):
if re.match(r'(i\.)?imgur.*\.gif.+$', sanitised_url):
return Imgur
elif re.match(r'.*/.*\.\w{3,4}(\?[\w;&=]*)?$', sanitised_url) and \
not DownloadFactory.is_web_resource(sanitised_url):
Expand Down
4 changes: 2 additions & 2 deletions bdfr/site_downloaders/imgur.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def _compute_image_url(self, image: dict) -> Resource:
@staticmethod
def _get_data(link: str) -> dict:
link = link.rstrip('?')
if re.match(r'(?i).*\.gif.*$', link):
if re.match(r'(?i).*\.gif.+$', link):
link = link.replace('i.imgur', 'imgur')
link = re.sub('(?i)\\.gif.*$', '', link)
link = re.sub('(?i)\\.gif.+$', '', link)

res = Imgur.retrieve_url(link, cookies={'over18': '1', 'postpagebeta': '0'})

Expand Down
1 change: 1 addition & 0 deletions tests/site_downloaders/test_download_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
('https://imgur.com/BuzvZwb.gifv', Imgur),
('https://i.imgur.com/6fNdLst.gif', Direct),
('https://imgur.com/a/MkxAzeg', Imgur),
('https://i.imgur.com/OGeVuAe.giff', Imgur),
('https://www.reddit.com/gallery/lu93m7', Gallery),
('https://gfycat.com/concretecheerfulfinwhale', Gfycat),
('https://www.erome.com/a/NWGw0F09', Erome),
Expand Down

0 comments on commit 53562f4

Please sign in to comment.