logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

voot.py (3560B)


  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': '0_8ledb18o',
  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. entry_id = media['EntryId']
  55. title = media['MediaName']
  56. formats = self._extract_m3u8_formats(
  57. 'https://cdnapisec.kaltura.com/p/1982551/playManifest/pt/https/f/applehttp/t/web/e/' + entry_id,
  58. video_id, 'mp4', m3u8_id='hls')
  59. self._sort_formats(formats)
  60. description, series, season_number, episode, episode_number = [None] * 5
  61. for meta in try_get(media, lambda x: x['Metas'], list) or []:
  62. key, value = meta.get('Key'), meta.get('Value')
  63. if not key or not value:
  64. continue
  65. if key == 'ContentSynopsis':
  66. description = value
  67. elif key == 'RefSeriesTitle':
  68. series = value
  69. elif key == 'RefSeriesSeason':
  70. season_number = int_or_none(value)
  71. elif key == 'EpisodeMainTitle':
  72. episode = value
  73. elif key == 'EpisodeNo':
  74. episode_number = int_or_none(value)
  75. return {
  76. 'extractor_key': 'Kaltura',
  77. 'id': entry_id,
  78. 'title': title,
  79. 'description': description,
  80. 'series': series,
  81. 'season_number': season_number,
  82. 'episode': episode,
  83. 'episode_number': episode_number,
  84. 'timestamp': unified_timestamp(media.get('CreationDate')),
  85. 'duration': int_or_none(media.get('Duration')),
  86. 'view_count': int_or_none(media.get('ViewCounter')),
  87. 'like_count': int_or_none(media.get('like_counter')),
  88. 'formats': formats,
  89. }