3 from .common import InfoExtractor
9 class GoogleDriveEmbedIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9_-]{28})'
12 'url': 'https://docs.google.com/file/d/0B8KB9DRosYGKMXNoeWxqa3JYclE/preview',
14 'id': '0B8KB9DRosYGKMXNoeWxqa3JYclE',
16 'title': 'Jimmy Fallon Sings Since You\'ve Been Gone.wmv',
21 def _extract_url(webpage):
23 r'<iframe src="https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9_-]{28})',
26 return 'https://drive.google.com/file/d/%s' % mobj.group('id')
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
32 'ie_key': 'GoogleDrive',
33 'url': 'https://drive.google.com/file/d/%s' % video_id
36 class GoogleDriveIE(InfoExtractor):
37 _VALID_URL = r'https?://(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/)(?P<id>[a-zA-Z0-9_-]{28})'
39 'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1',
41 'id': '0ByeS4oOUV-49Zzh4R1J6R09zazQ',
43 'title': 'Big Buck Bunny.mp4',
58 '43': {'ext': 'webm'},
59 '44': {'ext': 'webm'},
60 '45': {'ext': 'webm'},
61 '46': {'ext': 'webm'},
65 def _real_extract(self, url):
66 video_id = self._match_id(url)
67 webpage = self._download_webpage(
68 'http://docs.google.com/file/d/' + video_id, video_id, encoding='unicode_escape'
71 title = self._html_search_regex(
72 r'"title"\s*,\s*"([^"]+)',
76 fmt_stream_map = self._html_search_regex(
77 r'"fmt_stream_map"\s*,\s*"([^"]+)',
81 fmt_list = self._html_search_regex(
82 r'"fmt_list"\s*,\s*"([^"]+)',
86 # timestamp = self._html_search_regex(
87 # r'"timestamp"\s*,\s*"([^"]+)',
91 length_seconds = self._html_search_regex(
92 r'"length_seconds"\s*,\s*"([^"]+)',
96 except RegexNotFoundError:
98 reason = self._html_search_regex(
103 raise ExtractorError(reason)
105 except RegexNotFoundError:
106 raise ExtractorError('not a video')
109 fmt_stream_map = fmt_stream_map.split(',')
110 fmt_list = fmt_list.split(',')
112 for i in range(len(fmt_stream_map)):
113 fmt_id, fmt_url = fmt_stream_map[i].split('|')
114 resolution = fmt_list[i].split('/')[1]
115 width, height = resolution.split('x')
119 'resolution': resolution,
121 'height': int(height),
122 'ext': self._formats[fmt_id]['ext']
124 self._sort_formats(formats)
129 # 'timestamp': int(timestamp),
130 'duration': int(length_seconds),