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.

121 lines
4.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..compat import compat_urllib_parse_unquote
  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': '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': '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. url = 'http://www.izlesene.com/video/%s' % video_id
  55. webpage = self._download_webpage(url, video_id)
  56. title = self._og_search_title(webpage)
  57. description = self._og_search_description(webpage, default=None)
  58. thumbnail = self._proto_relative_url(
  59. self._og_search_thumbnail(webpage), scheme='http:')
  60. uploader = self._html_search_regex(
  61. r"adduserUsername\s*=\s*'([^']+)';",
  62. webpage, 'uploader', fatal=False)
  63. timestamp = parse_iso8601(self._html_search_meta(
  64. 'uploadDate', webpage, 'upload date'))
  65. duration = float_or_none(self._html_search_regex(
  66. r'"videoduration"\s*:\s*"([^"]+)"',
  67. webpage, 'duration', fatal=False), scale=1000)
  68. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  69. comment_count = self._html_search_regex(
  70. r'comment_count\s*=\s*\'([^\']+)\';',
  71. webpage, 'comment_count', fatal=False)
  72. content_url = self._html_search_meta(
  73. 'contentURL', webpage, 'content URL', fatal=False)
  74. ext = determine_ext(content_url, 'mp4')
  75. # Might be empty for some videos.
  76. streams = self._html_search_regex(
  77. r'"qualitylevel"\s*:\s*"([^"]+)"', webpage, 'streams', default='')
  78. formats = []
  79. if streams:
  80. for stream in streams.split('|'):
  81. quality, url = re.search(r'\[(\w+)\](.+)', stream).groups()
  82. formats.append({
  83. 'format_id': '%sp' % quality if quality else 'sd',
  84. 'url': compat_urllib_parse_unquote(url),
  85. 'ext': ext,
  86. })
  87. else:
  88. stream_url = self._search_regex(
  89. r'"streamurl"\s*:\s*"([^"]+)"', webpage, 'stream URL')
  90. formats.append({
  91. 'format_id': 'sd',
  92. 'url': compat_urllib_parse_unquote(stream_url),
  93. 'ext': ext,
  94. })
  95. return {
  96. 'id': video_id,
  97. 'title': title,
  98. 'description': description,
  99. 'thumbnail': thumbnail,
  100. 'uploader_id': uploader,
  101. 'timestamp': timestamp,
  102. 'duration': duration,
  103. 'view_count': int_or_none(view_count),
  104. 'comment_count': int_or_none(comment_count),
  105. 'age_limit': self._family_friendly_search(webpage),
  106. 'formats': formats,
  107. }