epicon.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import ExtractorError
  4. class EpiconIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?epicon\.in/(?:documentaries|movies|tv-shows/[^/?#]+/[^/?#]+)/(?P<id>[^/?#]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.epicon.in/documentaries/air-battle-of-srinagar',
  8. 'info_dict': {
  9. 'id': 'air-battle-of-srinagar',
  10. 'ext': 'mp4',
  11. 'title': 'Air Battle of Srinagar',
  12. 'description': 'md5:c4de2013af9bc05ae4392e4115d518d7',
  13. 'thumbnail': r're:^https?://.*\.jpg$',
  14. },
  15. }, {
  16. 'url': 'https://www.epicon.in/movies/krit',
  17. 'info_dict': {
  18. 'id': 'krit',
  19. 'ext': 'mp4',
  20. 'title': 'Krit',
  21. 'description': 'md5:c12b35dad915d48ccff7f013c79bab4a',
  22. 'thumbnail': r're:^https?://.*\.jpg$',
  23. },
  24. }, {
  25. 'url': 'https://www.epicon.in/tv-shows/paapnaashini-ganga/season-1/vardaan',
  26. 'info_dict': {
  27. 'id': 'vardaan',
  28. 'ext': 'mp4',
  29. 'title': 'Paapnaashini Ganga - Season 1 - Ep 1 - VARDAAN',
  30. 'description': 'md5:f517058c3d0402398eefa6242f4dd6ae',
  31. 'thumbnail': r're:^https?://.*\.jpg$',
  32. },
  33. }, {
  34. 'url': 'https://www.epicon.in/movies/jayadev',
  35. 'info_dict': {
  36. 'id': 'jayadev',
  37. 'ext': 'mp4',
  38. 'title': 'Jayadev',
  39. 'description': 'md5:09e349eecd8e585a3b6466904f19df6c',
  40. 'thumbnail': r're:^https?://.*\.jpg$',
  41. },
  42. }]
  43. def _real_extract(self, url):
  44. video_id = self._match_id(url)
  45. webpage = self._download_webpage(url, video_id)
  46. cid = self._search_regex(r'class=\"mylist-icon\ iconclick\"\ id=\"(\d+)', webpage, 'cid')
  47. headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'}
  48. data = f'cid={cid}&action=st&type=video'.encode()
  49. data_json = self._parse_json(
  50. self._download_json('https://www.epicon.in/ajaxplayer/', video_id, headers=headers, data=data), video_id)
  51. if not data_json['success']:
  52. raise ExtractorError(data_json['message'], expected=True)
  53. title = self._search_regex(r'setplaytitle=\"([^\"]+)', webpage, 'title')
  54. description = self._og_search_description(webpage) or None
  55. thumbnail = self._og_search_thumbnail(webpage) or None
  56. formats = self._extract_m3u8_formats(data_json['url']['video_url'], video_id)
  57. subtitles = {}
  58. for subtitle in data_json.get('subtitles', []):
  59. sub_url = subtitle.get('file')
  60. if not sub_url:
  61. continue
  62. subtitles.setdefault(subtitle.get('lang', 'English'), []).append({
  63. 'url': self._proto_relative_url(sub_url),
  64. })
  65. return {
  66. 'id': video_id,
  67. 'formats': formats,
  68. 'title': title,
  69. 'description': description,
  70. 'thumbnail': thumbnail,
  71. 'subtitles': subtitles,
  72. }
  73. class EpiconSeriesIE(InfoExtractor):
  74. _VALID_URL = r'(?!.*season)https?://(?:www\.)?epicon\.in/tv-shows/(?P<id>[^/?#]+)'
  75. _TESTS = [{
  76. 'url': 'https://www.epicon.in/tv-shows/1-of-something',
  77. 'playlist_mincount': 5,
  78. 'info_dict': {
  79. 'id': '1-of-something',
  80. },
  81. }, {
  82. 'url': 'https://www.epicon.in/tv-shows/eco-india-english',
  83. 'playlist_mincount': 76,
  84. 'info_dict': {
  85. 'id': 'eco-india-english',
  86. },
  87. }, {
  88. 'url': 'https://www.epicon.in/tv-shows/s/',
  89. 'playlist_mincount': 25,
  90. 'info_dict': {
  91. 'id': 's',
  92. },
  93. }, {
  94. 'url': 'https://www.epicon.in/tv-shows/ekaant',
  95. 'playlist_mincount': 38,
  96. 'info_dict': {
  97. 'id': 'ekaant',
  98. },
  99. }]
  100. def _real_extract(self, url):
  101. playlist_id = self._match_id(url)
  102. webpage = self._download_webpage(url, playlist_id)
  103. episodes = re.findall(rf'ct-tray-url=\"(tv-shows/{playlist_id}/[^\"]+)', webpage)
  104. entries = [self.url_result(f'https://www.epicon.in/{episode}', EpiconIE) for episode in episodes]
  105. return self.playlist_result(entries, playlist_id=playlist_id)