1 from .common
import InfoExtractor
2 from ..utils
import ExtractorError
, determine_ext
, parse_iso8601
, url_or_none
3 from ..utils
.traversal
import traverse_obj
6 class TrtWorldIE(InfoExtractor
):
7 _VALID_URL
= r
'https?://www\.trtworld\.com/video/[\w-]+/[\w-]+-(?P<id>\d+)'
10 'url': 'https://www.trtworld.com/video/news/turkiye-switches-to-sustainable-tourism-16067690',
14 'title': 'Türkiye switches to sustainable tourism',
15 'release_timestamp': 1701529569,
16 'release_date': '20231202',
17 'thumbnail': 'https://cdn-i.pr.trt.com.tr/trtworld/17647563_0-0-1920-1080.jpeg',
18 'description': 'md5:0a975c04257fb529c8f99c7b76a2cf12',
21 'url': 'https://www.trtworld.com/video/one-offs/frames-from-anatolia-recreating-a-james-bond-scene-in-istanbuls-grand-bazaar-14541780',
25 'title': 'Frames From Anatolia: Recreating a ‘James Bond’ Scene in Istanbul’s Grand Bazaar',
26 'release_timestamp': 1692440844,
27 'release_date': '20230819',
28 'thumbnail': 'https://cdn-i.pr.trt.com.tr/trtworld/16939810_0-0-1920-1080.jpeg',
29 'description': 'md5:4050e21570cc3c40b6c9badae800a94f',
32 'url': 'https://www.trtworld.com/video/the-newsmakers/can-sudan-find-peace-amidst-failed-transition-to-democracy-12904760',
36 'title': 'Can Sudan find peace amidst failed transition to democracy?',
37 'release_timestamp': 1681972747,
38 'release_date': '20230420',
39 'thumbnail': 'http://cdni0.trtworld.com/w768/q70/154214_NMYOUTUBETEMPLATE1_1681833018736.jpg',
42 'url': 'https://www.trtworld.com/video/africa-matters/locals-learning-to-cope-with-rising-tides-of-kenyas-great-lakes-16059545',
46 'title': "Locals learning to cope with rising tides of Kenya's Great Lakes",
47 'thumbnail': 'https://i.ytimg.com/vi/zEns2dWl00w/maxresdefault.jpg',
48 'description': 'md5:3ad9d7c5234d752a4ead4340c79c6b8d',
49 'channel_id': 'UC7fWeaHhqgM4Ry-RMpM2YYw',
50 'channel_url': 'https://www.youtube.com/channel/UC7fWeaHhqgM4Ry-RMpM2YYw',
54 'webpage_url': 'https://www.youtube.com/watch?v=zEns2dWl00w',
55 'categories': ['News & Politics'],
56 'channel': 'TRT World',
57 'channel_follower_count': int,
58 'channel_is_verified': True,
59 'uploader': 'TRT World',
60 'uploader_id': '@trtworld',
61 'uploader_url': 'https://www.youtube.com/@trtworld',
62 'upload_date': '20231202',
63 'availability': 'public',
65 'playable_in_embed': True,
67 'live_status': 'not_live',
72 def _real_extract(self
, url
):
73 display_id
= self
._match
_id
(url
)
74 webpage
= self
._download
_webpage
(url
, display_id
)
75 nuxtjs_data
= self
._search
_nuxt
_data
(webpage
, display_id
)['videoData']['content']['platforms']
77 for media_url
in traverse_obj(nuxtjs_data
, (
78 ('website', 'ott'), 'metadata', ('hls_url', 'url'), {url_or_none}
)):
79 # NB: Website sometimes serves mp4 files under `hls_url` key
80 if determine_ext(media_url
) == 'm3u8':
81 formats
.extend(self
._extract
_m
3u8_formats
(media_url
, display_id
, fatal
=False))
88 if youtube_id
:= traverse_obj(nuxtjs_data
, ('youtube', 'metadata', 'youtubeId')):
89 return self
.url_result(youtube_id
, 'Youtube')
90 raise ExtractorError('No video found', expected
=True)
95 **traverse_obj(nuxtjs_data
, (('website', 'ott'), {
96 'title': ('fields', 'title', 'text', {str}
),
97 'description': ('fields', 'description', 'text', {str}
),
98 'thumbnail': ('fields', 'thumbnail', 'url', {url_or_none}
),
99 'release_timestamp': ('published', 'date', {parse_iso8601}
),