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.

59 lines
2.0 KiB

  1. from .common import InfoExtractor
  2. from ..utils import (
  3. get_element_by_id,
  4. ExtractorError,
  5. }
  6. class ShahidIE(InfoExtractor):
  7. _VALID_URL = r'https?://shahid\.mbc\.net/ar/episode/(?P<id>\d+)/?'
  8. _TESTS = [
  9. {
  10. 'url': 'https://shahid.mbc.net/ar/episode/108084/%D8%AE%D9%88%D8%A7%D8%B7%D8%B1-%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%85-11-%D8%A7%D9%84%D8%AD%D9%84%D9%82%D8%A9-1.html',
  11. 'info_dict': {
  12. 'id': '108084',
  13. 'ext': 'm3u8',
  14. 'title': 'بسم الله',
  15. 'description': 'بسم الله'
  16. },
  17. 'params': {
  18. # m3u8 download
  19. 'skip_download': True,
  20. }
  21. },
  22. {
  23. #shahid plus subscriber only
  24. 'url': 'https://shahid.mbc.net/ar/series/90497/%D9%85%D8%B1%D8%A7%D9%8A%D8%A7-2011.html',
  25. 'only_matching': True
  26. }
  27. ]
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. json_data = self._parse_json(
  32. get_element_by_id('jsonld', webpage),
  33. video_id
  34. )
  35. title = json_data['name']
  36. thumbnail = json_data['image']
  37. categories = json_data['genre']
  38. description = json_data['description']
  39. player_json_data = self._download_json(
  40. 'https://shahid.mbc.net/arContent/getPlayerContent-param-.id-'+video_id+'.type-player.html',
  41. video_id
  42. )['data']
  43. if 'url' in player_json_data:
  44. m3u8_url = player_json_data['url']
  45. else:
  46. for error in json_data['error'].values():
  47. raise ExtractorError(error)
  48. return
  49. formats = self._extract_m3u8_formats(m3u8_url, video_id)
  50. return {
  51. 'id': video_id,
  52. 'title': title,
  53. 'thumbnail': thumbnail,
  54. 'categories': categories,
  55. 'description': description,
  56. 'formats': formats,
  57. }