add mime parsers for gifs.com and giphy.com
This commit is contained in:
@@ -55,8 +55,10 @@ class OpenGraphMIMEParser(BaseMIMEParser):
|
||||
def get_mimetype(url):
|
||||
page = requests.get(url)
|
||||
soup = BeautifulSoup(page.content, 'html.parser')
|
||||
for og_type in ['og:video:secure_url', 'og:video', 'og:image']:
|
||||
tag = soup.find('meta', attrs={'property': og_type})
|
||||
for og_type in ['video', 'image']:
|
||||
tag = soup.find('meta',
|
||||
attrs={'property':'og:' + og_type + ':secure_url'}) or \
|
||||
soup.find('meta', attrs={'property': 'og:' + og_type})
|
||||
if tag:
|
||||
return BaseMIMEParser.get_mimetype(tag.get('content'))
|
||||
return url, None
|
||||
@@ -394,6 +396,20 @@ class ClippitUserMIMEParser(BaseMIMEParser):
|
||||
return tag.get(quality[0]), 'video/mp4'
|
||||
|
||||
|
||||
class GifsMIMEParser(OpenGraphMIMEParser):
|
||||
"""
|
||||
Gifs.com uses the Open Graph protocol
|
||||
"""
|
||||
pattern = re.compile(r'https?://(www\.)?gifs\.com/gif/[^.]+$')
|
||||
|
||||
|
||||
class GiphyMIMEParser(OpenGraphMIMEParser):
|
||||
"""
|
||||
Giphy.com uses the Open Graph protocol
|
||||
"""
|
||||
pattern = re.compile(r'https?://(www\.)?giphy\.com/gifs/[^.]+$')
|
||||
|
||||
|
||||
# Parsers should be listed in the order they will be checked
|
||||
parsers = [
|
||||
ClippitUserMIMEParser,
|
||||
@@ -408,5 +424,7 @@ parsers = [
|
||||
YoutubeMIMEParser,
|
||||
LiveleakMIMEParser,
|
||||
TwitchMIMEParser,
|
||||
GifsMIMEParser,
|
||||
GiphyMIMEParser,
|
||||
GifvMIMEParser,
|
||||
BaseMIMEParser]
|
||||
|
||||
Reference in New Issue
Block a user