epicon.py 4.1 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. id = self._match_id(url)
  45. webpage = self._download_webpage(url, 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(self._download_json('https://www.epicon.in/ajaxplayer/', id, headers=headers, data=data), id)
  50. if not data_json['success']:
  51. raise ExtractorError(data_json['message'], expected=True)
  52. title = self._search_regex(r'setplaytitle=\"([^\"]+)', webpage, 'title')
  53. description = self._og_search_description(webpage) or None
  54. thumbnail = self._og_search_thumbnail(webpage) or None
  55. formats = self._extract_m3u8_formats(data_json['url']['video_url'], id)
  56. subtitles = {}
  57. for subtitle in data_json.get('subtitles', []):
  58. sub_url = subtitle.get('file')
  59. if not sub_url:
  60. continue
  61. subtitles.setdefault(subtitle.get('lang', 'English'), []).append({
  62. 'url': self._proto_relative_url(sub_url),
  63. })
  64. return {
  65. 'id': id,
  66. 'formats': formats,
  67. 'title': title,
  68. 'description': description,
  69. 'thumbnail': thumbnail,
  70. 'subtitles': subtitles,
  71. }
  72. class EpiconSeriesIE(InfoExtractor):
  73. _VALID_URL = r'(?!.*season)https?://(?:www\.)?epicon\.in/tv-shows/(?P<id>[^/?#]+)'
  74. _TESTS = [{
  75. 'url': 'https://www.epicon.in/tv-shows/1-of-something',
  76. 'playlist_mincount': 5,
  77. 'info_dict': {
  78. 'id': '1-of-something',
  79. },
  80. }, {
  81. 'url': 'https://www.epicon.in/tv-shows/eco-india-english',
  82. 'playlist_mincount': 76,
  83. 'info_dict': {
  84. 'id': 'eco-india-english',
  85. },
  86. }, {
  87. 'url': 'https://www.epicon.in/tv-shows/s/',
  88. 'playlist_mincount': 25,
  89. 'info_dict': {
  90. 'id': 's',
  91. },
  92. }, {
  93. 'url': 'https://www.epicon.in/tv-shows/ekaant',
  94. 'playlist_mincount': 38,
  95. 'info_dict': {
  96. 'id': 'ekaant',
  97. },
  98. }]
  99. def _real_extract(self, url):
  100. id = self._match_id(url)
  101. webpage = self._download_webpage(url, id)
  102. episodes = re.findall(r'ct-tray-url=\"(tv-shows/%s/[^\"]+)' % id, webpage)
  103. entries = [self.url_result('https://www.epicon.in/%s' % episode, ie=EpiconIE.ie_key()) for episode in episodes]
  104. return self.playlist_result(entries, playlist_id=id)