2016-05-06 09:02:40 -05:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2019-03-12 02:08:54 -05:00
|
|
|
from .vk import VKIE
|
|
|
|
from ..utils import (
|
|
|
|
HEADRequest,
|
|
|
|
int_or_none,
|
|
|
|
)
|
2016-05-06 09:02:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
class BIQLEIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watch/(?P<id>-?\d+_\d+)'
|
|
|
|
_TESTS = [{
|
2019-03-12 02:08:54 -05:00
|
|
|
# Youtube embed
|
|
|
|
'url': 'https://biqle.ru/watch/-115995369_456239081',
|
|
|
|
'md5': '97af5a06ee4c29bbf9c001bdb1cf5c06',
|
2016-05-06 09:02:40 -05:00
|
|
|
'info_dict': {
|
2019-03-12 02:08:54 -05:00
|
|
|
'id': '8v4f-avW-VI',
|
2016-05-06 09:02:40 -05:00
|
|
|
'ext': 'mp4',
|
2019-03-12 02:08:54 -05:00
|
|
|
'title': "PASSE-PARTOUT - L'ete c'est fait pour jouer",
|
|
|
|
'description': 'Passe-Partout',
|
|
|
|
'uploader_id': 'mrsimpsonstef3',
|
|
|
|
'uploader': 'Phanolito',
|
|
|
|
'upload_date': '20120822',
|
|
|
|
},
|
2016-05-06 09:02:40 -05:00
|
|
|
}, {
|
2019-03-12 02:08:54 -05:00
|
|
|
'url': 'http://biqle.org/watch/-44781847_168547604',
|
2016-05-06 09:02:40 -05:00
|
|
|
'md5': '7f24e72af1db0edf7c1aaba513174f97',
|
|
|
|
'info_dict': {
|
2019-04-03 05:08:42 -05:00
|
|
|
'id': '-44781847_168547604',
|
2016-05-06 09:02:40 -05:00
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Ребенок в шоке от автоматической мойки',
|
2019-03-12 02:08:54 -05:00
|
|
|
'timestamp': 1396633454,
|
2016-05-06 09:02:40 -05:00
|
|
|
'uploader': 'Dmitry Kotov',
|
2019-03-12 02:08:54 -05:00
|
|
|
'upload_date': '20140404',
|
|
|
|
'uploader_id': '47850140',
|
2016-08-07 23:59:55 -05:00
|
|
|
},
|
2016-05-06 09:02:40 -05:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
embed_url = self._proto_relative_url(self._search_regex(
|
2019-03-12 02:08:54 -05:00
|
|
|
r'<iframe.+?src="((?:https?:)?//daxab\.com/[^"]+)".*?></iframe>',
|
|
|
|
webpage, 'embed url'))
|
|
|
|
if VKIE.suitable(embed_url):
|
|
|
|
return self.url_result(embed_url, VKIE.ie_key(), video_id)
|
|
|
|
|
|
|
|
self._request_webpage(
|
|
|
|
HEADRequest(embed_url), video_id, headers={'Referer': url})
|
|
|
|
video_id, sig, _, access_token = self._get_cookies(embed_url)['video_ext'].value.split('%3A')
|
|
|
|
item = self._download_json(
|
|
|
|
'https://api.vk.com/method/video.get', video_id,
|
|
|
|
headers={'User-Agent': 'okhttp/3.4.1'}, query={
|
|
|
|
'access_token': access_token,
|
|
|
|
'sig': sig,
|
|
|
|
'v': 5.44,
|
|
|
|
'videos': video_id,
|
|
|
|
})['response']['items'][0]
|
|
|
|
title = item['title']
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
for f_id, f_url in item.get('files', {}).items():
|
|
|
|
if f_id == 'external':
|
|
|
|
return self.url_result(f_url)
|
|
|
|
ext, height = f_id.split('_')
|
|
|
|
formats.append({
|
|
|
|
'format_id': height + 'p',
|
|
|
|
'url': f_url,
|
|
|
|
'height': int_or_none(height),
|
|
|
|
'ext': ext,
|
|
|
|
})
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
thumbnails = []
|
|
|
|
for k, v in item.items():
|
|
|
|
if k.startswith('photo_') and v:
|
|
|
|
width = k.replace('photo_', '')
|
|
|
|
thumbnails.append({
|
|
|
|
'id': width,
|
|
|
|
'url': v,
|
|
|
|
'width': int_or_none(width),
|
|
|
|
})
|
2016-05-06 09:02:40 -05:00
|
|
|
|
|
|
|
return {
|
2019-03-12 02:08:54 -05:00
|
|
|
'id': video_id,
|
|
|
|
'title': title,
|
|
|
|
'formats': formats,
|
|
|
|
'comment_count': int_or_none(item.get('comments')),
|
|
|
|
'description': item.get('description'),
|
|
|
|
'duration': int_or_none(item.get('duration')),
|
|
|
|
'thumbnails': thumbnails,
|
|
|
|
'timestamp': int_or_none(item.get('date')),
|
|
|
|
'uploader': item.get('owner_id'),
|
|
|
|
'view_count': int_or_none(item.get('views')),
|
2016-05-06 09:02:40 -05:00
|
|
|
}
|