Refactor method to base class

This commit is contained in:
Serene-Arc
2021-04-05 17:21:04 +10:00
committed by Ali Parlakci
parent 500cee4bae
commit 2384c03170
7 changed files with 28 additions and 40 deletions

View File

@@ -1,9 +1,7 @@
#!/usr/bin/env python3
import re
from typing import Optional
import requests
from bs4 import BeautifulSoup
from praw.models import Submission
@@ -23,12 +21,9 @@ class GifDeliveryNetwork(BaseDownloader):
@staticmethod
def _get_link(url: str) -> str:
if re.match(r'https://.*\.(mp4|webm|gif)(\?.*)?$', url):
return url
page = GifDeliveryNetwork.get_link(url)
page_source = requests.get(url).text
soup = BeautifulSoup(page_source, 'html.parser')
soup = BeautifulSoup(page.text, 'html.parser')
content = soup.find('source', attrs={'id': 'mp4Source', 'type': 'video/mp4'})
if content is None or content.get('src') is None: