From f05e909008a23ee401aed28e8fff7ecaf939c031 Mon Sep 17 00:00:00 2001 From: OMEGARAZER <869111+OMEGARAZER@users.noreply.github.com> Date: Tue, 9 Nov 2021 19:30:27 -0500 Subject: [PATCH] Stop videos from being downloaded as images Erroneous .gifv extensions such as .giff or .gift resolve to a static image and are downloaded by the direct downloader. (ex: https://i.imgur.com/OGeVuAe.giff ) --- bdfr/site_downloaders/download_factory.py | 2 +- bdfr/site_downloaders/imgur.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bdfr/site_downloaders/download_factory.py b/bdfr/site_downloaders/download_factory.py index a4e9a6a..ccff8e7 100644 --- a/bdfr/site_downloaders/download_factory.py +++ b/bdfr/site_downloaders/download_factory.py @@ -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.*\.gifv$', 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): diff --git a/bdfr/site_downloaders/imgur.py b/bdfr/site_downloaders/imgur.py index a3e3135..905581e 100644 --- a/bdfr/site_downloaders/imgur.py +++ b/bdfr/site_downloaders/imgur.py @@ -42,9 +42,9 @@ class Imgur(BaseDownloader): @staticmethod def _get_data(link: str) -> dict: link = link.rstrip('?') - if re.match(r'(?i).*\.gifv$', link): + if re.match(r'(?i).*\.gif.*$', link): link = link.replace('i.imgur', 'imgur') - link = re.sub('(?i)\\.gifv$', '', link) + link = re.sub('(?i)\\.gif.*$', '', link) res = Imgur.retrieve_url(link, cookies={'over18': '1', 'postpagebeta': '0'})