Add some tests for base_download

This commit is contained in:
Serene-Arc
2021-02-07 16:38:30 +10:00
committed by Ali Parlakci
parent f573038a21
commit 5ef58f147f
4 changed files with 45 additions and 2 deletions

View File

@@ -96,8 +96,9 @@ class BaseDownloader(ABC):
@staticmethod
def _get_extension(url: str) -> str:
pattern = re.compile(r'(\.(jpg|jpeg|png|mp4|webm|gif))')
if len(results := re.search(pattern, url).groups()) > 1:
return results[1]
if results := re.search(pattern, url):
if len(results.groups()) > 1:
return results[0]
if "v.redd.it" not in url:
return '.jpg'
else: