]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/la7.py
3 from . common
import InfoExtractor
14 class LA7IE ( InfoExtractor
):
16 _VALID_URL
= r
'''(?x)(https?://)?(?:
17 (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
18 tg\.la7\.it/repliche-tgla7\?id=
22 # 'src' is a plain URL
23 'url' : 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722' ,
24 'md5' : '8b613ffc0c4bf9b9e377169fc19c214c' ,
26 'id' : 'inccool8-02-10-2015-163722' ,
29 'description' : 'Benvenuti nell \' incredibile mondo della INC. COOL. 8. dove “INC.” sta per “Incorporated” “COOL” sta per “fashion” ed Eight sta per il gesto atletico' ,
30 'thumbnail' : 're:^https?://.*' ,
31 'upload_date' : '20151002' ,
34 'url' : 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077' ,
35 'only_matching' : True ,
37 _HOST
= 'https://awsvodpkg.iltrovatore.it'
39 def _generate_mp4_url ( self
, quality
, m3u8_formats
):
40 for f
in m3u8_formats
:
41 if f
[ 'vcodec' ] != 'none' and quality
in f
[ 'url' ]:
42 http_url
= ' %s%s .mp4' % ( self
._ HOST
, quality
)
44 urlh
= self
._ request
_ webpage
(
45 HEADRequest ( http_url
), quality
,
46 note
= 'Check filesize' , fatal
= False )
49 del http_f
[ 'manifest_url' ]
51 'format_id' : http_f
[ 'format_id' ]. replace ( 'hls-' , 'https-' ),
54 'filesize_approx' : int_or_none ( urlh
. headers
. get ( 'Content-Length' , None )),
59 def _real_extract ( self
, url
):
60 video_id
= self
._ match
_ id
( url
)
62 if not url
. startswith ( 'http' ):
63 url
= ' %s // %s ' % ( self
. http_scheme (), url
)
65 webpage
= self
._ download
_ webpage
( url
, video_id
)
66 video_path
= self
._ search
_ regex
( r
'(/content/.*?).mp4' , webpage
, 'video_path' )
68 formats
= self
._ extract
_ mpd
_ formats
(
69 f
' {self._HOST} /local/dash/, {video_path} .mp4.urlset/manifest.mpd' ,
70 video_id
, mpd_id
= 'dash' , fatal
= False )
71 m3u8_formats
= self
._ extract
_ m
3u8_ formats
(
72 f
' {self._HOST} /local/hls/, {video_path} .mp4.urlset/master.m3u8' ,
73 video_id
, 'mp4' , m3u8_id
= 'hls' , fatal
= False )
74 formats
. extend ( m3u8_formats
)
76 for q
in filter ( None , video_path
. split ( ',' )):
77 http_f
= self
._ generate
_ mp
4_u rl
( q
, m3u8_formats
)
79 formats
. append ( http_f
)
81 self
._ sort
_ formats
( formats
)
85 'title' : self
._ og
_ search
_ title
( webpage
, default
= None ),
86 'description' : self
._ og
_ search
_ description
( webpage
, default
= None ),
87 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
, default
= None ),
89 'upload_date' : unified_strdate ( self
._ search
_ regex
( r
'datetime="(.+?)"' , webpage
, 'upload_date' , fatal
= False ))
93 class LA7PodcastEpisodeIE ( InfoExtractor
):
94 IE_NAME
= 'la7.it:pod:episode'
95 _VALID_URL
= r
'''(?x)(https?://)?
96 (?:www\.)?la7\.it/[^/]+/podcast/([^/]+-)?(?P<id>\d+)'''
99 'url' : 'https://www.la7.it/voicetown/podcast/la-carezza-delle-memoria-di-carlo-verdone-23-03-2021-371497' ,
100 'md5' : '7737d4d79b3c1a34b3de3e16297119ed' ,
104 'title' : '"La carezza delle memoria" di Carlo Verdone' ,
105 'description' : 'md5:5abf07c3c551a687db80af3f9ceb7d52' ,
106 'thumbnail' : 'https://www.la7.it/sites/default/files/podcast/371497.jpg' ,
107 'upload_date' : '20210323' ,
111 'url' : 'https://www.la7.it/embed/podcast/371497' ,
112 'only_matching' : True ,
114 # date already in the title
115 'url' : 'https://www.la7.it/propagandalive/podcast/lintervista-di-diego-bianchi-ad-annalisa-cuzzocrea-puntata-del-1932021-20-03-2021-371130' ,
116 'only_matching' : True ,
118 # title same as show_title
119 'url' : 'https://www.la7.it/otto-e-mezzo/podcast/otto-e-mezzo-26-03-2021-372340' ,
120 'only_matching' : True ,
123 def _extract_info ( self
, webpage
, video_id
= None , ppn
= None ):
125 video_id
= self
._ search
_ regex
(
126 r
'data-nid=([\' "])(?P<vid>\d+)\1',
127 webpage, 'video_id', group='vid')
129 media_url = self._search_regex(
130 (r'src:\s*([ \' " ])( ?P
< url
>.+ ?mp3
.+ ?
) \
1 ',
131 r' data
- podcast
=([ \' "])(?P<url>.+?mp3.+?)\1'),
132 webpage, 'media_url', group='url')
133 ext = determine_ext(media_url)
139 self._sort_formats(formats)
141 title = self._html_search_regex(
142 (r'<div class=" title
">(?P<title>.+?)</',
143 r'<title>(?P<title>[^<]+)</title>',
144 r'title:\s*([ \' " ])( ?P
< title
>.+ ?
) \
1 '),
145 webpage, ' title
', group=' title
')
148 self._html_search_regex(
149 (r' < div
class = "description" >(.+ ?
)</ div
> ',
150 r' < div
class = "description-mobile" >(.+ ?
)</ div
> ',
151 r' < div
class = "box-txt" >([ ^
<]+ ?
)</ div
> ',
152 r' < div
class = "field-content" >< p
>(.+ ?
)</ p
></ div
> '),
153 webpage, ' description
', default=None)
154 or self._html_search_meta(' description
', webpage))
156 thumb = self._html_search_regex(
157 (r' < div
class = "podcast-image" >< img src
= "(.+?)" ></ div
> ',
158 r' < div
class = "container-embed" [ ^
<]+ url\
((.+ ?
) \
); ">',
159 r'<div class=" field
- content
"><img src=" (.+ ?
) "'),
160 webpage, 'thumbnail', fatal=False, default=None)
162 duration = parse_duration(self._html_search_regex(
163 r'<span class=" ( ?
: durata|duration
) ">([\d:]+)</span>',
164 webpage, 'duration', fatal=False, default=None))
166 date = self._html_search_regex(
167 r'class=" data
">\s*(?:<span>)?([\d\.]+)\s*</',
168 webpage, 'date', default=None)
170 date_alt = self._search_regex(
171 r'(\d+[\./]\d+[\./]\d+)', title, 'date_alt', default=None)
172 ppn = ppn or self._search_regex(
173 r'ppN:\s*([ \' " ])( ?P
< ppn
>.+ ?
) \
1 ',
174 webpage, ' ppn
', group=' ppn
', default=None)
175 # if the date is not in the title
176 # and title is the same as the show_title
177 # add the date to the title
178 if date and not date_alt and ppn and ppn.lower() == title.lower():
179 title += ' del %s ' % date
183 ' description
': description,
184 ' duration
': float_or_none(duration),
187 ' upload_date
': unified_strdate(date),
190 def _real_extract(self, url):
191 video_id = self._match_id(url)
192 webpage = self._download_webpage(url, video_id)
194 return self._extract_info(webpage, video_id)
197 class LA7PodcastIE(LA7PodcastEpisodeIE):
198 IE_NAME = ' la7
. it
: podcast
'
199 _VALID_URL = r' ( https?
://) ?
( www\
.) ?la7\
. it
/( ?P
< id >[ ^
/]+)/ podcast
/ ?
( ?
: $|
[ #?])'
202 'url' : 'https://www.la7.it/propagandalive/podcast' ,
204 'id' : 'propagandalive' ,
205 'title' : "Propaganda Live" ,
207 'playlist_count' : 10 ,
210 def _real_extract ( self
, url
):
211 playlist_id
= self
._ match
_ id
( url
)
212 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
215 self
._ html
_ search
_ regex
(
216 r
'<h1.*?>(.+?)</h1>' , webpage
, 'title' , fatal
= False , default
= None )
217 or self
._ og
_ search
_ title
( webpage
))
218 ppn
= self
._ search
_ regex
(
219 r
'window\.ppN\s*=\s*([\' "])(?P<ppn>.+?)\1',
220 webpage, 'ppn', group='ppn', default=None)
223 for episode in re.finditer(
224 r'<div class=" container
- podcast
- property ">([\s\S]+?)(?:</div>\s*) {3} ',
226 entries.append(self._extract_info(episode.group(1), ppn=ppn))
228 return self.playlist_result(entries, playlist_id, title)