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.

122 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:^http://.*\.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. 'description': 'Tarkan Dortmund 2006 Konseri',
  44. 'thumbnail': 're:^http://.*\.jpg',
  45. 'uploader_id': 'parlayankiz',
  46. 'timestamp': int,
  47. 'upload_date': '20061112',
  48. 'duration': 253.666,
  49. 'age_limit': 0,
  50. }
  51. },
  52. ]
  53. def _real_extract(self, url):
  54. video_id = self._match_id(url)
  55. url = 'http://www.izlesene.com/video/%s' % video_id
  56. webpage = self._download_webpage(url, video_id)
  57. title = self._og_search_title(webpage)
  58. description = self._og_search_description(webpage)
  59. thumbnail = self._proto_relative_url(
  60. self._og_search_thumbnail(webpage), scheme='http:')
  61. uploader = self._html_search_regex(
  62. r"adduserUsername\s*=\s*'([^']+)';",
  63. webpage, 'uploader', fatal=False)
  64. timestamp = parse_iso8601(self._html_search_meta(
  65. 'uploadDate', webpage, 'upload date'))
  66. duration = float_or_none(self._html_search_regex(
  67. r'"videoduration"\s*:\s*"([^"]+)"',
  68. webpage, 'duration', fatal=False), scale=1000)
  69. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  70. comment_count = self._html_search_regex(
  71. r'comment_count\s*=\s*\'([^\']+)\';',
  72. webpage, 'comment_count', fatal=False)
  73. content_url = self._html_search_meta(
  74. 'contentURL', webpage, 'content URL', fatal=False)
  75. ext = determine_ext(content_url, 'mp4')
  76. # Might be empty for some videos.
  77. streams = self._html_search_regex(
  78. r'"qualitylevel"\s*:\s*"([^"]+)"', webpage, 'streams', default='')
  79. formats = []
  80. if streams:
  81. for stream in streams.split('|'):
  82. quality, url = re.search(r'\[(\w+)\](.+)', stream).groups()
  83. formats.append({
  84. 'format_id': '%sp' % quality if quality else 'sd',
  85. 'url': compat_urllib_parse_unquote(url),
  86. 'ext': ext,
  87. })
  88. else:
  89. stream_url = self._search_regex(
  90. r'"streamurl"\s*:\s*"([^"]+)"', webpage, 'stream URL')
  91. formats.append({
  92. 'format_id': 'sd',
  93. 'url': compat_urllib_parse_unquote(stream_url),
  94. 'ext': ext,
  95. })
  96. return {
  97. 'id': video_id,
  98. 'title': title,
  99. 'description': description,
  100. 'thumbnail': thumbnail,
  101. 'uploader_id': uploader,
  102. 'timestamp': timestamp,
  103. 'duration': duration,
  104. 'view_count': int_or_none(view_count),
  105. 'comment_count': int_or_none(comment_count),
  106. 'age_limit': self._family_friendly_search(webpage),
  107. 'formats': formats,
  108. }