]>
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
)
83 'title' : self
._ og
_ search
_ title
( webpage
, default
= None ),
84 'description' : self
._ og
_ search
_ description
( webpage
, default
= None ),
85 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
, default
= None ),
87 'upload_date' : unified_strdate ( self
._ search
_ regex
( r
'datetime="(.+?)"' , webpage
, 'upload_date' , fatal
= False ))
91 class LA7PodcastEpisodeIE ( InfoExtractor
):
92 IE_NAME
= 'la7.it:pod:episode'
93 _VALID_URL
= r
'''(?x)(https?://)?
94 (?:www\.)?la7\.it/[^/]+/podcast/([^/]+-)?(?P<id>\d+)'''
97 'url' : 'https://www.la7.it/voicetown/podcast/la-carezza-delle-memoria-di-carlo-verdone-23-03-2021-371497' ,
98 'md5' : '7737d4d79b3c1a34b3de3e16297119ed' ,
102 'title' : '"La carezza delle memoria" di Carlo Verdone' ,
103 'description' : 'md5:5abf07c3c551a687db80af3f9ceb7d52' ,
104 'thumbnail' : 'https://www.la7.it/sites/default/files/podcast/371497.jpg' ,
105 'upload_date' : '20210323' ,
109 'url' : 'https://www.la7.it/embed/podcast/371497' ,
110 'only_matching' : True ,
112 # date already in the title
113 'url' : 'https://www.la7.it/propagandalive/podcast/lintervista-di-diego-bianchi-ad-annalisa-cuzzocrea-puntata-del-1932021-20-03-2021-371130' ,
114 'only_matching' : True ,
116 # title same as show_title
117 'url' : 'https://www.la7.it/otto-e-mezzo/podcast/otto-e-mezzo-26-03-2021-372340' ,
118 'only_matching' : True ,
121 def _extract_info ( self
, webpage
, video_id
= None , ppn
= None ):
123 video_id
= self
._ search
_ regex
(
124 r
'data-nid=([\' "])(?P<vid>\d+)\1',
125 webpage, 'video_id', group='vid')
127 media_url = self._search_regex(
128 (r'src:\s*([ \' " ])( ?P
< url
>.+ ?mp3
.+ ?
) \
1 ',
129 r' data
- podcast
=([ \' "])(?P<url>.+?mp3.+?)\1'),
130 webpage, 'media_url', group='url')
131 ext = determine_ext(media_url)
138 title = self._html_search_regex(
139 (r'<div class=" title
">(?P<title>.+?)</',
140 r'<title>(?P<title>[^<]+)</title>',
141 r'title:\s*([ \' " ])( ?P
< title
>.+ ?
) \
1 '),
142 webpage, ' title
', group=' title
')
145 self._html_search_regex(
146 (r' < div
class = "description" >(.+ ?
)</ div
> ',
147 r' < div
class = "description-mobile" >(.+ ?
)</ div
> ',
148 r' < div
class = "box-txt" >([ ^
<]+ ?
)</ div
> ',
149 r' < div
class = "field-content" >< p
>(.+ ?
)</ p
></ div
> '),
150 webpage, ' description
', default=None)
151 or self._html_search_meta(' description
', webpage))
153 thumb = self._html_search_regex(
154 (r' < div
class = "podcast-image" >< img src
= "(.+?)" ></ div
> ',
155 r' < div
class = "container-embed" [ ^
<]+ url\
((.+ ?
) \
); ">',
156 r'<div class=" field
- content
"><img src=" (.+ ?
) "'),
157 webpage, 'thumbnail', fatal=False, default=None)
159 duration = parse_duration(self._html_search_regex(
160 r'<span class=" ( ?
: durata|duration
) ">([\d:]+)</span>',
161 webpage, 'duration', fatal=False, default=None))
163 date = self._html_search_regex(
164 r'class=" data
">\s*(?:<span>)?([\d\.]+)\s*</',
165 webpage, 'date', default=None)
167 date_alt = self._search_regex(
168 r'(\d+[\./]\d+[\./]\d+)', title, 'date_alt', default=None)
169 ppn = ppn or self._search_regex(
170 r'ppN:\s*([ \' " ])( ?P
< ppn
>.+ ?
) \
1 ',
171 webpage, ' ppn
', group=' ppn
', default=None)
172 # if the date is not in the title
173 # and title is the same as the show_title
174 # add the date to the title
175 if date and not date_alt and ppn and ppn.lower() == title.lower():
176 title += ' del %s ' % date
180 ' description
': description,
181 ' duration
': float_or_none(duration),
184 ' upload_date
': unified_strdate(date),
187 def _real_extract(self, url):
188 video_id = self._match_id(url)
189 webpage = self._download_webpage(url, video_id)
191 return self._extract_info(webpage, video_id)
194 class LA7PodcastIE(LA7PodcastEpisodeIE): # XXX: Do not subclass from concrete IE
195 IE_NAME = ' la7
. it
: podcast
'
196 _VALID_URL = r' ( https?
://) ?
( www\
.) ?la7\
. it
/( ?P
< id >[ ^
/]+)/ podcast
/ ?
( ?
: $|
[ #?])'
199 'url' : 'https://www.la7.it/propagandalive/podcast' ,
201 'id' : 'propagandalive' ,
202 'title' : "Propaganda Live" ,
204 'playlist_count' : 10 ,
207 def _real_extract ( self
, url
):
208 playlist_id
= self
._ match
_ id
( url
)
209 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
212 self
._ html
_ search
_ regex
(
213 r
'<h1.*?>(.+?)</h1>' , webpage
, 'title' , fatal
= False , default
= None )
214 or self
._ og
_ search
_ title
( webpage
))
215 ppn
= self
._ search
_ regex
(
216 r
'window\.ppN\s*=\s*([\' "])(?P<ppn>.+?)\1',
217 webpage, 'ppn', group='ppn', default=None)
220 for episode in re.finditer(
221 r'<div class=" container
- podcast
- property ">([\s\S]+?)(?:</div>\s*) {3} ',
223 entries.append(self._extract_info(episode.group(1), ppn=ppn))
225 return self.playlist_result(entries, playlist_id, title)