voot.py 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. int_or_none,
  7. try_get,
  8. unified_timestamp,
  9. )
  10. class VootIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?voot\.com/(?:[^/]+/)+(?P<id>\d+)'
  12. _GEO_COUNTRIES = ['IN']
  13. _TESTS = [{
  14. 'url': 'https://www.voot.com/shows/ishq-ka-rang-safed/1/360558/is-this-the-end-of-kamini-/441353',
  15. 'info_dict': {
  16. 'id': '441353',
  17. 'ext': 'mp4',
  18. 'title': 'Ishq Ka Rang Safed - Season 01 - Episode 340',
  19. 'description': 'md5:06291fbbbc4dcbe21235c40c262507c1',
  20. 'timestamp': 1472162937,
  21. 'upload_date': '20160825',
  22. 'duration': 1146,
  23. 'series': 'Ishq Ka Rang Safed',
  24. 'season_number': 1,
  25. 'episode': 'Is this the end of Kamini?',
  26. 'episode_number': 340,
  27. 'view_count': int,
  28. 'like_count': int,
  29. },
  30. 'params': {
  31. 'skip_download': True,
  32. },
  33. 'expected_warnings': ['Failed to download m3u8 information'],
  34. }, {
  35. 'url': 'https://www.voot.com/kids/characters/mighty-cat-masked-niyander-e-/400478/school-bag-disappears/440925',
  36. 'only_matching': True,
  37. }, {
  38. 'url': 'https://www.voot.com/movies/pandavas-5/424627',
  39. 'only_matching': True,
  40. }]
  41. def _real_extract(self, url):
  42. video_id = self._match_id(url)
  43. media_info = self._download_json(
  44. 'https://wapi.voot.com/ws/ott/getMediaInfo.json', video_id,
  45. query={
  46. 'platform': 'Web',
  47. 'pId': 2,
  48. 'mediaId': video_id,
  49. })
  50. status_code = try_get(media_info, lambda x: x['status']['code'], int)
  51. if status_code != 0:
  52. raise ExtractorError(media_info['status']['message'], expected=True)
  53. media = media_info['assets']
  54. title = media['MediaName']
  55. formats = self._extract_m3u8_formats(
  56. 'https://cdnapisec.kaltura.com/p/1982551/playManifest/pt/https/f/applehttp/t/web/e/' + media['EntryId'],
  57. video_id, 'mp4', m3u8_id='hls', fatal=False)
  58. description, series, season_number, episode, episode_number = [None] * 5
  59. for meta in try_get(media, lambda x: x['Metas'], list) or []:
  60. key, value = meta.get('Key'), meta.get('Value')
  61. if not key or not value:
  62. continue
  63. if key == 'ContentSynopsis':
  64. description = value
  65. elif key == 'RefSeriesTitle':
  66. series = value
  67. elif key == 'RefSeriesSeason':
  68. season_number = int_or_none(value)
  69. elif key == 'EpisodeMainTitle':
  70. episode = value
  71. elif key == 'EpisodeNo':
  72. episode_number = int_or_none(value)
  73. return {
  74. 'id': video_id,
  75. 'title': title,
  76. 'description': description,
  77. 'series': series,
  78. 'season_number': season_number,
  79. 'episode': episode,
  80. 'episode_number': episode_number,
  81. 'timestamp': unified_timestamp(media.get('CreationDate')),
  82. 'duration': int_or_none(media.get('Duration')),
  83. 'view_count': int_or_none(media.get('ViewCounter')),
  84. 'like_count': int_or_none(media.get('like_counter')),
  85. 'formats': formats,
  86. }