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.

125 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._og_search_thumbnail(webpage)
  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. family_friendly = self._html_search_meta(
  73. 'isFamilyFriendly', webpage, 'age limit', fatal=False)
  74. content_url = self._html_search_meta(
  75. 'contentURL', webpage, 'content URL', fatal=False)
  76. ext = determine_ext(content_url, 'mp4')
  77. # Might be empty for some videos.
  78. streams = self._html_search_regex(
  79. r'"qualitylevel"\s*:\s*"([^"]+)"',
  80. webpage, 'streams', fatal=False, default='')
  81. formats = []
  82. if streams:
  83. for stream in streams.split('|'):
  84. quality, url = re.search(r'\[(\w+)\](.+)', stream).groups()
  85. formats.append({
  86. 'format_id': '%sp' % quality if quality else 'sd',
  87. 'url': url,
  88. 'ext': ext,
  89. })
  90. else:
  91. stream_url = self._search_regex(
  92. r'"streamurl"\s?:\s?"([^"]+)"', webpage, 'stream URL')
  93. formats.append({
  94. 'format_id': 'sd',
  95. 'url': stream_url,
  96. 'ext': ext,
  97. })
  98. return {
  99. 'id': video_id,
  100. 'title': title,
  101. 'description': description,
  102. 'thumbnail': thumbnail,
  103. 'uploader_id': uploader,
  104. 'timestamp': timestamp,
  105. 'duration': duration,
  106. 'view_count': int_or_none(view_count),
  107. 'comment_count': int_or_none(comment_count),
  108. 'age_limit': 18 if family_friendly == 'False' else 0,
  109. 'formats': formats,
  110. }