[openload] switch to pairing method

This commit is contained in:
Tithen-Firion 2017-04-10 06:03:54 +02:00
parent 639e5b2a84
commit 84d5d1e96e

View File

@ -58,6 +58,12 @@ class OpenloadIE(InfoExtractor):
'only_matching': True,
}]
_API_URL = 'https://api.openload.co/1'
_PAIR_INFO_URL = _API_URL + '/streaming/info'
_GET_VIDEO_URL = _API_URL + '/streaming/get?file={0}'
_PAIR_NEEDED = 'Open this url: {0}, solve captcha, click "Pair" button and try again'
@staticmethod
def _extract_urls(webpage):
return re.findall(
@ -66,60 +72,39 @@ class OpenloadIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage('https://openload.co/embed/%s/' % video_id, video_id)
webpage = self._download_webpage('https://openload.co/embed/{0}/'.format(video_id), video_id)
if 'File not found' in webpage or 'deleted by the owner' in webpage:
raise ExtractorError('File not found', expected=True)
raise ExtractorError('File not found', expected=True, video_id=video_id)
ol_id = self._search_regex(
'<span[^>]+id="[^"]+"[^>]*>([0-9A-Za-z]+)</span>',
webpage, 'openload ID')
decoded = ''
a = ol_id[0:24]
b = []
for i in range(0, len(a), 8):
b.append(int(a[i:i + 8] or '0', 16))
ol_id = ol_id[24:]
j = 0
k = 0
while j < len(ol_id):
c = 128
d = 0
e = 0
f = 0
_more = True
while _more:
if j + 1 >= len(ol_id):
c = 143
f = int(ol_id[j:j + 2] or '0', 16)
j += 2
d += (f & 127) << e
e += 7
_more = f >= c
g = d ^ b[k % 3]
for i in range(4):
char_dec = (g >> 8 * i) & (c + 127)
char = compat_chr(char_dec)
if char != '#':
decoded += char
k += 1
video_url = 'https://openload.co/stream/%s?mime=true'
video_url = video_url % decoded
title = self._og_search_title(webpage, default=None) or self._search_regex(
r'<span[^>]+class=["\']title["\'][^>]*>([^<]+)', webpage,
'title', default=None) or self._html_search_meta(
'description', webpage, 'title', fatal=True)
get_info = self._download_json(self._GET_VIDEO_URL.format(video_id), video_id)
status = get_info.get('status')
if status == 200:
result = get_info.get('result', {})
title = result.get('name')
video_url = result.get('url')
elif status == 403:
pair_info = self._download_json(self._PAIR_INFO_URL, video_id,
note='Downloading pair info')
if pair_info.get('status') == 200:
pair_url = pair_info.get('result', {}).get('auth_url')
if pair_url:
raise ExtractorError(self._PAIR_NEEDED.format(pair_url), expected=True)
else:
raise ExtractorError('Pair URL not found')
else:
raise ExtractorError('Error loading pair info')
else:
raise ExtractorError('Error loading JSON metadata', video_id=video_id)
entries = self._parse_html5_media_entries(url, webpage, video_id)
subtitles = entries[0]['subtitles'] if entries else None
entry = entries[0] if entries else {}
subtitles = entry.get('subtitles')
info_dict = {
'id': video_id,
'title': title,
'thumbnail': self._og_search_thumbnail(webpage, default=None),
'thumbnail': entry.get('thumbnail') or self._og_search_thumbnail(webpage, default=None),
'url': video_url,
# Seems all videos have extensions in their titles
'ext': determine_ext(title, 'mp4'),