1 from .common import InfoExtractor
2 from ..utils import RegexNotFoundError
4 class GoogleDriveIE(InfoExtractor):
5 _VALID_URL = r'(?:https?://)?(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/))(?P<id>.+?)(?:&|/|$)'
7 'url': 'https://drive.google.com/file/d/0BzpExh0WzJF0NlR5WUlxdEVsY0U/edit?pli=1',
9 'id': '0BzpExh0WzJF0NlR5WUlxdEVsY0U',
11 'title': '[AHSH] Fairy Tail S2 - 01 [720p].mp4',
26 '43': {'ext': 'webm'},
27 '44': {'ext': 'webm'},
28 '45': {'ext': 'webm'},
29 '46': {'ext': 'webm'},
33 def _real_extract(self, url):
34 video_id = self._match_id(url)
35 webpage = self._download_webpage(
36 'http://docs.google.com/file/d/'+video_id, video_id, encoding='unicode_escape'
39 title = self._html_search_regex(
40 r'"title","(?P<title>.*?)"',
45 fmt_stream_map = self._html_search_regex(
46 r'"fmt_stream_map","(?P<fmt_stream_map>.*?)"',
49 group='fmt_stream_map'
51 fmt_list = self._html_search_regex(
52 r'"fmt_list","(?P<fmt_list>.*?)"',
57 # timestamp = self._html_search_regex(
58 # r'"timestamp","(?P<timestamp>.*?)"',
63 length_seconds = self._html_search_regex(
64 r'"length_seconds","(?P<length_seconds>.*?)"',
67 group='length_seconds'
69 except RegexNotFoundError:
71 reason = self._html_search_regex(
72 r'"reason","(?P<reason>.*?)"',
77 self.report_warning(reason)
79 except RegexNotFoundError:
80 self.report_warning('not a video')
83 fmt_stream_map = fmt_stream_map.split(',')
84 fmt_list = fmt_list.split(',')
86 for i in range(len(fmt_stream_map)):
87 fmt_id, fmt_url = fmt_stream_map[i].split('|')
88 resolution = fmt_list[i].split('/')[1]
89 width, height = resolution.split('x')
93 'resolution': resolution,
95 'height': int(height),
96 'ext': self._formats[fmt_id]['ext']
98 self._sort_formats(formats)
103 # 'timestamp': int(timestamp),
104 'duration': int(length_seconds),