manoto.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. clean_html,
  4. int_or_none,
  5. traverse_obj
  6. )
  7. _API_URL = 'https://dak1vd5vmi7x6.cloudfront.net/api/v1/publicrole/{}/{}?id={}'
  8. class ManotoTVIE(InfoExtractor):
  9. IE_DESC = 'Manoto TV (Episode)'
  10. _VALID_URL = r'https?://(?:www\.)?manototv\.com/episode/(?P<id>[0-9]+)'
  11. _TESTS = [{
  12. 'url': 'https://www.manototv.com/episode/8475',
  13. 'info_dict': {
  14. 'id': '8475',
  15. 'series': 'خانه های رویایی با برادران اسکات',
  16. 'season_number': 7,
  17. 'episode_number': 25,
  18. 'episode_id': 'My Dream Home S7: Carol & John',
  19. 'duration': 3600,
  20. 'categories': ['سرگرمی'],
  21. 'title': 'کارول و جان',
  22. 'description': 'md5:d0fff1f8ba5c6775d312a00165d1a97e',
  23. 'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$',
  24. 'ext': 'mp4'
  25. },
  26. 'params': {
  27. 'skip_download': 'm3u8',
  28. }
  29. }, {
  30. 'url': 'https://www.manototv.com/episode/12576',
  31. 'info_dict': {
  32. 'id': '12576',
  33. 'series': 'فیلم های ایرانی',
  34. 'episode_id': 'Seh Mah Taatili',
  35. 'duration': 5400,
  36. 'view_count': int,
  37. 'categories': ['سرگرمی'],
  38. 'title': 'سه ماه تعطیلی',
  39. 'description': 'سه ماه تعطیلی فیلمی به کارگردانی و نویسندگی شاپور قریب ساختهٔ سال ۱۳۵۶ است.',
  40. 'thumbnail': r're:^https?://.*\.(jpeg|png|jpg)$',
  41. 'ext': 'mp4'
  42. },
  43. 'params': {
  44. 'skip_download': 'm3u8',
  45. }
  46. }]
  47. def _real_extract(self, url):
  48. video_id = self._match_id(url)
  49. episode_json = self._download_json(_API_URL.format('showmodule', 'episodedetails', video_id), video_id)
  50. details = episode_json.get('details', {})
  51. formats = self._extract_m3u8_formats(details.get('videoM3u8Url'), video_id, 'mp4')
  52. return {
  53. 'id': video_id,
  54. 'series': details.get('showTitle'),
  55. 'season_number': int_or_none(details.get('analyticsSeasonNumber')),
  56. 'episode_number': int_or_none(details.get('episodeNumber')),
  57. 'episode_id': details.get('analyticsEpisodeTitle'),
  58. 'duration': int_or_none(details.get('durationInMinutes'), invscale=60),
  59. 'view_count': details.get('viewCount'),
  60. 'categories': [details.get('videoCategory')],
  61. 'title': details.get('episodeTitle'),
  62. 'description': clean_html(details.get('episodeDescription')),
  63. 'thumbnail': details.get('episodelandscapeImgIxUrl'),
  64. 'formats': formats,
  65. }
  66. class ManotoTVShowIE(InfoExtractor):
  67. IE_DESC = 'Manoto TV (Show)'
  68. _VALID_URL = r'https?://(?:www\.)?manototv\.com/show/(?P<id>[0-9]+)'
  69. _TESTS = [{
  70. 'url': 'https://www.manototv.com/show/2526',
  71. 'playlist_mincount': 68,
  72. 'info_dict': {
  73. 'id': '2526',
  74. 'title': 'فیلم های ایرانی',
  75. 'description': 'مجموعه ای از فیلم های سینمای کلاسیک ایران',
  76. },
  77. }]
  78. def _real_extract(self, url):
  79. show_id = self._match_id(url)
  80. show_json = self._download_json(_API_URL.format('showmodule', 'details', show_id), show_id)
  81. show_details = show_json.get('details', {})
  82. title = show_details.get('showTitle')
  83. description = show_details.get('showSynopsis')
  84. series_json = self._download_json(_API_URL.format('showmodule', 'serieslist', show_id), show_id)
  85. playlist_id = str(traverse_obj(series_json, ('details', 'list', 0, 'id')))
  86. playlist_json = self._download_json(_API_URL.format('showmodule', 'episodelist', playlist_id), playlist_id)
  87. playlist = traverse_obj(playlist_json, ('details', 'list')) or []
  88. entries = [
  89. self.url_result(
  90. 'https://www.manototv.com/episode/%s' % item['slideID'], ie=ManotoTVIE.ie_key(), video_id=item['slideID'])
  91. for item in playlist]
  92. return self.playlist_result(entries, show_id, title, description)
  93. class ManotoTVLiveIE(InfoExtractor):
  94. IE_DESC = 'Manoto TV (Live)'
  95. _VALID_URL = r'https?://(?:www\.)?manototv\.com/live/'
  96. _TEST = {
  97. 'url': 'https://www.manototv.com/live/',
  98. 'info_dict': {
  99. 'id': 'live',
  100. 'title': 'Manoto TV Live',
  101. 'ext': 'mp4',
  102. 'is_live': True,
  103. },
  104. 'params': {
  105. 'skip_download': 'm3u8',
  106. }
  107. }
  108. def _real_extract(self, url):
  109. video_id = 'live'
  110. json = self._download_json(_API_URL.format('livemodule', 'details', ''), video_id)
  111. details = json.get('details', {})
  112. video_url = details.get('liveUrl')
  113. formats = self._extract_m3u8_formats(video_url, video_id, 'mp4', live=True)
  114. return {
  115. 'id': video_id,
  116. 'title': 'Manoto TV Live',
  117. 'is_live': True,
  118. 'formats': formats,
  119. }