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