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.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .vk import VKIE
  5. from ..utils import (
  6. HEADRequest,
  7. int_or_none,
  8. )
  9. class BIQLEIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watch/(?P<id>-?\d+_\d+)'
  11. _TESTS = [{
  12. # Youtube embed
  13. 'url': 'https://biqle.ru/watch/-115995369_456239081',
  14. 'md5': '97af5a06ee4c29bbf9c001bdb1cf5c06',
  15. 'info_dict': {
  16. 'id': '8v4f-avW-VI',
  17. 'ext': 'mp4',
  18. 'title': "PASSE-PARTOUT - L'ete c'est fait pour jouer",
  19. 'description': 'Passe-Partout',
  20. 'uploader_id': 'mrsimpsonstef3',
  21. 'uploader': 'Phanolito',
  22. 'upload_date': '20120822',
  23. },
  24. }, {
  25. 'url': 'http://biqle.org/watch/-44781847_168547604',
  26. 'md5': '7f24e72af1db0edf7c1aaba513174f97',
  27. 'info_dict': {
  28. 'id': '168547604',
  29. 'ext': 'mp4',
  30. 'title': 'Ребенок в шоке от автоматической мойки',
  31. 'timestamp': 1396633454,
  32. 'uploader': 'Dmitry Kotov',
  33. 'upload_date': '20140404',
  34. 'uploader_id': '47850140',
  35. },
  36. }]
  37. def _real_extract(self, url):
  38. video_id = self._match_id(url)
  39. webpage = self._download_webpage(url, video_id)
  40. embed_url = self._proto_relative_url(self._search_regex(
  41. r'<iframe.+?src="((?:https?:)?//daxab\.com/[^"]+)".*?></iframe>',
  42. webpage, 'embed url'))
  43. if VKIE.suitable(embed_url):
  44. return self.url_result(embed_url, VKIE.ie_key(), video_id)
  45. self._request_webpage(
  46. HEADRequest(embed_url), video_id, headers={'Referer': url})
  47. video_id, sig, _, access_token = self._get_cookies(embed_url)['video_ext'].value.split('%3A')
  48. item = self._download_json(
  49. 'https://api.vk.com/method/video.get', video_id,
  50. headers={'User-Agent': 'okhttp/3.4.1'}, query={
  51. 'access_token': access_token,
  52. 'sig': sig,
  53. 'v': 5.44,
  54. 'videos': video_id,
  55. })['response']['items'][0]
  56. title = item['title']
  57. formats = []
  58. for f_id, f_url in item.get('files', {}).items():
  59. if f_id == 'external':
  60. return self.url_result(f_url)
  61. ext, height = f_id.split('_')
  62. formats.append({
  63. 'format_id': height + 'p',
  64. 'url': f_url,
  65. 'height': int_or_none(height),
  66. 'ext': ext,
  67. })
  68. self._sort_formats(formats)
  69. thumbnails = []
  70. for k, v in item.items():
  71. if k.startswith('photo_') and v:
  72. width = k.replace('photo_', '')
  73. thumbnails.append({
  74. 'id': width,
  75. 'url': v,
  76. 'width': int_or_none(width),
  77. })
  78. return {
  79. 'id': video_id,
  80. 'title': title,
  81. 'formats': formats,
  82. 'comment_count': int_or_none(item.get('comments')),
  83. 'description': item.get('description'),
  84. 'duration': int_or_none(item.get('duration')),
  85. 'thumbnails': thumbnails,
  86. 'timestamp': int_or_none(item.get('date')),
  87. 'uploader': item.get('owner_id'),
  88. 'view_count': int_or_none(item.get('views')),
  89. }