[mildom] Change proxy

Related: #251
Closes #252
This commit is contained in:
pukkandan 2021-04-19 11:41:33 +05:30
parent d0491a1ebe
commit 2cff495997
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -1,11 +1,12 @@
# coding: utf-8 # coding: utf-8
from __future__ import unicode_literals from __future__ import unicode_literals
import base64
from datetime import datetime from datetime import datetime
import itertools import itertools
import json import json
import base64
import re import re
import random
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
@ -25,6 +26,17 @@ 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']
@ -69,7 +81,7 @@ def _fetch_dispatcher_config(self):
self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization') self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization')
except ExtractorError: except ExtractorError:
self._DISPATCHER_CONFIG = self._download_json( self._DISPATCHER_CONFIG = self._download_json(
'https://bookish-octo-barnacle.vercel.app/api/mildom/dispatcher_config', 'initialization', 'https://%s/api/mildom/dispatcher_config' % self._mildom_proxy_host(), 'initialization',
note='Downloading dispatcher_config fallback') note='Downloading dispatcher_config fallback')
return self._DISPATCHER_CONFIG return self._DISPATCHER_CONFIG
@ -145,12 +157,12 @@ def _real_extract(self, url):
'Referer': 'https://www.mildom.com/', 'Referer': 'https://www.mildom.com/',
'Origin': 'https://www.mildom.com', 'Origin': 'https://www.mildom.com',
}, note='Downloading m3u8 information') }, note='Downloading m3u8 information')
del stream_query['streamReqId'], stream_query['timestamp'] del stream_query['streamReqId'], stream_query['timestamp']
for fmt in formats: for fmt in formats:
# Uses https://github.com/nao20010128nao/bookish-octo-barnacle by @nao20010128nao as a proxy
parsed = compat_urlparse.urlparse(fmt['url']) parsed = compat_urlparse.urlparse(fmt['url'])
parsed = parsed._replace( parsed = parsed._replace(
netloc='bookish-octo-barnacle.vercel.app', netloc=self._mildom_proxy_host(),
query=compat_urllib_parse_urlencode(stream_query, True), query=compat_urllib_parse_urlencode(stream_query, True),
path='/api/mildom' + parsed.path) path='/api/mildom' + parsed.path)
fmt['url'] = compat_urlparse.urlunparse(parsed) fmt['url'] = compat_urlparse.urlunparse(parsed)
@ -229,7 +241,7 @@ def _real_extract(self, url):
parsed = compat_urlparse.urlparse(fmt['url']) parsed = compat_urlparse.urlparse(fmt['url'])
stream_query['path'] = parsed.path[5:] stream_query['path'] = parsed.path[5:]
parsed = parsed._replace( parsed = parsed._replace(
netloc='bookish-octo-barnacle.vercel.app', netloc=self._mildom_proxy_host(),
query=compat_urllib_parse_urlencode(stream_query, True), query=compat_urllib_parse_urlencode(stream_query, True),
path='/api/mildom/vod2/proxy') path='/api/mildom/vod2/proxy')
fmt['url'] = compat_urlparse.urlunparse(parsed) fmt['url'] = compat_urlparse.urlunparse(parsed)