Merge pull request #610 from mac1202/gfycat-mp4
Add mp4 support to gfycat.
This commit is contained in:
@@ -98,7 +98,7 @@ class VideoTagMIMEParser(BaseMIMEParser):
|
|||||||
class GfycatMIMEParser(BaseMIMEParser):
|
class GfycatMIMEParser(BaseMIMEParser):
|
||||||
"""
|
"""
|
||||||
Gfycat provides a primitive json api to generate image links. URLs can be
|
Gfycat provides a primitive json api to generate image links. URLs can be
|
||||||
downloaded as either gif, webm, or mjpg. Webm was selected because it's
|
downloaded as either gif, mp4, webm, or mjpg. Mp4 was selected because it's
|
||||||
fast and works with VLC.
|
fast and works with VLC.
|
||||||
|
|
||||||
https://gfycat.com/api
|
https://gfycat.com/api
|
||||||
@@ -113,8 +113,8 @@ class GfycatMIMEParser(BaseMIMEParser):
|
|||||||
parts = url.replace('gifs/detail/', '').split('/')
|
parts = url.replace('gifs/detail/', '').split('/')
|
||||||
api_url = '/'.join(parts[:-1] + ['cajax', 'get'] + parts[-1:])
|
api_url = '/'.join(parts[:-1] + ['cajax', 'get'] + parts[-1:])
|
||||||
resp = requests.get(api_url)
|
resp = requests.get(api_url)
|
||||||
image_url = resp.json()['gfyItem']['webmUrl']
|
image_url = resp.json()['gfyItem']['mp4Url']
|
||||||
return image_url, 'video/webm'
|
return image_url, 'video/mp4'
|
||||||
|
|
||||||
|
|
||||||
class YoutubeMIMEParser(BaseMIMEParser):
|
class YoutubeMIMEParser(BaseMIMEParser):
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ URLS = OrderedDict([
|
|||||||
None)),
|
None)),
|
||||||
('gfycat', (
|
('gfycat', (
|
||||||
'https://gfycat.com/DeliciousUnfortunateAdouri',
|
'https://gfycat.com/DeliciousUnfortunateAdouri',
|
||||||
'https://giant.gfycat.com/DeliciousUnfortunateAdouri.webm',
|
'https://giant.gfycat.com/DeliciousUnfortunateAdouri.mp4',
|
||||||
'video/webm')),
|
'video/mp4')),
|
||||||
('youtube', (
|
('youtube', (
|
||||||
'https://www.youtube.com/watch?v=FjNdYp2gXRY',
|
'https://www.youtube.com/watch?v=FjNdYp2gXRY',
|
||||||
'https://www.youtube.com/watch?v=FjNdYp2gXRY',
|
'https://www.youtube.com/watch?v=FjNdYp2gXRY',
|
||||||
|
|||||||
Reference in New Issue
Block a user