2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class NocoIE(InfoExtractor):
15 _VALID_URL = r'http://(?:(?:www\.)?noco\.tv/emission/|player\.noco\.tv/\?idvideo=)(?P<id>\d+)'
18 'url': 'http://noco.tv/emission/11538/nolife/ami-ami-idol-hello-france/',
19 'md5': '0a993f0058ddbcd902630b2047ef710e',
23 'title': 'Ami Ami Idol - Hello! France',
24 'description': 'md5:4eaab46ab68fa4197a317a88a53d3b86',
25 'upload_date': '20140412',
32 def _real_extract(self, url):
33 mobj = re.match(self._VALID_URL, url)
34 video_id = mobj.group('id')
36 medias = self._download_json(
37 'http://api.noco.tv/1.0/video/medias/%s' % video_id, video_id, 'Downloading video JSON')
41 for fmt in medias['fr']['video_list']['default']['quality_list']:
42 format_id = fmt['quality_key']
44 file = self._download_json(
45 'http://api.noco.tv/1.0/video/file/%s/fr/%s' % (format_id.lower(), video_id),
46 video_id, 'Downloading %s video JSON' % format_id)
48 file_url = file['file']
52 if file_url == 'forbidden':
54 '%s returned error: %s - %s' % (
55 self.IE_NAME, file['popmessage']['title'], file['popmessage']['message']),
60 'format_id': format_id,
61 'width': fmt['res_width'],
62 'height': fmt['res_lines'],
63 'abr': fmt['audiobitrate'],
64 'vbr': fmt['videobitrate'],
65 'filesize': fmt['filesize'],
66 'format_note': fmt['quality_name'],
67 'preference': fmt['priority'],
70 self._sort_formats(formats)
72 show = self._download_json(
73 'http://api.noco.tv/1.0/shows/show/%s' % video_id, video_id, 'Downloading show JSON')[0]
75 upload_date = unified_strdate(show['indexed'])
76 uploader = show['partner_name']
77 uploader_id = show['partner_key']
78 duration = show['duration_ms'] / 1000.0
79 thumbnail = show['screenshot']
81 episode = show.get('show_TT') or show.get('show_OT')
82 family = show.get('family_TT') or show.get('family_OT')
83 episode_number = show.get('episode_number')
89 title += ' #' + compat_str(episode_number)
91 title += ' - ' + episode
93 description = show.get('show_resume') or show.get('family_resume')
98 'description': description,
99 'thumbnail': thumbnail,
100 'upload_date': upload_date,
101 'uploader': uploader,
102 'uploader_id': uploader_id,
103 'duration': duration,