]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/pandoratv.py
fc7bd34112f8863b741a67e2b97d473c7fc55e55
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',
38 'url': 'http://channel.pandora.tv/channel/video.ptv?ch_userid=gogoucc&prgid=54721744',
42 'title': '[HD] JAPAN COUNTDOWN 170423',
43 'description': '[HD] JAPAN COUNTDOWN 170423',
44 'thumbnail': r
're:^https?://.*\.jpg$',
46 'upload_date': '20170423',
47 'uploader': 'GOGO_UCC',
48 'uploader_id': 'gogoucc',
54 'skip_download': True,
58 def _real_extract(self
, url
):
59 qs
= compat_urlparse
.parse_qs(compat_urlparse
.urlparse(url
).query
)
60 video_id
= qs
.get('prgid', [None])[0]
61 user_id
= qs
.get('ch_userid', [None])[0]
62 if any(not f
for f
in (video_id
, user_id
,)):
63 raise ExtractorError('Invalid URL', expected
=True)
65 data
= self
._download
_json
(
66 'http://m.pandora.tv/?c=view&m=viewJsonApi&ch_userid=%s&prgid=%s'
67 % (user_id
, video_id
), video_id
)
69 info
= data
['data']['rows']['vod_play_info']['result']
72 for format_id
, format_url
in info
.items():
75 height
= self
._search
_regex
(
76 r
'^v(\d+)[Uu]rl$', format_id
, 'height', default
=None)
80 play_url
= self
._download
_json
(
81 'http://m.pandora.tv/?c=api&m=play_url', video_id
,
82 data
=urlencode_postdata({
84 'runtime': info
.get('runtime'),
85 'vod_url': format_url
,
89 'Content-Type': 'application/x-www-form-urlencoded',
91 format_url
= play_url
.get('url')
96 'format_id': '%sp' % height
,
98 'height': int(height
),
100 self
._sort
_formats
(formats
)
104 'title': info
['subject'],
105 'description': info
.get('body'),
106 'thumbnail': info
.get('thumbnail') or info
.get('poster'),
107 'duration': float_or_none(info
.get('runtime'), 1000) or parse_duration(info
.get('time')),
108 'upload_date': info
['fid'].split('/')[-1][:8] if isinstance(info
.get('fid'), compat_str
) else None,
109 'uploader': info
.get('nickname'),
110 'uploader_id': info
.get('upload_userid'),
111 'view_count': str_to_int(info
.get('hit')),
112 'like_count': str_to_int(info
.get('likecnt')),