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.

126 lines
4.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. get_element_by_id,
  7. parse_iso8601,
  8. determine_ext,
  9. int_or_none,
  10. float_or_none,
  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': 1404298698,
  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': 1163318593,
  46. 'upload_date': '20061112',
  47. 'duration': 253.666,
  48. 'age_limit': 0,
  49. }
  50. },
  51. ]
  52. def _real_extract(self, url):
  53. mobj = re.match(self._VALID_URL, url)
  54. video_id = mobj.group('id')
  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, default='')
  64. timestamp = parse_iso8601(self._html_search_meta(
  65. 'uploadDate', webpage, 'upload date', fatal=False))
  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. family_friendly = self._html_search_meta(
  74. 'isFamilyFriendly', webpage, 'age limit', fatal=False)
  75. content_url = self._html_search_meta(
  76. 'contentURL', webpage, 'content URL', fatal=False)
  77. ext = determine_ext(content_url, 'mp4')
  78. # Might be empty for some videos.
  79. streams = self._html_search_regex(
  80. r'"qualitylevel"\s*:\s*"([^"]+)"',
  81. webpage, 'streams', fatal=False, default='')
  82. formats = []
  83. if streams:
  84. for stream in streams.split('|'):
  85. quality, url = re.search(r'\[(\w+)\](.+)', stream).groups()
  86. formats.append({
  87. 'format_id': '%sp' % quality if quality else 'sd',
  88. 'url': url,
  89. 'ext': ext,
  90. })
  91. else:
  92. stream_url = self._search_regex(
  93. r'"streamurl"\s?:\s?"([^"]+)"', webpage, 'stream URL')
  94. formats.append({
  95. 'format_id': 'sd',
  96. 'url': stream_url,
  97. 'ext': ext,
  98. })
  99. return {
  100. 'id': video_id,
  101. 'title': title,
  102. 'description': description,
  103. 'thumbnail': thumbnail,
  104. 'uploader_id': uploader,
  105. 'timestamp': timestamp,
  106. 'duration': duration,
  107. 'view_count': int_or_none(view_count),
  108. 'comment_count': int_or_none(comment_count),
  109. 'age_limit': 18 if family_friendly == 'False' else 0,
  110. 'formats': formats,
  111. }