1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-21 15:23:13 +00:00

Create streamtape.py

This commit is contained in:
Nial McCallister 2021-09-28 00:09:26 +01:00 committed by GitHub
parent 4c9cc9cfac
commit 96bbda4a4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,54 @@
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import js_to_json, urljoin
# strings are obfuscated by concatenating substrings
split_string_part = r'(?:%s|%s)' % (r'"(?:[^"\\]|\\.)*"',
r"'(?:[^'\\]|\\.)*'")
split_string = r'(?:' + split_string_part + r'(?:\s*\+\s*' + split_string_part + r')*)'
videolink = r"(?:'\+')?".join('videolink')
videolink = r"document\.getElementById\('" + videolink + r"'\)\.innerHTML\s*=\s*(?P<data>" + split_string + r")"
class StreamtapeIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?streamtape.com/[ev]/(?P<id>[^/?#]+)'
_TESTS = [{
'url': 'https://streamtape.com/v/AJD9gAVwMOcXrQ8/Big_Buck_Bunny_Trailer_400p.ogg',
'md5': '6f7cdddd436852f054728bfd4d3be873',
'info_dict': {
'id': 'AJD9gAVwMOcXrQ8',
'ext': 'mp4',
'title': 'Big_Buck_Bunny_Trailer_400p.ogg.mp4',
'thumbnail': r're:^https?://.*\.jpg$',
'age_limit': 18,
},
}]
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
video = self._html_search_regex(videolink, webpage, 'video', group='data')
video = video.split('+')
video = [self._parse_json(v, video_id, js_to_json) for v in video]
video = urljoin(url, ''.join(video))
try:
poster = self._html_search_regex(r' id="mainvideo"[^>]* poster="(?P<data>.*?)"',
webpage, 'poster', group='data')
poster = urljoin(url, poster)
except ValueError:
poster = None
title = self._og_search_title(webpage)
return {
'id': video_id,
'url': video,
'title': title,
'thumbnail': poster,
'age_limit': 18,
'ext': 'mp4',
}