3 from __future__ import unicode_literals
7 from .common import InfoExtractor
9 class GfycatIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?gfycat\.com/(?P<id>[^/?#]+)'
12 'url': 'http://gfycat.com/DeadlyDecisiveGermanpinscher',
14 'id': 'DeadlyDecisiveGermanpinscher',
15 'title': 'Ghost in the Shell',
17 'upload_date': '20140913'
20 'url': 'http://gfycat.com/pleasinghilariouskusimanse',
22 'id': 'pleasinghilariouskusimanse',
23 'title': 'PleasingHilariousKusimanse',
25 'upload_date': '20150412'
28 'url': 'http://gfycat.com/requiredunkemptbuzzard',
30 'id': 'requiredunkemptbuzzard',
33 'upload_date': '20150130'
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
39 json = self._download_json("http://gfycat.com/cajax/get/" + video_id, video_id, 'Downloading video info')['gfyItem']
42 # Use user title first, else fallback to url formated name
44 video_title = json['title']
46 video_title = json['gfyName']
49 # Pref: mp4, webm, gif
53 'url': json['mp4Url'],
54 'width': json['width'],
55 'height': json['height'],
56 'fps': json['frameRate'],
57 'filesize': json['mp4Size'],
62 'url': json['webmUrl'],
63 'width': json['width'],
64 'height': json['height'],
65 'fps': json['frameRate'],
66 'filesize': json['webmSize'],
71 'url': json['gifUrl'],
72 'width': json['width'],
73 'height': json['height'],
74 'fps': json['frameRate'],
75 'filesize': json['gifSize'],
79 self._sort_formats(formats)
82 date = datetime.datetime.fromtimestamp(
83 int(json['createDate'])
87 duration = json['numFrames'] / json['frameRate']
100 'creator': json['userName'],
101 'description': json['description'],
103 'categories': json['tags'],
104 'age_limit': age_limit,
105 'duration': duration,
106 'view_count': json['views']