]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/cnn.py
1 from . common
import InfoExtractor
2 from . turner
import TurnerBaseIE
3 from .. utils
import merge_dicts
, try_call
, url_basename
6 class CNNIE ( TurnerBaseIE
):
7 _VALID_URL
= r
'''(?x)https?://(?:(?P<sub_domain>edition|www|money)\.)?cnn\.com/(?:video/(?:data/.+?|\?)/)?videos?/
8 (?P<path>.+?/(?P<title>[^/]+?)(?:\.(?:[a-z\-]+)|(?=&)))'''
11 'url' : 'http://edition.cnn.com/video/?/video/sports/2013/06/09/nadal-1-on-1.cnn' ,
12 'md5' : '3e6121ea48df7e2259fe73a0628605c4' ,
14 'id' : 'sports/2013/06/09/nadal-1-on-1.cnn' ,
16 'title' : 'Nadal wins 8th French Open title' ,
17 'description' : 'World Sport \' s Amanda Davies chats with 2013 French Open champion Rafael Nadal.' ,
19 'upload_date' : '20130609' ,
21 'expected_warnings' : [ 'Failed to download m3u8 information' ],
23 'url' : 'http://edition.cnn.com/video/?/video/us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+rss%2Fcnn_topstories+%28RSS%3A+Top+Stories%29' ,
24 'md5' : 'b5cc60c60a3477d185af8f19a2a26f4e' ,
26 'id' : 'us/2013/08/21/sot-student-gives-epic-speech.georgia-institute-of-technology' ,
28 'title' : "Student's epic speech stuns new freshmen" ,
29 'description' : "A Georgia Tech student welcomes the incoming freshmen with an epic speech backed by music from \" 2001: A Space Odyssey. \" " ,
30 'upload_date' : '20130821' ,
32 'expected_warnings' : [ 'Failed to download m3u8 information' ],
34 'url' : 'http://www.cnn.com/video/data/2.0/video/living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln.html' ,
35 'md5' : 'f14d02ebd264df951feb2400e2c25a1b' ,
37 'id' : 'living/2014/12/22/growing-america-nashville-salemtown-board-episode-1.hln' ,
39 'title' : 'Nashville Ep. 1: Hand crafted skateboards' ,
40 'description' : 'md5:e7223a503315c9f150acac52e76de086' ,
41 'upload_date' : '20141222' ,
43 'expected_warnings' : [ 'Failed to download m3u8 information' ],
45 'url' : 'http://money.cnn.com/video/news/2016/08/19/netflix-stunning-stats.cnnmoney/index.html' ,
46 'md5' : '52a515dc1b0f001cd82e4ceda32be9d1' ,
48 'id' : '/video/news/2016/08/19/netflix-stunning-stats.cnnmoney' ,
50 'title' : '5 stunning stats about Netflix' ,
51 'description' : 'Did you know that Netflix has more than 80 million members? Here are five facts about the online video distributor that you probably didn \' t know.' ,
52 'upload_date' : '20160819' ,
56 'skip_download' : True ,
59 'url' : 'http://cnn.com/video/?/video/politics/2015/03/27/pkg-arizona-senator-church-attendance-mandatory.ktvk' ,
60 'only_matching' : True ,
62 'url' : 'http://cnn.com/video/?/video/us/2015/04/06/dnt-baker-refuses-anti-gay-order.wkmg' ,
63 'only_matching' : True ,
65 'url' : 'http://edition.cnn.com/videos/arts/2016/04/21/olympic-games-cultural-a-z-brazil.cnn' ,
66 'only_matching' : True ,
70 # http://edition.cnn.com/.element/apps/cvp/3.0/cfg/spider/cnn/expansion/config.xml
72 'data_src' : 'http://edition.cnn.com/video/data/3.0/video/ %s /index.xml' ,
73 'media_src' : 'http://pmd.cdn.turner.com/cnn/big' ,
75 # http://money.cnn.com/.element/apps/cvp2/cfg/config.xml
77 'data_src' : 'http://money.cnn.com/video/data/4.0/video/ %s .xml' ,
78 'media_src' : 'http://ht3.cdn.turner.com/money/big' ,
82 def _extract_timestamp ( self
, video_data
):
83 # TODO: fix timestamp extraction
86 def _real_extract ( self
, url
):
87 sub_domain
, path
, page_title
= self
._ match
_ valid
_u rl
( url
). groups ()
88 if sub_domain
not in ( 'money' , 'edition' ):
89 sub_domain
= 'edition'
90 config
= self
._ CONFIG
[ sub_domain
]
91 return self
._ extract
_ cvp
_ info
(
92 config
[ 'data_src' ] % path
, page_title
, {
94 'media_src' : config
[ 'media_src' ],
97 'host' : 'cnn-vh.akamaihd.net' ,
102 class CNNBlogsIE ( InfoExtractor
):
103 _VALID_URL
= r
'https?://[^\.]+\.blogs\.cnn\.com/.+'
105 'url' : 'http://reliablesources.blogs.cnn.com/2014/02/09/criminalizing-journalism/' ,
106 'md5' : '3e56f97b0b6ffb4b79f4ea0749551084' ,
108 'id' : 'bestoftv/2014/02/09/criminalizing-journalism.cnn' ,
110 'title' : 'Criminalizing journalism?' ,
111 'description' : 'Glenn Greenwald responds to comments made this week on Capitol Hill that journalists could be criminal accessories.' ,
112 'upload_date' : '20140209' ,
114 'expected_warnings' : [ 'Failed to download m3u8 information' ],
118 def _real_extract ( self
, url
):
119 webpage
= self
._ download
_ webpage
( url
, url_basename ( url
))
120 cnn_url
= self
._ html
_ search
_ regex
( r
'data-url="(.+?)"' , webpage
, 'cnn url' )
121 return self
. url_result ( cnn_url
, CNNIE
. ie_key ())
124 class CNNArticleIE ( InfoExtractor
):
125 _VALID_URL
= r
'https?://(?:(?:edition|www)\.)?cnn\.com/(?!videos?/)'
127 'url' : 'http://www.cnn.com/2014/12/21/politics/obama-north-koreas-hack-not-war-but-cyber-vandalism/' ,
128 'md5' : '689034c2a3d9c6dc4aa72d65a81efd01' ,
130 'id' : 'bestoftv/2014/12/21/ip-north-korea-obama.cnn' ,
132 'title' : 'Obama: Cyberattack not an act of war' ,
133 'description' : 'md5:0a802a40d2376f60e6b04c8d5bcebc4b' ,
134 'upload_date' : '20141221' ,
136 'expected_warnings' : [ 'Failed to download m3u8 information' ],
140 def _real_extract ( self
, url
):
141 webpage
= self
._ download
_ webpage
( url
, url_basename ( url
))
142 cnn_url
= self
._ html
_ search
_ regex
( r
"video:\s*'([^']+)'" , webpage
, 'cnn url' )
143 return self
. url_result ( 'http://cnn.com/video/?/video/' + cnn_url
, CNNIE
. ie_key ())
146 class CNNIndonesiaIE ( InfoExtractor
):
147 _VALID_URL
= r
'https?://www\.cnnindonesia\.com/[\w-]+/(?P<upload_date>\d {8} )\d+-\d+-(?P<id>\d+)/(?P<display_id>[\w-]+)'
149 'url' : 'https://www.cnnindonesia.com/ekonomi/20220909212635-89-845885/alasan-harga-bbm-di-indonesia-masih-disubsidi' ,
153 'description' : 'md5:e7954bfa6f1749bc9ef0c079a719c347' ,
154 'upload_date' : '20220909' ,
155 'title' : 'Alasan Harga BBM di Indonesia Masih Disubsidi' ,
156 'timestamp' : 1662859088 ,
158 'thumbnail' : r
're:https://akcdn\.detik\.net\.id/visual/2022/09/09/thumbnail-ekopedia-alasan-harga-bbm-disubsidi_169\.jpeg' ,
159 'tags' : [ 'ekopedia' , 'subsidi bbm' , 'subsidi' , 'bbm' , 'bbm subsidi' , 'harga pertalite naik' ],
161 'release_timestamp' : 1662859088 ,
162 'release_date' : '20220911' ,
163 'uploader' : 'Asfahan Yahsyi' ,
166 'url' : 'https://www.cnnindonesia.com/internasional/20220911104341-139-846189/video-momen-charles-disambut-meriah-usai-dilantik-jadi-raja-inggris' ,
170 'upload_date' : '20220911' ,
172 'timestamp' : 1662869995 ,
173 'description' : 'md5:ece7b003b3ee7d81c6a5cfede7d5397d' ,
174 'thumbnail' : r
're:https://akcdn\.detik\.net\.id/visual/2022/09/11/thumbnail-video-1_169\.jpeg' ,
175 'title' : 'VIDEO: Momen Charles Disambut Meriah usai Dilantik jadi Raja Inggris' ,
176 'tags' : [ 'raja charles' , 'raja charles iii' , 'ratu elizabeth' , 'ratu elizabeth meninggal dunia' , 'raja inggris' , 'inggris' ],
178 'release_date' : '20220911' ,
179 'uploader' : 'REUTERS' ,
180 'release_timestamp' : 1662869995 ,
184 def _real_extract ( self
, url
):
185 upload_date
, video_id
, display_id
= self
._ match
_ valid
_u rl
( url
). group ( 'upload_date' , 'id' , 'display_id' )
186 webpage
= self
._ download
_ webpage
( url
, display_id
)
188 json_ld_list
= list ( self
._ yield
_ json
_l d
( webpage
, display_id
))
189 json_ld_data
= self
._ json
_l d
( json_ld_list
, display_id
)
191 json_ld
. get ( 'embedUrl' ) for json_ld
in json_ld_list
if json_ld
. get ( '@type' ) == 'VideoObject' )
193 return merge_dicts ( json_ld_data
, {
194 '_type' : 'url_transparent' ,
196 'upload_date' : upload_date
,
197 'tags' : try_call ( lambda : self
._ html
_ search
_ meta
( 'keywords' , webpage
). split ( ', ' ))