From 50cdbbaf9ccccf44cef2f4c57815d13a71b5699a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 20 Nov 2024 11:41:29 +0200 Subject: [PATCH 1/2] Add new url format to duoplay - https://duoplay.ee/9644?ep=184 --- yt_dlp/extractor/duoplay.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/duoplay.py b/yt_dlp/extractor/duoplay.py index 18642fea3..4559c2d1c 100644 --- a/yt_dlp/extractor/duoplay.py +++ b/yt_dlp/extractor/duoplay.py @@ -13,7 +13,8 @@ class DuoplayIE(InfoExtractor): - _VALID_URL = r'https?://duoplay\.ee/(?P\d+)/[\w-]+/?(?:\?(?:[^#]+&)?ep=(?P\d+))?' + # https://duoplay.ee/9644?ep=185 + _VALID_URL = r'https?://duoplay\.ee/(?P\d+)(?:/[\w-]+/?(?:\?(?:[^#]+&))?ep=(?P\d+))?' _TESTS = [{ 'note': 'Siberi võmm S02E12', 'url': 'https://duoplay.ee/4312/siberi-vomm?ep=24', From 886ae0c277383ecb5c3b497106695e69bf3fbfee Mon Sep 17 00:00:00 2001 From: bashonly <88596187+bashonly@users.noreply.github.com> Date: Wed, 20 Nov 2024 15:24:36 +0000 Subject: [PATCH 2/2] get session token --- yt_dlp/extractor/duoplay.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/yt_dlp/extractor/duoplay.py b/yt_dlp/extractor/duoplay.py index 4559c2d1c..d64c71412 100644 --- a/yt_dlp/extractor/duoplay.py +++ b/yt_dlp/extractor/duoplay.py @@ -8,6 +8,7 @@ str_or_none, try_call, unified_timestamp, + update_url_query, ) from ..utils.traversal import traverse_obj @@ -80,11 +81,20 @@ def _real_extract(self, url): if not video_player or not video_player.get('manifest-url'): raise ExtractorError('No video found', expected=True) + manifest_url = video_player['manifest-url'] + session_token = self._download_json( + 'https://sts.postimees.ee/session/register', video_id, 'Registering session', + 'Unable to register session', headers={ + 'Accept': 'application/json', + 'X-Original-URI': manifest_url, + })['session'] + manifest_url = update_url_query(manifest_url, {'s': session_token}) + episode_attr = self._parse_json(video_player.get(':episode') or '', video_id, fatal=False) or {} return { 'id': video_id, - 'formats': self._extract_m3u8_formats(video_player['manifest-url'], video_id, 'mp4'), + 'formats': self._extract_m3u8_formats(manifest_url, video_id, 'mp4'), **traverse_obj(episode_attr, { 'title': 'title', 'description': 'synopsis',