mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[mildom] Remove proxy (#260)
Closes #251 Makes2cff495997
,ab406a1c0e
, #252 obsolete Authored by: fstirlitz
This commit is contained in:
parent
6efb071135
commit
a471f21da6
|
@ -6,18 +6,15 @@
|
|||
import itertools
|
||||
import json
|
||||
import re
|
||||
import random
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
ExtractorError, std_headers,
|
||||
std_headers,
|
||||
update_url_query,
|
||||
random_uuidv4,
|
||||
try_get,
|
||||
)
|
||||
from ..compat import (
|
||||
compat_urlparse,
|
||||
compat_urllib_parse_urlencode,
|
||||
compat_str,
|
||||
)
|
||||
|
||||
|
@ -26,17 +23,6 @@ class MildomBaseIE(InfoExtractor):
|
|||
_GUEST_ID = 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):
|
||||
url = update_url_query(url, self._common_queries(query, init=init))
|
||||
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):
|
||||
if not self._DISPATCHER_CONFIG:
|
||||
try:
|
||||
tmp = self._download_json(
|
||||
'https://disp.mildom.com/serverListV2', 'initialization',
|
||||
note='Downloading dispatcher_config', data=json.dumps({
|
||||
'protover': 0,
|
||||
'data': base64.b64encode(json.dumps({
|
||||
'fr': 'web',
|
||||
'sfr': 'pc',
|
||||
'devi': 'Windows',
|
||||
'la': 'ja',
|
||||
'gid': None,
|
||||
'loc': '',
|
||||
'clu': '',
|
||||
'wh': '1919*810',
|
||||
'rtm': self.iso_timestamp(),
|
||||
'ua': std_headers['User-Agent'],
|
||||
}).encode('utf8')).decode('utf8').replace('\n', ''),
|
||||
}).encode('utf8'))
|
||||
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')
|
||||
tmp = self._download_json(
|
||||
'https://disp.mildom.com/serverListV2', 'initialization',
|
||||
note='Downloading dispatcher_config', data=json.dumps({
|
||||
'protover': 0,
|
||||
'data': base64.b64encode(json.dumps({
|
||||
'fr': 'web',
|
||||
'sfr': 'pc',
|
||||
'devi': 'Windows',
|
||||
'la': 'ja',
|
||||
'gid': None,
|
||||
'loc': '',
|
||||
'clu': '',
|
||||
'wh': '1919*810',
|
||||
'rtm': self.iso_timestamp(),
|
||||
'ua': std_headers['User-Agent'],
|
||||
}).encode('utf8')).decode('utf8').replace('\n', ''),
|
||||
}).encode('utf8'))
|
||||
self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization')
|
||||
return self._DISPATCHER_CONFIG
|
||||
|
||||
@staticmethod
|
||||
|
@ -118,9 +99,6 @@ def _real_extract(self, url):
|
|||
video_id = self._match_id(url)
|
||||
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)
|
||||
|
||||
enterstudio = self._call_api(
|
||||
|
@ -163,12 +141,7 @@ def _real_extract(self, url):
|
|||
|
||||
del stream_query['streamReqId'], stream_query['timestamp']
|
||||
for fmt in formats:
|
||||
parsed = compat_urlparse.urlparse(fmt['url'])
|
||||
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)
|
||||
fmt.setdefault('http_headers', {})['Referer'] = 'https://www.mildom.com/'
|
||||
|
||||
self._sort_formats(formats)
|
||||
|
||||
|
@ -235,21 +208,6 @@ def _real_extract(self, url):
|
|||
'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)
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue