Merge branch 'vidme_mime_parser' of https://github.com/woorst/rtv

This commit is contained in:
Michael Lazar
2017-05-31 23:20:09 -04:00
2 changed files with 22 additions and 0 deletions

View File

@@ -204,9 +204,27 @@ class StreamableMIMEParser(OpenGraphMIMEParser):
pattern = re.compile(r'https?://(www\.)?streamable\.com/[^.]+$')
class VidmeMIMEParser(BaseMIMEParser):
"""
Vidme provides a json api.
https://doc.vid.me
"""
pattern = re.compile(r'https?://(www\.)?vid\.me/[^.]+$')
@staticmethod
def get_mimetype(url):
resp = requests.get('https://api.vid.me/videoByUrl?url=' + url)
if resp.status_code == 200 and resp.json()['status']:
return resp.json()['video']['complete_url'], 'video/mp4'
else:
return url, None
# Parsers should be listed in the order they will be checked
parsers = [
StreamableMIMEParser,
VidmeMIMEParser,
InstagramMIMEParser,
GfycatMIMEParser,
ImgurAlbumMIMEParser,