]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/googledrive.py
37be34091895392b014a8fe2167d9c708ca60e71
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
12 class GoogleDriveIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:(?:docs|drive)\.google\.com/(?:uc\?.*?id=|file/d/)|video\.google\.com/get_player\?.*?docid=)(?P<id>[a-zA-Z0-9_-]{28})'
15 'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1',
16 'md5': '881f7700aec4f538571fa1e0eed4a7b6',
18 'id': '0ByeS4oOUV-49Zzh4R1J6R09zazQ',
20 'title': 'Big Buck Bunny.mp4',
44 def _extract_url(webpage
):
46 r
'<iframe[^>]+src="https?://(?:video\.google\.com/get_player\?.*?docid=|(?:docs|drive)\.google\.com/file/d/)(?P<id>[a-zA-Z0-9_-]{28})',
49 return 'https://drive.google.com/file/d/%s' % mobj
.group('id')
51 def _real_extract(self
, url
):
52 video_id
= self
._match
_id
(url
)
53 webpage
= self
._download
_webpage
(
54 'http://docs.google.com/file/d/%s' % video_id
, video_id
, encoding
='unicode_escape')
56 reason
= self
._search
_regex
(r
'"reason"\s*,\s*"([^"]+)', webpage
, 'reason', default
=None)
58 raise ExtractorError(reason
)
60 title
= self
._search
_regex
(r
'"title"\s*,\s*"([^"]+)', webpage
, 'title')
61 duration
= int_or_none(self
._search
_regex
(
62 r
'"length_seconds"\s*,\s*"([^"]+)', webpage
, 'length seconds', default
=None))
63 fmt_stream_map
= self
._search
_regex
(
64 r
'"fmt_stream_map"\s*,\s*"([^"]+)', webpage
, 'fmt stream map').split(',')
65 fmt_list
= self
._search
_regex
(r
'"fmt_list"\s*,\s*"([^"]+)', webpage
, 'fmt_list').split(',')
68 for fmt
, fmt_stream
in zip(fmt_list
, fmt_stream_map
):
69 fmt_id
, fmt_url
= fmt_stream
.split('|')
70 resolution
= fmt
.split('/')[1]
71 width
, height
= resolution
.split('x')
75 'resolution': resolution
,
76 'width': int_or_none(width
),
77 'height': int_or_none(height
),
78 'ext': self
._FORMATS
_EXT
[fmt_id
],
80 self
._sort
_formats
(formats
)
85 'thumbnail': self
._og
_search
_thumbnail
(webpage
, default
=None),