2 from __future__ import unicode_literals
4 from .common import InfoExtractor
17 class PandoraTVIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:.+?\.)?channel\.pandora\.tv/channel/video\.ptv\?'
20 'url': 'http://jp.channel.pandora.tv/channel/video.ptv?c1=&prgid=53294230&ch_userid=mikakim&ref=main&lot=cate_01_2',
25 'description': '頭を撫でてくれる?',
26 'thumbnail': 're:^https?://.*\.jpg$',
28 'upload_date': '20151218',
29 'uploader': 'カワイイ動物まとめ',
30 'uploader_id': 'mikakim',
36 def _real_extract(self, url):
37 qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
38 video_id = qs.get('prgid', [None])[0]
39 user_id = qs.get('ch_userid', [None])[0]
40 if any(not f for f in (video_id, user_id,)):
41 raise ExtractorError('Invalid URL', expected=True)
43 data = self._download_json(
44 'http://m.pandora.tv/?c=view&m=viewJsonApi&ch_userid=%s&prgid=%s'
45 % (user_id, video_id), video_id)
47 info = data['data']['rows']['vod_play_info']['result']
50 for format_id, format_url in info.items():
53 height = self._search_regex(
54 r'^v(\d+)[Uu]rl$', format_id, 'height', default=None)
58 'format_id': '%sp' % height,
60 'height': int(height),
62 self._sort_formats(formats)
66 'title': info['subject'],
67 'description': info.get('body'),
68 'thumbnail': info.get('thumbnail') or info.get('poster'),
69 'duration': float_or_none(info.get('runtime'), 1000) or parse_duration(info.get('time')),
70 'upload_date': info['fid'][:8] if isinstance(info.get('fid'), compat_str) else None,
71 'uploader': info.get('nickname'),
72 'uploader_id': info.get('upload_userid'),
73 'view_count': str_to_int(info.get('hit')),
74 'like_count': str_to_int(info.get('likecnt')),