You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

384 lines
13 KiB

11 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
Switch codebase to use sanitized_Request instead of compat_urllib_request.Request [downloader/dash] Use sanitized_Request [downloader/http] Use sanitized_Request [atresplayer] Use sanitized_Request [bambuser] Use sanitized_Request [bliptv] Use sanitized_Request [brightcove] Use sanitized_Request [cbs] Use sanitized_Request [ceskatelevize] Use sanitized_Request [collegerama] Use sanitized_Request [extractor/common] Use sanitized_Request [crunchyroll] Use sanitized_Request [dailymotion] Use sanitized_Request [dcn] Use sanitized_Request [dramafever] Use sanitized_Request [dumpert] Use sanitized_Request [eitb] Use sanitized_Request [escapist] Use sanitized_Request [everyonesmixtape] Use sanitized_Request [extremetube] Use sanitized_Request [facebook] Use sanitized_Request [fc2] Use sanitized_Request [flickr] Use sanitized_Request [4tube] Use sanitized_Request [gdcvault] Use sanitized_Request [extractor/generic] Use sanitized_Request [hearthisat] Use sanitized_Request [hotnewhiphop] Use sanitized_Request [hypem] Use sanitized_Request [iprima] Use sanitized_Request [ivi] Use sanitized_Request [keezmovies] Use sanitized_Request [letv] Use sanitized_Request [lynda] Use sanitized_Request [metacafe] Use sanitized_Request [minhateca] Use sanitized_Request [miomio] Use sanitized_Request [meovideo] Use sanitized_Request [mofosex] Use sanitized_Request [moniker] Use sanitized_Request [mooshare] Use sanitized_Request [movieclips] Use sanitized_Request [mtv] Use sanitized_Request [myvideo] Use sanitized_Request [neteasemusic] Use sanitized_Request [nfb] Use sanitized_Request [niconico] Use sanitized_Request [noco] Use sanitized_Request [nosvideo] Use sanitized_Request [novamov] Use sanitized_Request [nowness] Use sanitized_Request [nuvid] Use sanitized_Request [played] Use sanitized_Request [pluralsight] Use sanitized_Request [pornhub] Use sanitized_Request [pornotube] Use sanitized_Request [primesharetv] Use sanitized_Request [promptfile] Use sanitized_Request [qqmusic] Use sanitized_Request [rtve] Use sanitized_Request [safari] Use sanitized_Request [sandia] Use sanitized_Request [shared] Use sanitized_Request [sharesix] Use sanitized_Request [sina] Use sanitized_Request [smotri] Use sanitized_Request [sohu] Use sanitized_Request [spankwire] Use sanitized_Request [sportdeutschland] Use sanitized_Request [streamcloud] Use sanitized_Request [streamcz] Use sanitized_Request [tapely] Use sanitized_Request [tube8] Use sanitized_Request [tubitv] Use sanitized_Request [twitch] Use sanitized_Request [twitter] Use sanitized_Request [udemy] Use sanitized_Request [vbox7] Use sanitized_Request [veoh] Use sanitized_Request [vessel] Use sanitized_Request [vevo] Use sanitized_Request [viddler] Use sanitized_Request [videomega] Use sanitized_Request [viewvster] Use sanitized_Request [viki] Use sanitized_Request [vk] Use sanitized_Request [vodlocker] Use sanitized_Request [voicerepublic] Use sanitized_Request [wistia] Use sanitized_Request [xfileshare] Use sanitized_Request [xtube] Use sanitized_Request [xvideos] Use sanitized_Request [yandexmusic] Use sanitized_Request [youku] Use sanitized_Request [youporn] Use sanitized_Request [youtube] Use sanitized_Request [patreon] Use sanitized_Request [extractor/common] Remove unused import [nfb] PEP 8
9 years ago
11 years ago
11 years ago
11 years ago
10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import hashlib
  4. import hmac
  5. import itertools
  6. import json
  7. import re
  8. import time
  9. from .common import InfoExtractor
  10. from ..utils import (
  11. ExtractorError,
  12. int_or_none,
  13. parse_age_limit,
  14. parse_iso8601,
  15. sanitized_Request,
  16. )
  17. class VikiBaseIE(InfoExtractor):
  18. _VALID_URL_BASE = r'https?://(?:www\.)?viki\.(?:com|net|mx|jp|fr)/'
  19. _API_QUERY_TEMPLATE = '/v4/%sapp=%s&t=%s&site=www.viki.com'
  20. _API_URL_TEMPLATE = 'https://api.viki.io%s&sig=%s'
  21. _APP = '100005a'
  22. _APP_VERSION = '2.2.5.1428709186'
  23. _APP_SECRET = 'MM_d*yP@`&1@]@!AVrXf_o-HVEnoTnm$O-ti4[G~$JDI/Dc-&piU&z&5.;:}95=Iad'
  24. _GEO_BYPASS = False
  25. _NETRC_MACHINE = 'viki'
  26. _token = None
  27. _ERRORS = {
  28. 'geo': 'Sorry, this content is not available in your region.',
  29. 'upcoming': 'Sorry, this content is not yet available.',
  30. # 'paywall': 'paywall',
  31. }
  32. def _prepare_call(self, path, timestamp=None, post_data=None):
  33. path += '?' if '?' not in path else '&'
  34. if not timestamp:
  35. timestamp = int(time.time())
  36. query = self._API_QUERY_TEMPLATE % (path, self._APP, timestamp)
  37. if self._token:
  38. query += '&token=%s' % self._token
  39. sig = hmac.new(
  40. self._APP_SECRET.encode('ascii'),
  41. query.encode('ascii'),
  42. hashlib.sha1
  43. ).hexdigest()
  44. url = self._API_URL_TEMPLATE % (query, sig)
  45. return sanitized_Request(
  46. url, json.dumps(post_data).encode('utf-8')) if post_data else url
  47. def _call_api(self, path, video_id, note, timestamp=None, post_data=None):
  48. resp = self._download_json(
  49. self._prepare_call(path, timestamp, post_data), video_id, note)
  50. error = resp.get('error')
  51. if error:
  52. if error == 'invalid timestamp':
  53. resp = self._download_json(
  54. self._prepare_call(path, int(resp['current_timestamp']), post_data),
  55. video_id, '%s (retry)' % note)
  56. error = resp.get('error')
  57. if error:
  58. self._raise_error(resp['error'])
  59. return resp
  60. def _raise_error(self, error):
  61. raise ExtractorError(
  62. '%s returned error: %s' % (self.IE_NAME, error),
  63. expected=True)
  64. def _check_errors(self, data):
  65. for reason, status in data.get('blocking', {}).items():
  66. if status and reason in self._ERRORS:
  67. message = self._ERRORS[reason]
  68. if reason == 'geo':
  69. self.raise_geo_restricted(msg=message)
  70. raise ExtractorError('%s said: %s' % (
  71. self.IE_NAME, message), expected=True)
  72. def _real_initialize(self):
  73. self._login()
  74. def _login(self):
  75. username, password = self._get_login_info()
  76. if username is None:
  77. return
  78. login_form = {
  79. 'login_id': username,
  80. 'password': password,
  81. }
  82. login = self._call_api(
  83. 'sessions.json', None,
  84. 'Logging in', post_data=login_form)
  85. self._token = login.get('token')
  86. if not self._token:
  87. self.report_warning('Unable to get session token, login has probably failed')
  88. @staticmethod
  89. def dict_selection(dict_obj, preferred_key, allow_fallback=True):
  90. if preferred_key in dict_obj:
  91. return dict_obj.get(preferred_key)
  92. if not allow_fallback:
  93. return
  94. filtered_dict = list(filter(None, [dict_obj.get(k) for k in dict_obj.keys()]))
  95. return filtered_dict[0] if filtered_dict else None
  96. class VikiIE(VikiBaseIE):
  97. IE_NAME = 'viki'
  98. _VALID_URL = r'%s(?:videos|player)/(?P<id>[0-9]+v)' % VikiBaseIE._VALID_URL_BASE
  99. _TESTS = [{
  100. 'url': 'http://www.viki.com/videos/1023585v-heirs-episode-14',
  101. 'info_dict': {
  102. 'id': '1023585v',
  103. 'ext': 'mp4',
  104. 'title': 'Heirs Episode 14',
  105. 'uploader': 'SBS',
  106. 'description': 'md5:c4b17b9626dd4b143dcc4d855ba3474e',
  107. 'upload_date': '20131121',
  108. 'age_limit': 13,
  109. },
  110. 'skip': 'Blocked in the US',
  111. }, {
  112. # clip
  113. 'url': 'http://www.viki.com/videos/1067139v-the-avengers-age-of-ultron-press-conference',
  114. 'md5': '86c0b5dbd4d83a6611a79987cc7a1989',
  115. 'info_dict': {
  116. 'id': '1067139v',
  117. 'ext': 'mp4',
  118. 'title': "'The Avengers: Age of Ultron' Press Conference",
  119. 'description': 'md5:d70b2f9428f5488321bfe1db10d612ea',
  120. 'duration': 352,
  121. 'timestamp': 1430380829,
  122. 'upload_date': '20150430',
  123. 'uploader': 'Arirang TV',
  124. 'like_count': int,
  125. 'age_limit': 0,
  126. }
  127. }, {
  128. 'url': 'http://www.viki.com/videos/1048879v-ankhon-dekhi',
  129. 'info_dict': {
  130. 'id': '1048879v',
  131. 'ext': 'mp4',
  132. 'title': 'Ankhon Dekhi',
  133. 'duration': 6512,
  134. 'timestamp': 1408532356,
  135. 'upload_date': '20140820',
  136. 'uploader': 'Spuul',
  137. 'like_count': int,
  138. 'age_limit': 13,
  139. },
  140. 'skip': 'Blocked in the US',
  141. }, {
  142. # episode
  143. 'url': 'http://www.viki.com/videos/44699v-boys-over-flowers-episode-1',
  144. 'md5': '5fa476a902e902783ac7a4d615cdbc7a',
  145. 'info_dict': {
  146. 'id': '44699v',
  147. 'ext': 'mp4',
  148. 'title': 'Boys Over Flowers - Episode 1',
  149. 'description': 'md5:b89cf50038b480b88b5b3c93589a9076',
  150. 'duration': 4204,
  151. 'timestamp': 1270496524,
  152. 'upload_date': '20100405',
  153. 'uploader': 'group8',
  154. 'like_count': int,
  155. 'age_limit': 13,
  156. }
  157. }, {
  158. # youtube external
  159. 'url': 'http://www.viki.com/videos/50562v-poor-nastya-complete-episode-1',
  160. 'md5': '63f8600c1da6f01b7640eee7eca4f1da',
  161. 'info_dict': {
  162. 'id': '50562v',
  163. 'ext': 'webm',
  164. 'title': 'Poor Nastya [COMPLETE] - Episode 1',
  165. 'description': '',
  166. 'duration': 606,
  167. 'timestamp': 1274949505,
  168. 'upload_date': '20101213',
  169. 'uploader': 'ad14065n',
  170. 'uploader_id': 'ad14065n',
  171. 'like_count': int,
  172. 'age_limit': 13,
  173. }
  174. }, {
  175. 'url': 'http://www.viki.com/player/44699v',
  176. 'only_matching': True,
  177. }, {
  178. # non-English description
  179. 'url': 'http://www.viki.com/videos/158036v-love-in-magic',
  180. 'md5': '1713ae35df5a521b31f6dc40730e7c9c',
  181. 'info_dict': {
  182. 'id': '158036v',
  183. 'ext': 'mp4',
  184. 'uploader': 'I Planet Entertainment',
  185. 'upload_date': '20111122',
  186. 'timestamp': 1321985454,
  187. 'description': 'md5:44b1e46619df3a072294645c770cef36',
  188. 'title': 'Love In Magic',
  189. 'age_limit': 13,
  190. },
  191. }]
  192. def _real_extract(self, url):
  193. video_id = self._match_id(url)
  194. video = self._call_api(
  195. 'videos/%s.json' % video_id, video_id, 'Downloading video JSON')
  196. self._check_errors(video)
  197. title = self.dict_selection(video.get('titles', {}), 'en', allow_fallback=False)
  198. if not title:
  199. title = 'Episode %d' % video.get('number') if video.get('type') == 'episode' else video.get('id') or video_id
  200. container_titles = video.get('container', {}).get('titles', {})
  201. container_title = self.dict_selection(container_titles, 'en')
  202. title = '%s - %s' % (container_title, title)
  203. description = self.dict_selection(video.get('descriptions', {}), 'en')
  204. duration = int_or_none(video.get('duration'))
  205. timestamp = parse_iso8601(video.get('created_at'))
  206. uploader = video.get('author')
  207. like_count = int_or_none(video.get('likes', {}).get('count'))
  208. age_limit = parse_age_limit(video.get('rating'))
  209. thumbnails = []
  210. for thumbnail_id, thumbnail in video.get('images', {}).items():
  211. thumbnails.append({
  212. 'id': thumbnail_id,
  213. 'url': thumbnail.get('url'),
  214. })
  215. subtitles = {}
  216. for subtitle_lang, _ in video.get('subtitle_completions', {}).items():
  217. subtitles[subtitle_lang] = [{
  218. 'ext': subtitles_format,
  219. 'url': self._prepare_call(
  220. 'videos/%s/subtitles/%s.%s' % (video_id, subtitle_lang, subtitles_format)),
  221. } for subtitles_format in ('srt', 'vtt')]
  222. result = {
  223. 'id': video_id,
  224. 'title': title,
  225. 'description': description,
  226. 'duration': duration,
  227. 'timestamp': timestamp,
  228. 'uploader': uploader,
  229. 'like_count': like_count,
  230. 'age_limit': age_limit,
  231. 'thumbnails': thumbnails,
  232. 'subtitles': subtitles,
  233. }
  234. streams = self._call_api(
  235. 'videos/%s/streams.json' % video_id, video_id,
  236. 'Downloading video streams JSON')
  237. if 'external' in streams:
  238. result.update({
  239. '_type': 'url_transparent',
  240. 'url': streams['external']['url'],
  241. })
  242. return result
  243. formats = []
  244. for format_id, stream_dict in streams.items():
  245. height = int_or_none(self._search_regex(
  246. r'^(\d+)[pP]$', format_id, 'height', default=None))
  247. for protocol, format_dict in stream_dict.items():
  248. # rtmps URLs does not seem to work
  249. if protocol == 'rtmps':
  250. continue
  251. format_url = format_dict['url']
  252. if format_id == 'm3u8':
  253. m3u8_formats = self._extract_m3u8_formats(
  254. format_url, video_id, 'mp4',
  255. entry_protocol='m3u8_native',
  256. m3u8_id='m3u8-%s' % protocol, fatal=False)
  257. # Despite CODECS metadata in m3u8 all video-only formats
  258. # are actually video+audio
  259. for f in m3u8_formats:
  260. if f.get('acodec') == 'none' and f.get('vcodec') != 'none':
  261. f['acodec'] = None
  262. formats.extend(m3u8_formats)
  263. elif format_url.startswith('rtmp'):
  264. mobj = re.search(
  265. r'^(?P<url>rtmp://[^/]+/(?P<app>.+?))/(?P<playpath>mp4:.+)$',
  266. format_url)
  267. if not mobj:
  268. continue
  269. formats.append({
  270. 'format_id': 'rtmp-%s' % format_id,
  271. 'ext': 'flv',
  272. 'url': mobj.group('url'),
  273. 'play_path': mobj.group('playpath'),
  274. 'app': mobj.group('app'),
  275. 'page_url': url,
  276. })
  277. else:
  278. formats.append({
  279. 'url': format_url,
  280. 'format_id': '%s-%s' % (format_id, protocol),
  281. 'height': height,
  282. })
  283. self._sort_formats(formats)
  284. result['formats'] = formats
  285. return result
  286. class VikiChannelIE(VikiBaseIE):
  287. IE_NAME = 'viki:channel'
  288. _VALID_URL = r'%s(?:tv|news|movies|artists)/(?P<id>[0-9]+c)' % VikiBaseIE._VALID_URL_BASE
  289. _TESTS = [{
  290. 'url': 'http://www.viki.com/tv/50c-boys-over-flowers',
  291. 'info_dict': {
  292. 'id': '50c',
  293. 'title': 'Boys Over Flowers',
  294. 'description': 'md5:ecd3cff47967fe193cff37c0bec52790',
  295. },
  296. 'playlist_mincount': 71,
  297. }, {
  298. 'url': 'http://www.viki.com/tv/1354c-poor-nastya-complete',
  299. 'info_dict': {
  300. 'id': '1354c',
  301. 'title': 'Poor Nastya [COMPLETE]',
  302. 'description': 'md5:05bf5471385aa8b21c18ad450e350525',
  303. },
  304. 'playlist_count': 127,
  305. }, {
  306. 'url': 'http://www.viki.com/news/24569c-showbiz-korea',
  307. 'only_matching': True,
  308. }, {
  309. 'url': 'http://www.viki.com/movies/22047c-pride-and-prejudice-2005',
  310. 'only_matching': True,
  311. }, {
  312. 'url': 'http://www.viki.com/artists/2141c-shinee',
  313. 'only_matching': True,
  314. }]
  315. _PER_PAGE = 25
  316. def _real_extract(self, url):
  317. channel_id = self._match_id(url)
  318. channel = self._call_api(
  319. 'containers/%s.json' % channel_id, channel_id,
  320. 'Downloading channel JSON')
  321. self._check_errors(channel)
  322. title = self.dict_selection(channel['titles'], 'en')
  323. description = self.dict_selection(channel['descriptions'], 'en')
  324. entries = []
  325. for video_type in ('episodes', 'clips', 'movies'):
  326. for page_num in itertools.count(1):
  327. page = self._call_api(
  328. 'containers/%s/%s.json?per_page=%d&sort=number&direction=asc&with_paging=true&page=%d'
  329. % (channel_id, video_type, self._PER_PAGE, page_num), channel_id,
  330. 'Downloading %s JSON page #%d' % (video_type, page_num))
  331. for video in page['response']:
  332. video_id = video['id']
  333. entries.append(self.url_result(
  334. 'https://www.viki.com/videos/%s' % video_id, 'Viki'))
  335. if not page['pagination']['next']:
  336. break
  337. return self.playlist_result(entries, channel_id, title, description)