]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/la7.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
17 class LA7IE ( InfoExtractor
):
19 _VALID_URL
= r
'''(?x)(https?://)?(?:
20 (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
21 tg\.la7\.it/repliche-tgla7\?id=
25 # 'src' is a plain URL
26 'url' : 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722' ,
27 'md5' : '8b613ffc0c4bf9b9e377169fc19c214c' ,
29 'id' : 'inccool8-02-10-2015-163722' ,
32 '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' ,
33 'thumbnail' : 're:^https?://.*' ,
34 'upload_date' : '20151002' ,
37 'url' : 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077' ,
38 'only_matching' : True ,
40 _HOST
= 'https://awsvodpkg.iltrovatore.it'
42 def _generate_mp4_url ( self
, quality
, m3u8_formats
):
43 for f
in m3u8_formats
:
44 if f
[ 'vcodec' ] != 'none' and quality
in f
[ 'url' ]:
45 http_url
= ' %s%s .mp4' % ( self
._ HOST
, quality
)
47 urlh
= self
._ request
_ webpage
(
48 HEADRequest ( http_url
), quality
,
49 note
= 'Check filesize' , fatal
= False )
52 del http_f
[ 'manifest_url' ]
54 'format_id' : http_f
[ 'format_id' ]. replace ( 'hls-' , 'https-' ),
57 'filesize_approx' : int_or_none ( urlh
. headers
. get ( 'Content-Length' , None )),
62 def _real_extract ( self
, url
):
63 video_id
= self
._ match
_ id
( url
)
65 if not url
. startswith ( 'http' ):
66 url
= ' %s // %s ' % ( self
. http_scheme (), url
)
68 webpage
= self
._ download
_ webpage
( url
, video_id
)
69 video_path
= self
._ search
_ regex
( r
'(/content/.*?).mp4' , webpage
, 'video_path' )
71 formats
= self
._ extract
_ mpd
_ formats
(
72 f
' {self._HOST} /local/dash/, {video_path} .mp4.urlset/manifest.mpd' ,
73 video_id
, mpd_id
= 'dash' , fatal
= False )
74 m3u8_formats
= self
._ extract
_ m
3u8_ formats
(
75 f
' {self._HOST} /local/hls/, {video_path} .mp4.urlset/master.m3u8' ,
76 video_id
, 'mp4' , m3u8_id
= 'hls' , fatal
= False )
77 formats
. extend ( m3u8_formats
)
79 for q
in filter ( None , video_path
. split ( ',' )):
80 http_f
= self
._ generate
_ mp
4_u rl
( q
, m3u8_formats
)
82 formats
. append ( http_f
)
84 self
._ sort
_ formats
( formats
)
88 'title' : self
._ og
_ search
_ title
( webpage
, default
= None ),
89 'description' : self
._ og
_ search
_ description
( webpage
, default
= None ),
90 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
, default
= None ),
92 'upload_date' : unified_strdate ( self
._ search
_ regex
( r
'datetime="(.+?)"' , webpage
, 'upload_date' , fatal
= False ))
96 class LA7PodcastEpisodeIE ( InfoExtractor
):
97 IE_NAME
= 'la7.it:pod:episode'
98 _VALID_URL
= r
'''(?x)(https?://)?
99 (?:www\.)?la7\.it/[^/]+/podcast/([^/]+-)?(?P<id>\d+)'''
102 'url' : 'https://www.la7.it/voicetown/podcast/la-carezza-delle-memoria-di-carlo-verdone-23-03-2021-371497' ,
103 'md5' : '7737d4d79b3c1a34b3de3e16297119ed' ,
107 'title' : '"La carezza delle memoria" di Carlo Verdone' ,
108 'description' : 'md5:5abf07c3c551a687db80af3f9ceb7d52' ,
109 'thumbnail' : 'https://www.la7.it/sites/default/files/podcast/371497.jpg' ,
110 'upload_date' : '20210323' ,
114 'url' : 'https://www.la7.it/embed/podcast/371497' ,
115 'only_matching' : True ,
117 # date already in the title
118 'url' : 'https://www.la7.it/propagandalive/podcast/lintervista-di-diego-bianchi-ad-annalisa-cuzzocrea-puntata-del-1932021-20-03-2021-371130' ,
119 'only_matching' : True ,
121 # title same as show_title
122 'url' : 'https://www.la7.it/otto-e-mezzo/podcast/otto-e-mezzo-26-03-2021-372340' ,
123 'only_matching' : True ,
126 def _extract_info ( self
, webpage
, video_id
= None , ppn
= None ):
128 video_id
= self
._ search
_ regex
(
129 r
'data-nid=([\' "])(?P<vid>\d+)\1',
130 webpage, 'video_id', group='vid')
132 media_url = self._search_regex(
133 (r'src:\s*([ \' " ])( ?P
< url
>.+ ?mp3
.+ ?
) \
1 ',
134 r' data
- podcast
=([ \' "])(?P<url>.+?mp3.+?)\1'),
135 webpage, 'media_url', group='url')
136 ext = determine_ext(media_url)
142 self._sort_formats(formats)
144 title = self._html_search_regex(
145 (r'<div class=" title
">(?P<title>.+?)</',
146 r'<title>(?P<title>[^<]+)</title>',
147 r'title:\s*([ \' " ])( ?P
< title
>.+ ?
) \
1 '),
148 webpage, ' title
', group=' title
')
151 self._html_search_regex(
152 (r' < div
class = "description" >(.+ ?
)</ div
> ',
153 r' < div
class = "description-mobile" >(.+ ?
)</ div
> ',
154 r' < div
class = "box-txt" >([ ^
<]+ ?
)</ div
> ',
155 r' < div
class = "field-content" >< p
>(.+ ?
)</ p
></ div
> '),
156 webpage, ' description
', default=None)
157 or self._html_search_meta(' description
', webpage))
159 thumb = self._html_search_regex(
160 (r' < div
class = "podcast-image" >< img src
= "(.+?)" ></ div
> ',
161 r' < div
class = "container-embed" [ ^
<]+ url\
((.+ ?
) \
); ">',
162 r'<div class=" field
- content
"><img src=" (.+ ?
) "'),
163 webpage, 'thumbnail', fatal=False, default=None)
165 duration = parse_duration(self._html_search_regex(
166 r'<span class=" ( ?
: durata|duration
) ">([\d:]+)</span>',
167 webpage, 'duration', fatal=False, default=None))
169 date = self._html_search_regex(
170 r'class=" data
">\s*(?:<span>)?([\d\.]+)\s*</',
171 webpage, 'date', default=None)
173 date_alt = self._search_regex(
174 r'(\d+[\./]\d+[\./]\d+)', title, 'date_alt', default=None)
175 ppn = ppn or self._search_regex(
176 r'ppN:\s*([ \' " ])( ?P
< ppn
>.+ ?
) \
1 ',
177 webpage, ' ppn
', group=' ppn
', default=None)
178 # if the date is not in the title
179 # and title is the same as the show_title
180 # add the date to the title
181 if date and not date_alt and ppn and ppn.lower() == title.lower():
182 title += ' del %s ' % date
186 ' description
': description,
187 ' duration
': float_or_none(duration),
190 ' upload_date
': unified_strdate(date),
193 def _real_extract(self, url):
194 video_id = self._match_id(url)
195 webpage = self._download_webpage(url, video_id)
197 return self._extract_info(webpage, video_id)
200 class LA7PodcastIE(LA7PodcastEpisodeIE):
201 IE_NAME = ' la7
. it
: podcast
'
202 _VALID_URL = r' ( https?
://) ?
( www\
.) ?la7\
. it
/( ?P
< id >[ ^
/]+)/ podcast
/ ?
( ?
: $|
[ #?])'
205 'url' : 'https://www.la7.it/propagandalive/podcast' ,
207 'id' : 'propagandalive' ,
208 'title' : "Propaganda Live" ,
210 'playlist_count' : 10 ,
213 def _real_extract ( self
, url
):
214 playlist_id
= self
._ match
_ id
( url
)
215 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
218 self
._ html
_ search
_ regex
(
219 r
'<h1.*?>(.+?)</h1>' , webpage
, 'title' , fatal
= False , default
= None )
220 or self
._ og
_ search
_ title
( webpage
))
221 ppn
= self
._ search
_ regex
(
222 r
'window\.ppN\s*=\s*([\' "])(?P<ppn>.+?)\1',
223 webpage, 'ppn', group='ppn', default=None)
226 for episode in re.finditer(
227 r'<div class=" container
- podcast
- property ">([\s\S]+?)(?:</div>\s*) {3} ',
229 entries.append(self._extract_info(episode.group(1), ppn=ppn))
231 return self.playlist_result(entries, playlist_id, title)