0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-22 02:15:12 +00:00

[mildom] Remove proxy (#260)

Closes #251
Makes 2cff495997, ab406a1c0e, #252 obsolete

Authored by: fstirlitz
This commit is contained in:
Felix S 2021-04-22 13:22:22 +02:00 committed by GitHub
parent 6efb071135
commit a471f21da6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,18 +6,15 @@
import itertools import itertools
import json import json
import re import re
import random
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError, std_headers, std_headers,
update_url_query, update_url_query,
random_uuidv4, random_uuidv4,
try_get, try_get,
) )
from ..compat import ( from ..compat import (
compat_urlparse,
compat_urllib_parse_urlencode,
compat_str, compat_str,
) )
@ -26,17 +23,6 @@ class MildomBaseIE(InfoExtractor):
_GUEST_ID = None _GUEST_ID = None
_DISPATCHER_CONFIG = None _DISPATCHER_CONFIG = None
# Proxies provided by @nao20010128nao
# See https://github.com/nao20010128nao/bookish-octo-barnacle
_MILDOM_PROXY_HOSTS = (
# 'bookish-octo-barnacle.vercel.app', # see https://github.com/yt-dlp/yt-dlp/issues/251
'free-mountain-goal.glitch.me',
'lesmih0sted.f5.si',
)
def _mildom_proxy_host(self):
return random.choice(self._MILDOM_PROXY_HOSTS)
def _call_api(self, url, video_id, query={}, note='Downloading JSON metadata', init=False): def _call_api(self, url, video_id, query={}, note='Downloading JSON metadata', init=False):
url = update_url_query(url, self._common_queries(query, init=init)) url = update_url_query(url, self._common_queries(query, init=init))
return self._download_json(url, video_id, note=note)['body'] return self._download_json(url, video_id, note=note)['body']
@ -60,29 +46,24 @@ def _common_queries(self, query={}, init=False):
def _fetch_dispatcher_config(self): def _fetch_dispatcher_config(self):
if not self._DISPATCHER_CONFIG: if not self._DISPATCHER_CONFIG:
try: tmp = self._download_json(
tmp = self._download_json( 'https://disp.mildom.com/serverListV2', 'initialization',
'https://disp.mildom.com/serverListV2', 'initialization', note='Downloading dispatcher_config', data=json.dumps({
note='Downloading dispatcher_config', data=json.dumps({ 'protover': 0,
'protover': 0, 'data': base64.b64encode(json.dumps({
'data': base64.b64encode(json.dumps({ 'fr': 'web',
'fr': 'web', 'sfr': 'pc',
'sfr': 'pc', 'devi': 'Windows',
'devi': 'Windows', 'la': 'ja',
'la': 'ja', 'gid': None,
'gid': None, 'loc': '',
'loc': '', 'clu': '',
'clu': '', 'wh': '1919*810',
'wh': '1919*810', 'rtm': self.iso_timestamp(),
'rtm': self.iso_timestamp(), 'ua': std_headers['User-Agent'],
'ua': std_headers['User-Agent'], }).encode('utf8')).decode('utf8').replace('\n', ''),
}).encode('utf8')).decode('utf8').replace('\n', ''), }).encode('utf8'))
}).encode('utf8')) self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization')
self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization')
except ExtractorError:
self._DISPATCHER_CONFIG = self._download_json(
'https://%s/api/mildom/dispatcher_config' % self._mildom_proxy_host(), 'initialization',
note='Downloading dispatcher_config fallback')
return self._DISPATCHER_CONFIG return self._DISPATCHER_CONFIG
@staticmethod @staticmethod
@ -118,9 +99,6 @@ def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
url = 'https://www.mildom.com/%s' % video_id url = 'https://www.mildom.com/%s' % video_id
self.to_screen(
'Live videos are downloaded using proxies based on "https://github.com/nao20010128nao/bookish-octo-barnacle"\n'
' %s If you do not trust these proxies, please refrain from downloading live %s videos ' % (' ' * len(self.IE_NAME), self.IE_NAME))
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
enterstudio = self._call_api( enterstudio = self._call_api(
@ -163,12 +141,7 @@ def _real_extract(self, url):
del stream_query['streamReqId'], stream_query['timestamp'] del stream_query['streamReqId'], stream_query['timestamp']
for fmt in formats: for fmt in formats:
parsed = compat_urlparse.urlparse(fmt['url']) fmt.setdefault('http_headers', {})['Referer'] = 'https://www.mildom.com/'
parsed = parsed._replace(
netloc=self._mildom_proxy_host(),
query=compat_urllib_parse_urlencode(stream_query, True),
path='/api/mildom' + parsed.path)
fmt['url'] = compat_urlparse.urlunparse(parsed)
self._sort_formats(formats) self._sort_formats(formats)
@ -235,21 +208,6 @@ def _real_extract(self, url):
'ext': 'mp4' 'ext': 'mp4'
}) })
r''' # Proxy is not needed for VODs
stream_query = self._common_queries({
'is_lhls': '0',
})
del stream_query['timestamp']
for fmt in formats:
parsed = compat_urlparse.urlparse(fmt['url'])
stream_query['path'] = parsed.path[5:]
parsed = parsed._replace(
netloc=self._mildom_proxy_host(),
query=compat_urllib_parse_urlencode(stream_query, True),
path='/api/mildom/vod2/proxy')
fmt['url'] = compat_urlparse.urlunparse(parsed)
'''
self._sort_formats(formats) self._sort_formats(formats)
return { return {