Compare commits

...

5 Commits

Author SHA1 Message Date
Patrick Menschel
b5d656ac73 Fix Flake8 Issues. 2023-11-03 16:52:24 +01:00
Patrick Menschel
e50c253023 Fix ytdlp's own requirements.txt ! v2
Remove duplicate of pycryptodomex
2023-11-03 16:44:54 +01:00
Patrick Menschel
904819e08b Fix ytdlp's own requirements.txt ! 2023-11-03 16:43:49 +01:00
Patrick Menschel
a3833fc5de Fix ytdlp's own CI script! v2 2023-11-03 16:38:47 +01:00
Patrick Menschel
02539fabe2 Fix ytdlp's own CI script! 2023-11-03 16:28:11 +01:00
3 changed files with 21 additions and 11 deletions

View File

@ -15,7 +15,7 @@ jobs:
with: with:
python-version: '3.11' python-version: '3.11'
- name: Install test requirements - name: Install test requirements
run: pip install pytest pycryptodomex run: pip install -r requirements.txt
- name: Run tests - name: Run tests
run: | run: |
python3 -m yt_dlp -v || true python3 -m yt_dlp -v || true

View File

@ -5,4 +5,7 @@ brotli; platform_python_implementation=='CPython'
brotlicffi; platform_python_implementation!='CPython' brotlicffi; platform_python_implementation!='CPython'
certifi certifi
requests>=2.31.0,<3 requests>=2.31.0,<3
urllib3>=1.26.17,<3 urllib3>=1.26.17,<3
# test
pytest

View File

@ -19,6 +19,8 @@ def _generate_video_specific_cache_url(slug, parent_slug):
""" """
return 'https://de-api.loma-cms.com/feloma/page/{0}/?environment=tele5&parent_slug={1}&v=2'.format(slug, return 'https://de-api.loma-cms.com/feloma/page/{0}/?environment=tele5&parent_slug={1}&v=2'.format(slug,
parent_slug) parent_slug)
def _do_cached_post(s: requests.session, def _do_cached_post(s: requests.session,
referer: str, referer: str,
url: str) -> dict: url: str) -> dict:
@ -45,6 +47,7 @@ def _do_cached_post(s: requests.session,
r.raise_for_status() r.raise_for_status()
return r.json() return r.json()
class Tele5IE(DPlayIE): # XXX: Do not subclass from concrete IE class Tele5IE(DPlayIE): # XXX: Do not subclass from concrete IE
_VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)' _VALID_URL = r'https?://(?:www\.)?tele5\.de/(?:[^/]+/)*(?P<id>[^/?#&]+)'
_GEO_COUNTRIES = ['DE'] _GEO_COUNTRIES = ['DE']
@ -128,19 +131,22 @@ class Tele5IE(DPlayIE): # XXX: Do not subclass from concrete IE
}] }]
def _real_extract(self, url): def _real_extract(self, url):
content_regex = re.compile(r'https?://(?:www\.)?(?P<environment>[^.]+)\.de/(?P<parent_slug>[^/]+)/(?P<slug>[^/?#&]+)') content_regex = re.compile(
r'https?://(?:www\.)?(?P<environment>[^.]+)\.de/(?P<parent_slug>[^/]+)/(?P<slug>[^/?#&]+)')
m = content_regex.search(url) m = content_regex.search(url)
if m is not None: if m is not None:
environment, parent_slug, slug = m.groups() environment, parent_slug, slug = m.groups()
s = requests.session() s = requests.session()
headers_for_origin = {'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0'} headers_for_origin = {
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0'}
r = s.get(url=url, r = s.get(url=url,
headers=headers_for_origin) headers=headers_for_origin)
r.raise_for_status() r.raise_for_status()
cached_base = _do_cached_post(s=s, cached_base = _do_cached_post(
referer=url, s=s,
url='https://de-api.loma-cms.com/feloma/configurations/?environment={0}'.format(environment)) referer=url,
url='https://de-api.loma-cms.com/feloma/configurations/?environment={0}'.format(environment))
site_info = cached_base.get('data').get('settings').get('site') site_info = cached_base.get('data').get('settings').get('site')
player_info = site_info.get('player') player_info = site_info.get('player')
@ -149,10 +155,11 @@ class Tele5IE(DPlayIE): # XXX: Do not subclass from concrete IE
sonic_endpoint = compat_urlparse.urlparse(player_info['sonicEndpoint']).hostname sonic_endpoint = compat_urlparse.urlparse(player_info['sonicEndpoint']).hostname
country = site_info['info']['country'] country = site_info['info']['country']
cached_video_specific = _do_cached_post(s=s, referer=url, cached_video_specific = _do_cached_post(s=s,
url=_generate_video_specific_cache_url( referer=url,
slug=slug, url=_generate_video_specific_cache_url(
parent_slug=parent_slug)) slug=slug,
parent_slug=parent_slug))
video_id = cached_video_specific['data']['blocks'][1]['videoId'] video_id = cached_video_specific['data']['blocks'][1]['videoId']