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 ..utils import (
  6. determine_ext,
  7. float_or_none,
  8. get_element_by_id,
  9. int_or_none,
  10. parse_iso8601,
  11. str_to_int,
  12. )
  13. class IzleseneIE(InfoExtractor):
  14. _VALID_URL = r'''(?x)
  15. https?://(?:(?:www|m)\.)?izlesene\.com/
  16. (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+)
  17. '''
  18. _TESTS = [
  19. {
  20. 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694',
  21. 'md5': '4384f9f0ea65086734b881085ee05ac2',
  22. 'info_dict': {
  23. 'id': '7599694',
  24. 'ext': 'mp4',
  25. 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi',
  26. 'description': 'md5:253753e2655dde93f59f74b572454f6d',
  27. 'thumbnail': 're:^http://.*\.jpg',
  28. 'uploader_id': 'pelikzzle',
  29. 'timestamp': 1404302298,
  30. 'upload_date': '20140702',
  31. 'duration': 95.395,
  32. 'age_limit': 0,
  33. }
  34. },
  35. {
  36. 'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997',
  37. 'md5': '97f09b6872bffa284cb7fa4f6910cb72',
  38. 'info_dict': {
  39. 'id': '17997',
  40. 'ext': 'mp4',
  41. 'title': 'Tarkan Dortmund 2006 Konseri',
  42. 'description': 'Tarkan Dortmund 2006 Konseri',
  43. 'thumbnail': 're:^http://.*\.jpg',
  44. 'uploader_id': 'parlayankiz',
  45. 'timestamp': 1163322193,
  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)
  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, default='')
  63. timestamp = parse_iso8601(self._html_search_meta(
  64. 'uploadDate', webpage, 'upload date', fatal=False))
  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*"([^"]+)"',
  78. webpage, 'streams', fatal=False, 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': 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': 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. }