weyyak.py 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. float_or_none,
  4. int_or_none,
  5. parse_age_limit,
  6. traverse_obj,
  7. unified_timestamp,
  8. url_or_none,
  9. )
  10. class WeyyakIE(InfoExtractor):
  11. _VALID_URL = r'https?://weyyak\.com/(?P<lang>\w+)/(?:player/)?(?P<type>episode|movie)/(?P<id>\d+)'
  12. _TESTS = [
  13. {
  14. 'url': 'https://weyyak.com/en/player/episode/1341952/Ribat-Al-Hob-Episode49',
  15. 'md5': '0caf55c1a615531c8fe60f146ae46849',
  16. 'info_dict': {
  17. 'id': '1341952',
  18. 'ext': 'mp4',
  19. 'title': 'Ribat Al Hob',
  20. 'duration': 2771,
  21. 'alt_title': 'رباط الحب',
  22. 'season': 'Season 1',
  23. 'season_number': 1,
  24. 'episode': 'Episode 49',
  25. 'episode_number': 49,
  26. 'timestamp': 1485907200,
  27. 'upload_date': '20170201',
  28. 'thumbnail': r're:^https://content\.weyyak\.com/.+/poster-image',
  29. 'categories': ['Drama', 'Thrillers', 'Romance'],
  30. 'tags': 'count:8',
  31. },
  32. },
  33. {
  34. 'url': 'https://weyyak.com/en/movie/233255/8-Seconds',
  35. 'md5': 'fe740ae0f63e4d1c8a7fc147a410c564',
  36. 'info_dict': {
  37. 'id': '233255',
  38. 'ext': 'mp4',
  39. 'title': '8 Seconds',
  40. 'duration': 6490,
  41. 'alt_title': '8 ثواني',
  42. 'description': 'md5:45b83a155c30b49950624c7e99600b9d',
  43. 'age_limit': 15,
  44. 'release_year': 2015,
  45. 'timestamp': 1683106031,
  46. 'upload_date': '20230503',
  47. 'thumbnail': r're:^https://content\.weyyak\.com/.+/poster-image',
  48. 'categories': ['Drama', 'Social'],
  49. 'cast': ['Ceylin Adiyaman', 'Esra Inal'],
  50. },
  51. },
  52. ]
  53. def _real_extract(self, url):
  54. video_id, lang, type_ = self._match_valid_url(url).group('id', 'lang', 'type')
  55. path = 'episode/' if type_ == 'episode' else 'contents/moviedetails?contentkey='
  56. data = self._download_json(
  57. f'https://msapifo-prod-me.weyyak.z5.com/v1/{lang}/{path}{video_id}', video_id)['data']
  58. m3u8_url = self._download_json(
  59. f'https://api-weyyak.akamaized.net/get_info/{data["video_id"]}',
  60. video_id, 'Extracting video details')['url_video']
  61. formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id)
  62. return {
  63. 'id': video_id,
  64. 'formats': formats,
  65. 'subtitles': subtitles,
  66. **traverse_obj(data, {
  67. 'title': ('title', {str}),
  68. 'alt_title': ('translated_title', {str}),
  69. 'description': ('synopsis', {str}),
  70. 'duration': ('length', {float_or_none}),
  71. 'age_limit': ('age_rating', {parse_age_limit}),
  72. 'season_number': ('season_number', {int_or_none}),
  73. 'episode_number': ('episode_number', {int_or_none}),
  74. 'thumbnail': ('imagery', 'thumbnail', {url_or_none}),
  75. 'categories': ('genres', ..., {str}),
  76. 'tags': ('tags', ..., {str}),
  77. 'cast': (('main_actor', 'main_actress'), {str}),
  78. 'timestamp': ('insertedAt', {unified_timestamp}),
  79. 'release_year': ('production_year', {int_or_none}),
  80. }),
  81. }