From 2cff49599769dcc131c385cbc24bab35d0b182ad Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 19 Apr 2021 11:41:33 +0530 Subject: [PATCH] [mildom] Change proxy Related: #251 Closes #252 --- yt_dlp/extractor/mildom.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/yt_dlp/extractor/mildom.py b/yt_dlp/extractor/mildom.py index 3606f09b4..83d9e7dd1 100644 --- a/yt_dlp/extractor/mildom.py +++ b/yt_dlp/extractor/mildom.py @@ -1,11 +1,12 @@ # coding: utf-8 from __future__ import unicode_literals +import base64 from datetime import datetime import itertools import json -import base64 import re +import random from .common import InfoExtractor from ..utils import ( @@ -25,6 +26,17 @@ 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'] @@ -69,7 +81,7 @@ class MildomBaseIE(InfoExtractor): self._DISPATCHER_CONFIG = self._parse_json(base64.b64decode(tmp['data']), 'initialization') except ExtractorError: 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') return self._DISPATCHER_CONFIG @@ -145,12 +157,12 @@ class MildomIE(MildomBaseIE): 'Referer': 'https://www.mildom.com/', 'Origin': 'https://www.mildom.com', }, note='Downloading m3u8 information') + del stream_query['streamReqId'], stream_query['timestamp'] for fmt in formats: - # Uses https://github.com/nao20010128nao/bookish-octo-barnacle by @nao20010128nao as a proxy parsed = compat_urlparse.urlparse(fmt['url']) parsed = parsed._replace( - netloc='bookish-octo-barnacle.vercel.app', + netloc=self._mildom_proxy_host(), query=compat_urllib_parse_urlencode(stream_query, True), path='/api/mildom' + parsed.path) fmt['url'] = compat_urlparse.urlunparse(parsed) @@ -229,7 +241,7 @@ class MildomVodIE(MildomBaseIE): parsed = compat_urlparse.urlparse(fmt['url']) stream_query['path'] = parsed.path[5:] parsed = parsed._replace( - netloc='bookish-octo-barnacle.vercel.app', + netloc=self._mildom_proxy_host(), query=compat_urllib_parse_urlencode(stream_query, True), path='/api/mildom/vod2/proxy') fmt['url'] = compat_urlparse.urlunparse(parsed)