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.

97 lines
3.6 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. str_to_int,
  11. )
  12. class IzleseneIE(InfoExtractor):
  13. _VALID_URL = r'https?://(?:(?:www|m)\.)?izlesene\.com/(?:video|embedplayer)/(?:[^/]+/)?(?P<id>[0-9]+)'
  14. _STREAM_URL = 'http://panel.izlesene.com/api/streamurl/{id:}/{format:}'
  15. _TEST = {
  16. 'url': 'http://www.izlesene.com/video/sevincten-cildirtan-dogum-gunu-hediyesi/7599694',
  17. 'md5': '4384f9f0ea65086734b881085ee05ac2',
  18. 'info_dict': {
  19. 'id': '7599694',
  20. 'ext': 'mp4',
  21. 'title': 'Sevinçten Çıldırtan Doğum Günü Hediyesi',
  22. 'description': 'Annesi oğluna doğum günü hediyesi olarak minecraft cd si alıyor, ve çocuk hunharca seviniyor',
  23. 'thumbnail': 're:^http://.*\.jpg',
  24. 'uploader_id': 'pelikzzle',
  25. 'timestamp': 1404298698,
  26. 'upload_date': '20140702',
  27. 'duration': 95.395,
  28. 'age_limit': 0,
  29. }
  30. }
  31. def _real_extract(self, url):
  32. mobj = re.match(self._VALID_URL, url)
  33. video_id = mobj.group('id')
  34. url = 'http://www.izlesene.com/video/%s' % video_id
  35. webpage = self._download_webpage(url, video_id)
  36. title = self._og_search_title(webpage)
  37. description = self._og_search_description(webpage)
  38. thumbnail = self._og_search_thumbnail(webpage)
  39. uploader = self._html_search_regex(
  40. r"adduserUsername\s*=\s*'([^']+)';", webpage, 'uploader', fatal=False, default='')
  41. timestamp = parse_iso8601(self._html_search_meta(
  42. 'uploadDate', webpage, 'upload date', fatal=False))
  43. duration = int_or_none(self._html_search_regex(
  44. r'"videoduration"\s*:\s*"([^"]+)"', webpage, 'duration', fatal=False))
  45. if duration:
  46. duration /= 1000.0
  47. view_count = str_to_int(get_element_by_id('videoViewCount', webpage))
  48. comment_count = self._html_search_regex(
  49. r'comment_count\s*=\s*\'([^\']+)\';', webpage, 'uploader', fatal=False)
  50. family_friendly = self._html_search_meta(
  51. 'isFamilyFriendly', webpage, 'age limit', fatal=False)
  52. content_url = self._html_search_meta(
  53. 'contentURL', webpage, 'content URL', fatal=False)
  54. ext = determine_ext(content_url, 'mp4')
  55. # Might be empty for some videos.
  56. qualities = self._html_search_regex(
  57. r'"quality"\s*:\s*"([^"]+)"', webpage, 'qualities', fatal=False, default='')
  58. formats = []
  59. for quality in qualities.split('|'):
  60. json = self._download_json(
  61. self._STREAM_URL.format(id=video_id, format=quality), video_id,
  62. note='Getting video URL for "%s" quality' % quality,
  63. errnote='Failed to get video URL for "%s" quality' % quality
  64. )
  65. formats.append({
  66. 'url': json.get('streamurl'),
  67. 'ext': ext,
  68. 'format_id': '%sp' % quality if quality else 'sd',
  69. })
  70. return {
  71. 'id': video_id,
  72. 'title': title,
  73. 'description': description,
  74. 'thumbnail': thumbnail,
  75. 'uploader_id': uploader,
  76. 'timestamp': timestamp,
  77. 'duration': duration,
  78. 'view_count': int_or_none(view_count),
  79. 'comment_count': int_or_none(comment_count),
  80. 'age_limit': 18 if family_friendly == 'False' else 0,
  81. 'formats': formats,
  82. }