1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-27 07:38:30 +00:00

Apply review suggestions

This commit is contained in:
sepro 2025-07-13 10:41:00 +02:00
parent 025c410414
commit a075e47a28
2 changed files with 7 additions and 29 deletions

View File

@ -2288,7 +2288,7 @@
) )
from .umg import UMGDeIE from .umg import UMGDeIE
from .unistra import UnistraIE from .unistra import UnistraIE
from .unitednation import UnitedNationWebTVExtractorIE from .unitednations import UnitedNationsWebTVIE
from .unity import UnityIE from .unity import UnityIE
from .unsupported import ( from .unsupported import (
KnownDRMIE, KnownDRMIE,

View File

@ -1,7 +1,8 @@
from .common import InfoExtractor
from .kaltura import KalturaIE from .kaltura import KalturaIE
class UnitedNationWebTVExtractorIE(KalturaIE): class UnitedNationsWebTVIE(InfoExtractor):
_VALID_URL = r'https?://webtv.un.org/(ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)' _VALID_URL = r'https?://webtv.un.org/(ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
_TESTS = [{ _TESTS = [{
'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p', 'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p',
@ -22,33 +23,10 @@ class UnitedNationWebTVExtractorIE(KalturaIE):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
partner_id = self._html_search_regex( partner_id = self._html_search_regex(
r'partnerId:\s*(\w+)', r'partnerId:\s*(\d+)', webpage, 'partner_id')
webpage,
'partner_id',
)
entry_id = self._html_search_regex( entry_id = self._html_search_regex(
r'const\s+kentryID\s*=\s*["\'](\w+)["\'];', r'const\s+kentryID\s*=\s*["\'](\w+)["\']', webpage, 'kentry_id')
webpage,
'kentry_id',
)
kaltura_api_response = self._get_video_info(entry_id, partner_id)
try: return self.url_result(f'kaltura:{partner_id}:{entry_id}', KalturaIE)
kaltura_url = kaltura_api_response[1].get('dataUrl', None)
except IndexError:
return self.url_result(
f'kaltura:{partner_id}:{entry_id}',
KalturaIE.ie_key(),
)
kaltura_id = self._search_regex(
r'http://cdnapi.kaltura.com/p/\w+/sp/\w+/playManifest/entryId/(\w+)/format/url/protocol/http',
kaltura_url,
'kaltura_id',
)
return self.url_result(
f'kaltura:{partner_id}:{kaltura_id}',
KalturaIE.ie_key(),
)