izlesene.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urllib_parse_unquote
  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': r're:^https?://.*\.jpg',
  28. 'uploader_id': 'pelikzzle',
  29. 'timestamp': int,
  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. 'thumbnail': r're:^https://.*\.jpg',
  43. 'uploader_id': 'parlayankiz',
  44. 'timestamp': int,
  45. 'upload_date': '20061112',
  46. 'duration': 253.666,
  47. 'age_limit': 0,
  48. }
  49. },
  50. ]
  51. def _real_extract(self, url):
  52. video_id = self._match_id(url)
  53. url = 'http://www.izlesene.com/video/%s' % video_id
  54. webpage = self._download_webpage(url, video_id)
  55. title = self._og_search_title(webpage)
  56. description = self._og_search_description(webpage, default=None)
  57. thumbnail = self._proto_relative_url(
  58. self._og_search_thumbnail(webpage), scheme='http:')
  59. uploader = self._html_search_regex(
  60. r"adduserUsername\s*=\s*'([^']+)';",
  61. webpage, 'uploader', fatal=False)
  62. timestamp = parse_iso8601(self._html_search_meta(
  63. 'uploadDate', webpage, 'upload date'))
  64. duration = float_or_none(self._html_search_regex(
  65. r'videoduration\s*=\s*\'([^\']+)\'',
  66. webpage, 'duration', fatal=False), scale=1000)
  67. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  68. comment_count = self._html_search_regex(
  69. r'comment_count\s*=\s*\'([^\']+)\';',
  70. webpage, 'comment_count', fatal=False)
  71. streams_json = self._html_search_regex(
  72. r'_videoObj\s*=\s*(.+);', webpage, 'streams')
  73. streams = self._parse_json(streams_json, video_id)
  74. formats = []
  75. for stream in streams.get('media').get('level'):
  76. url = stream.get('source')
  77. ext = determine_ext(url, 'mp4')
  78. quality = stream.get('value')
  79. formats.append({
  80. 'format_id': '%sp' % quality,
  81. 'url': compat_urllib_parse_unquote(url),
  82. 'ext': ext,
  83. })
  84. return {
  85. 'id': video_id,
  86. 'title': title,
  87. 'description': description,
  88. 'thumbnail': thumbnail,
  89. 'uploader_id': uploader,
  90. 'timestamp': timestamp,
  91. 'duration': duration,
  92. 'view_count': int_or_none(view_count),
  93. 'comment_count': int_or_none(comment_count),
  94. 'age_limit': self._family_friendly_search(webpage),
  95. 'formats': formats,
  96. }