izlesene.py 4.0 KB

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