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.

98 lines
3.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .kaltura import KalturaIE
  5. from ..utils import (
  6. ExtractorError,
  7. int_or_none,
  8. try_get,
  9. unified_timestamp,
  10. )
  11. class VootIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?voot\.com/(?:[^/]+/)+(?P<id>\d+)'
  13. _GEO_COUNTRIES = ['IN']
  14. _TESTS = [{
  15. 'url': 'https://www.voot.com/shows/ishq-ka-rang-safed/1/360558/is-this-the-end-of-kamini-/441353',
  16. 'info_dict': {
  17. 'id': '0_8ledb18o',
  18. 'ext': 'mp4',
  19. 'title': 'Ishq Ka Rang Safed - Season 01 - Episode 340',
  20. 'description': 'md5:06291fbbbc4dcbe21235c40c262507c1',
  21. 'uploader_id': 'batchUser',
  22. 'timestamp': 1472162937,
  23. 'upload_date': '20160825',
  24. 'duration': 1146,
  25. 'series': 'Ishq Ka Rang Safed',
  26. 'season_number': 1,
  27. 'episode': 'Is this the end of Kamini?',
  28. 'episode_number': 340,
  29. 'view_count': int,
  30. 'like_count': int,
  31. },
  32. 'params': {
  33. 'skip_download': True,
  34. },
  35. 'expected_warnings': ['Failed to download m3u8 information'],
  36. }, {
  37. 'url': 'https://www.voot.com/kids/characters/mighty-cat-masked-niyander-e-/400478/school-bag-disappears/440925',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'https://www.voot.com/movies/pandavas-5/424627',
  41. 'only_matching': True,
  42. }]
  43. def _real_extract(self, url):
  44. video_id = self._match_id(url)
  45. media_info = self._download_json(
  46. 'https://wapi.voot.com/ws/ott/getMediaInfo.json', video_id,
  47. query={
  48. 'platform': 'Web',
  49. 'pId': 2,
  50. 'mediaId': video_id,
  51. })
  52. status_code = try_get(media_info, lambda x: x['status']['code'], int)
  53. if status_code != 0:
  54. raise ExtractorError(media_info['status']['message'], expected=True)
  55. media = media_info['assets']
  56. entry_id = media['EntryId']
  57. title = media['MediaName']
  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. '_type': 'url_transparent',
  75. 'url': 'kaltura:1982551:%s' % entry_id,
  76. 'ie_key': KalturaIE.ie_key(),
  77. 'title': title,
  78. 'description': description,
  79. 'series': series,
  80. 'season_number': season_number,
  81. 'episode': episode,
  82. 'episode_number': episode_number,
  83. 'timestamp': unified_timestamp(media.get('CreationDate')),
  84. 'duration': int_or_none(media.get('Duration')),
  85. 'view_count': int_or_none(media.get('ViewCounter')),
  86. 'like_count': int_or_none(media.get('like_counter')),
  87. }