]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pandoratv.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
18 class PandoraTVIE(InfoExtractor
):
19 IE_NAME
= 'pandora.tv'
21 _VALID_URL
= r
'https?://(?:.+?\.)?channel\.pandora\.tv/channel/video\.ptv\?'
23 'url': 'http://jp.channel.pandora.tv/channel/video.ptv?c1=&prgid=53294230&ch_userid=mikakim&ref=main&lot=cate_01_2',
28 'description': '頭を撫でてくれる?',
29 'thumbnail': r
're:^https?://.*\.jpg$',
31 'upload_date': '20151218',
32 'uploader': 'カワイイ動物まとめ',
33 'uploader_id': 'mikakim',
39 def _real_extract(self
, url
):
40 qs
= compat_urlparse
.parse_qs(compat_urlparse
.urlparse(url
).query
)
41 video_id
= qs
.get('prgid', [None])[0]
42 user_id
= qs
.get('ch_userid', [None])[0]
43 if any(not f
for f
in (video_id
, user_id
,)):
44 raise ExtractorError('Invalid URL', expected
=True)
46 data
= self
._download
_json
(
47 'http://m.pandora.tv/?c=view&m=viewJsonApi&ch_userid=%s&prgid=%s'
48 % (user_id
, video_id
), video_id
)
50 info
= data
['data']['rows']['vod_play_info']['result']
53 for format_id
, format_url
in info
.items():
56 height
= self
._search
_regex
(
57 r
'^v(\d+)[Uu]rl$', format_id
, 'height', default
=None)
61 play_url
= self
._download
_json
(
62 'http://m.pandora.tv/?c=api&m=play_url', video_id
,
63 data
=urlencode_postdata({
65 'runtime': info
.get('runtime'),
66 'vod_url': format_url
,
70 'Content-Type': 'application/x-www-form-urlencoded',
72 format_url
= play_url
.get('url')
77 'format_id': '%sp' % height
,
79 'height': int(height
),
81 self
._sort
_formats
(formats
)
85 'title': info
['subject'],
86 'description': info
.get('body'),
87 'thumbnail': info
.get('thumbnail') or info
.get('poster'),
88 'duration': float_or_none(info
.get('runtime'), 1000) or parse_duration(info
.get('time')),
89 'upload_date': info
['fid'][:8] if isinstance(info
.get('fid'), compat_str
) else None,
90 'uploader': info
.get('nickname'),
91 'uploader_id': info
.get('upload_userid'),
92 'view_count': str_to_int(info
.get('hit')),
93 'like_count': str_to_int(info
.get('likecnt')),