]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/arkena.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
17 class ArkenaIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://play\.arkena\.com/(?:config|embed)/avp/v\d/player/media/(?P<id>[^/]+)/[^/]+/(?P<account_id>\d+)'
20 'url': 'https://play.arkena.com/embed/avp/v2/player/media/b41dda37-d8e7-4d3f-b1b5-9a9db578bdfe/1/129411',
21 'md5': 'b96f2f71b359a8ecd05ce4e1daa72365',
23 'id': 'b41dda37-d8e7-4d3f-b1b5-9a9db578bdfe',
25 'title': 'Big Buck Bunny',
26 'description': 'Royalty free test video',
27 'timestamp': 1432816365,
28 'upload_date': '20150528',
32 'url': 'https://play.arkena.com/config/avp/v2/player/media/b41dda37-d8e7-4d3f-b1b5-9a9db578bdfe/1/129411/?callbackMethod=jQuery1111023664739129262213_1469227693893',
33 'only_matching': True,
35 'url': 'http://play.arkena.com/config/avp/v1/player/media/327336/darkmatter/131064/?callbackMethod=jQuery1111002221189684892677_1469227595972',
36 'only_matching': True,
38 'url': 'http://play.arkena.com/embed/avp/v1/player/media/327336/darkmatter/131064/',
39 'only_matching': True,
43 def _extract_url(webpage
):
44 # See https://support.arkena.com/display/PLAY/Ways+to+embed+your+video
46 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//play\
.arkena\
.com
/embed
/avp
/.+?
)\
1',
49 return mobj.group('url
')
51 def _real_extract(self, url):
52 mobj = re.match(self._VALID_URL, url)
53 video_id = mobj.group('id')
54 account_id = mobj.group('account_id
')
56 playlist = self._download_json(
57 'https
://play
.arkena
.com
/config
/avp
/v2
/player
/media
/%s/0/%s/?callbackMethod
=_
'
58 % (video_id, account_id),
59 video_id, transform_source=strip_jsonp)['Playlist
'][0]
61 media_info = playlist['MediaInfo
']
62 title = media_info['Title
']
63 media_files = playlist['MediaFiles
']
67 for kind_case, kind_formats in media_files.items():
68 kind = kind_case.lower()
69 for f in kind_formats:
73 is_live = f.get('Live
') == 'true
'
74 exts = (mimetype2ext(f.get('Type
')), determine_ext(f_url, None))
75 if kind == 'm3u8
' or 'm3u8
' in exts:
76 formats.extend(self._extract_m3u8_formats(
77 f_url, video_id, 'mp4
',
78 entry_protocol='m3u8
' if is_live else 'm3u8_native
',
79 m3u8_id=kind, fatal=False, live=is_live))
80 elif kind == 'flash
' or 'f4m
' in exts:
81 formats.extend(self._extract_f4m_formats(
82 f_url, video_id, f4m_id=kind, fatal=False))
83 elif kind == 'dash
' or 'mpd
' in exts:
84 formats.extend(self._extract_mpd_formats(
85 f_url, video_id, mpd_id=kind, fatal=False))
86 elif kind == 'silverlight
':
87 # TODO: process when ism is supported (see
88 # https://github.com/rg3/youtube-dl/issues/8118)
91 tbr = float_or_none(f.get('Bitrate
'), 1000)
94 'format_id
': '%s-%d' % (kind, tbr) if tbr else kind,
97 self._sort_formats(formats)
99 description = media_info.get('Description
')
100 video_id = media_info.get('VideoId
') or video_id
101 timestamp = parse_iso8601(media_info.get('PublishDate
'))
103 'url
': thumbnail['Url
'],
104 'width
': int_or_none(thumbnail.get('Size
')),
105 } for thumbnail in (media_info.get('Poster
') or []) if thumbnail.get('Url
')]
110 'description
': description,
111 'timestamp
': timestamp,
113 'thumbnails
': thumbnails,