mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-08-22 22:34:01 -07:00
[StreamsbIE] some imports and minor fixes
This commit is contained in:
parent
2ae70a8ec0
commit
ff8c3d3324
1 changed files with 8 additions and 6 deletions
|
@ -1,10 +1,13 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import binascii
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import urljoin, url_basename
|
||||||
|
|
||||||
|
|
||||||
def to_ascii_hex(str1):
|
def to_ascii_hex(str1):
|
||||||
|
@ -17,7 +20,7 @@ def generate_random_string(length):
|
||||||
|
|
||||||
class StreamsbIE(InfoExtractor):
|
class StreamsbIE(InfoExtractor):
|
||||||
_DOMAINS = ('viewsb.com', )
|
_DOMAINS = ('viewsb.com', )
|
||||||
_VALID_URL = r'https://' + domain + '/(?P<id>.+)'
|
_VALID_URL = r'https://(?P<domain>%s)/(?P<id>.+)' % '|'.join(_DOMAINS)
|
||||||
_TEST = {
|
_TEST = {
|
||||||
'url': 'https://viewsb.com/dxfvlu4qanjx',
|
'url': 'https://viewsb.com/dxfvlu4qanjx',
|
||||||
'md5': '488d111a63415369bf90ea83adc8a325',
|
'md5': '488d111a63415369bf90ea83adc8a325',
|
||||||
|
@ -29,21 +32,20 @@ class StreamsbIE(InfoExtractor):
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
domain, video_id = re.match(self._VALID_URL, url).group('domain', 'id')
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
iframe_rel_url = self._search_regex(r'''(?i)<iframe\b[^>]+\bsrc\s*=\s*('|")(?P<path>/.*\.html)\1''', webpage, 'iframe', group='path')
|
iframe_rel_url = self._search_regex(r'''(?i)<iframe\b[^>]+\bsrc\s*=\s*('|")(?P<path>/.*\.html)\1''', webpage, 'iframe', group='path')
|
||||||
iframe_url = urljoin('https://' + self.domain, iframe_rel_url)
|
iframe_url = urljoin('https://' + domain, iframe_rel_url)
|
||||||
|
|
||||||
iframe_data = self._download_webpage(iframe_url, video_id)
|
iframe_data = self._download_webpage(iframe_url, video_id)
|
||||||
app_version = self._search_regex(r'''<script\b[^>]+\bsrc\s*=\s*("|')(?:(?!\1).)*/app\.min\.(\d+)\.js''', iframe_data, 'app version', fatal=False) or '50'
|
app_version = self._search_regex(r'''<script\b[^>]+\bsrc\s*=\s*["|'].*/app\.min\.(\d+)\.js''', iframe_data, 'app version', fatal=False) or '50'
|
||||||
|
|
||||||
video_code = url_basename(iframe_url).rsplit('.')[0]
|
video_code = url_basename(iframe_url).rsplit('.')[0]
|
||||||
|
|
||||||
length = 12
|
length = 12
|
||||||
req = '||'.join((generate_random_string(length), video_code, generate_random_string(length), 'streamsb'))
|
req = '||'.join((generate_random_string(length), video_code, generate_random_string(length), 'streamsb'))
|
||||||
ereq = 'https://{0}/sources{1}/{2}'.format(
|
ereq = 'https://{0}/sources{1}/{2}'.format(domain, app_version, to_ascii_hex(req))
|
||||||
self.domain, app_version, to_ascii_hex(req))
|
|
||||||
|
|
||||||
video_data = self._download_webpage(ereq, video_id, headers={
|
video_data = self._download_webpage(ereq, video_id, headers={
|
||||||
'Referer': iframe_url,
|
'Referer': iframe_url,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue