izlesene.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import urllib.parse
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. determine_ext,
  5. float_or_none,
  6. get_element_by_id,
  7. int_or_none,
  8. parse_iso8601,
  9. str_to_int,
  10. )
  11. class IzleseneIE(InfoExtractor):
  12. _VALID_URL = r'''(?x)
  13. https?://(?:(?:www|m)\.)?izlesene\.com/
  14. (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+)
  15. '''
  16. _TESTS = [
  17. {
  18. 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694',
  19. 'md5': '4384f9f0ea65086734b881085ee05ac2',
  20. 'info_dict': {
  21. 'id': '7599694',
  22. 'ext': 'mp4',
  23. 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi',
  24. 'description': 'md5:253753e2655dde93f59f74b572454f6d',
  25. 'thumbnail': r're:^https?://.*\.jpg',
  26. 'uploader_id': 'pelikzzle',
  27. 'timestamp': int,
  28. 'upload_date': '20140702',
  29. 'duration': 95.395,
  30. 'age_limit': 0,
  31. },
  32. },
  33. {
  34. 'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997',
  35. 'md5': '97f09b6872bffa284cb7fa4f6910cb72',
  36. 'info_dict': {
  37. 'id': '17997',
  38. 'ext': 'mp4',
  39. 'title': 'Tarkan Dortmund 2006 Konseri',
  40. 'thumbnail': r're:^https://.*\.jpg',
  41. 'uploader_id': 'parlayankiz',
  42. 'timestamp': int,
  43. 'upload_date': '20061112',
  44. 'duration': 253.666,
  45. 'age_limit': 0,
  46. },
  47. },
  48. ]
  49. def _real_extract(self, url):
  50. video_id = self._match_id(url)
  51. webpage = self._download_webpage(f'http://www.izlesene.com/video/{video_id}', video_id)
  52. video = self._parse_json(
  53. self._search_regex(
  54. r'videoObj\s*=\s*({.+?})\s*;\s*\n', webpage, 'streams'),
  55. video_id)
  56. title = video.get('videoTitle') or self._og_search_title(webpage)
  57. formats = []
  58. for stream in video['media']['level']:
  59. source_url = stream.get('source')
  60. if not source_url or not isinstance(source_url, str):
  61. continue
  62. ext = determine_ext(url, 'mp4')
  63. quality = stream.get('value')
  64. height = int_or_none(quality)
  65. formats.append({
  66. 'format_id': f'{quality}p' if quality else 'sd',
  67. 'url': urllib.parse.unquote(source_url),
  68. 'ext': ext,
  69. 'height': height,
  70. })
  71. description = self._og_search_description(webpage, default=None)
  72. thumbnail = video.get('posterURL') or self._proto_relative_url(
  73. self._og_search_thumbnail(webpage), scheme='http:')
  74. uploader = self._html_search_regex(
  75. r"adduserUsername\s*=\s*'([^']+)';",
  76. webpage, 'uploader', fatal=False)
  77. timestamp = parse_iso8601(self._html_search_meta(
  78. 'uploadDate', webpage, 'upload date'))
  79. duration = float_or_none(video.get('duration') or self._html_search_regex(
  80. r'videoduration["\']?\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
  81. webpage, 'duration', fatal=False, group='value'), scale=1000)
  82. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  83. comment_count = self._html_search_regex(
  84. r'comment_count\s*=\s*\'([^\']+)\';',
  85. webpage, 'comment_count', fatal=False)
  86. return {
  87. 'id': video_id,
  88. 'title': title,
  89. 'description': description,
  90. 'thumbnail': thumbnail,
  91. 'uploader_id': uploader,
  92. 'timestamp': timestamp,
  93. 'duration': duration,
  94. 'view_count': int_or_none(view_count),
  95. 'comment_count': int_or_none(comment_count),
  96. 'age_limit': self._family_friendly_search(webpage),
  97. 'formats': formats,
  98. }