logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

izlesene.py (4152B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_str,
  6. compat_urllib_parse_unquote,
  7. )
  8. from ..utils import (
  9. determine_ext,
  10. float_or_none,
  11. get_element_by_id,
  12. int_or_none,
  13. parse_iso8601,
  14. str_to_int,
  15. )
  16. class IzleseneIE(InfoExtractor):
  17. _VALID_URL = r'''(?x)
  18. https?://(?:(?:www|m)\.)?izlesene\.com/
  19. (?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+)
  20. '''
  21. _TESTS = [
  22. {
  23. 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694',
  24. 'md5': '4384f9f0ea65086734b881085ee05ac2',
  25. 'info_dict': {
  26. 'id': '7599694',
  27. 'ext': 'mp4',
  28. 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi',
  29. 'description': 'md5:253753e2655dde93f59f74b572454f6d',
  30. 'thumbnail': r're:^https?://.*\.jpg',
  31. 'uploader_id': 'pelikzzle',
  32. 'timestamp': int,
  33. 'upload_date': '20140702',
  34. 'duration': 95.395,
  35. 'age_limit': 0,
  36. }
  37. },
  38. {
  39. 'url': 'http://www.izlesene.com/video/tarkan-dortmund-2006-konseri/17997',
  40. 'md5': '97f09b6872bffa284cb7fa4f6910cb72',
  41. 'info_dict': {
  42. 'id': '17997',
  43. 'ext': 'mp4',
  44. 'title': 'Tarkan Dortmund 2006 Konseri',
  45. 'thumbnail': r're:^https://.*\.jpg',
  46. 'uploader_id': 'parlayankiz',
  47. 'timestamp': int,
  48. 'upload_date': '20061112',
  49. 'duration': 253.666,
  50. 'age_limit': 0,
  51. }
  52. },
  53. ]
  54. def _real_extract(self, url):
  55. video_id = self._match_id(url)
  56. webpage = self._download_webpage('http://www.izlesene.com/video/%s' % video_id, video_id)
  57. video = self._parse_json(
  58. self._search_regex(
  59. r'videoObj\s*=\s*({.+?})\s*;\s*\n', webpage, 'streams'),
  60. video_id)
  61. title = video.get('videoTitle') or self._og_search_title(webpage)
  62. formats = []
  63. for stream in video['media']['level']:
  64. source_url = stream.get('source')
  65. if not source_url or not isinstance(source_url, compat_str):
  66. continue
  67. ext = determine_ext(url, 'mp4')
  68. quality = stream.get('value')
  69. height = int_or_none(quality)
  70. formats.append({
  71. 'format_id': '%sp' % quality if quality else 'sd',
  72. 'url': compat_urllib_parse_unquote(source_url),
  73. 'ext': ext,
  74. 'height': height,
  75. })
  76. self._sort_formats(formats)
  77. description = self._og_search_description(webpage, default=None)
  78. thumbnail = video.get('posterURL') or self._proto_relative_url(
  79. self._og_search_thumbnail(webpage), scheme='http:')
  80. uploader = self._html_search_regex(
  81. r"adduserUsername\s*=\s*'([^']+)';",
  82. webpage, 'uploader', fatal=False)
  83. timestamp = parse_iso8601(self._html_search_meta(
  84. 'uploadDate', webpage, 'upload date'))
  85. duration = float_or_none(video.get('duration') or self._html_search_regex(
  86. r'videoduration["\']?\s*=\s*(["\'])(?P<value>(?:(?!\1).)+)\1',
  87. webpage, 'duration', fatal=False, group='value'), scale=1000)
  88. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  89. comment_count = self._html_search_regex(
  90. r'comment_count\s*=\s*\'([^\']+)\';',
  91. webpage, 'comment_count', fatal=False)
  92. return {
  93. 'id': video_id,
  94. 'title': title,
  95. 'description': description,
  96. 'thumbnail': thumbnail,
  97. 'uploader_id': uploader,
  98. 'timestamp': timestamp,
  99. 'duration': duration,
  100. 'view_count': int_or_none(view_count),
  101. 'comment_count': int_or_none(comment_count),
  102. 'age_limit': self._family_friendly_search(webpage),
  103. 'formats': formats,
  104. }