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.

143 lines
4.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_age_limit,
  7. parse_iso8601,
  8. )
  9. class IndavideoEmbedIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:(?:embed\.)?indavideo\.hu/player/video/|assets\.indavideo\.hu/swf/player\.swf\?.*\b(?:v(?:ID|id))=)(?P<id>[\da-f]+)'
  11. _TESTS = [{
  12. 'url': 'http://indavideo.hu/player/video/1bdc3c6d80/',
  13. 'md5': 'f79b009c66194acacd40712a6778acfa',
  14. 'info_dict': {
  15. 'id': '1837039',
  16. 'ext': 'mp4',
  17. 'title': 'Cicatánc',
  18. 'description': '',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. 'uploader': 'cukiajanlo',
  21. 'uploader_id': '83729',
  22. 'timestamp': 1439193826,
  23. 'upload_date': '20150810',
  24. 'duration': 72,
  25. 'age_limit': 0,
  26. 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'],
  27. },
  28. }, {
  29. 'url': 'http://embed.indavideo.hu/player/video/1bdc3c6d80?autostart=1&hide=1',
  30. 'only_matching': True,
  31. }, {
  32. 'url': 'http://assets.indavideo.hu/swf/player.swf?v=fe25e500&vID=1bdc3c6d80&autostart=1&hide=1&i=1',
  33. 'only_matching': True,
  34. }]
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. video = self._download_json(
  38. 'http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/%s' % video_id,
  39. video_id)['data']
  40. title = video['title']
  41. video_urls = video.get('video_files', [])
  42. video_file = video.get('video_file')
  43. if video:
  44. video_urls.append(video_file)
  45. video_urls = list(set(video_urls))
  46. video_prefix = video_urls[0].rsplit('/', 1)[0]
  47. for flv_file in video.get('flv_files', []):
  48. flv_url = '%s/%s' % (video_prefix, flv_file)
  49. if flv_url not in video_urls:
  50. video_urls.append(flv_url)
  51. formats = [{
  52. 'url': video_url,
  53. 'height': int_or_none(self._search_regex(
  54. r'\.(\d{3,4})\.mp4(?:\?|$)', video_url, 'height', default=None)),
  55. } for video_url in video_urls]
  56. self._sort_formats(formats)
  57. timestamp = video.get('date')
  58. if timestamp:
  59. # upload date is in CEST
  60. timestamp = parse_iso8601(timestamp + ' +0200', ' ')
  61. thumbnails = [{
  62. 'url': self._proto_relative_url(thumbnail)
  63. } for thumbnail in video.get('thumbnails', [])]
  64. tags = [tag['title'] for tag in video.get('tags') or []]
  65. return {
  66. 'id': video.get('id') or video_id,
  67. 'title': title,
  68. 'description': video.get('description'),
  69. 'thumbnails': thumbnails,
  70. 'uploader': video.get('user_name'),
  71. 'uploader_id': video.get('user_id'),
  72. 'timestamp': timestamp,
  73. 'duration': int_or_none(video.get('length')),
  74. 'age_limit': parse_age_limit(video.get('age_limit')),
  75. 'tags': tags,
  76. 'formats': formats,
  77. }
  78. class IndavideoIE(InfoExtractor):
  79. _VALID_URL = r'https?://(?:.+?\.)?indavideo\.hu/video/(?P<id>[^/#?]+)'
  80. _TESTS = [{
  81. 'url': 'http://indavideo.hu/video/Vicces_cica_1',
  82. 'md5': '8c82244ba85d2a2310275b318eb51eac',
  83. 'info_dict': {
  84. 'id': '1335611',
  85. 'display_id': 'Vicces_cica_1',
  86. 'ext': 'mp4',
  87. 'title': 'Vicces cica',
  88. 'description': 'Játszik a tablettel. :D',
  89. 'thumbnail': 're:^https?://.*\.jpg$',
  90. 'uploader': 'Jet_Pack',
  91. 'uploader_id': '491217',
  92. 'timestamp': 1390821212,
  93. 'upload_date': '20140127',
  94. 'duration': 7,
  95. 'age_limit': 0,
  96. 'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'],
  97. },
  98. }, {
  99. 'url': 'http://index.indavideo.hu/video/2015_0728_beregszasz',
  100. 'only_matching': True,
  101. }, {
  102. 'url': 'http://auto.indavideo.hu/video/Sajat_utanfutoban_a_kis_tacsko',
  103. 'only_matching': True,
  104. }, {
  105. 'url': 'http://erotika.indavideo.hu/video/Amator_tini_punci',
  106. 'only_matching': True,
  107. }, {
  108. 'url': 'http://film.indavideo.hu/video/f_hrom_nagymamm_volt',
  109. 'only_matching': True,
  110. }, {
  111. 'url': 'http://palyazat.indavideo.hu/video/Embertelen_dal_Dodgem_egyuttes',
  112. 'only_matching': True,
  113. }]
  114. def _real_extract(self, url):
  115. display_id = self._match_id(url)
  116. webpage = self._download_webpage(url, display_id)
  117. embed_url = self._search_regex(
  118. r'<link[^>]+rel="video_src"[^>]+href="(.+?)"', webpage, 'embed url')
  119. return {
  120. '_type': 'url_transparent',
  121. 'ie_key': 'IndavideoEmbed',
  122. 'url': embed_url,
  123. 'display_id': display_id,
  124. }