3 from .common
import InfoExtractor
4 from ..networking
import HEADRequest
5 from ..utils
import float_or_none
, int_or_none
, parse_duration
, unified_strdate
8 class LA7IE(InfoExtractor
):
10 _VALID_URL
= r
'''(?x)https?://(?:
11 (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video|news)/|
12 tg\.la7\.it/repliche-tgla7\?id=
16 # single quality video
17 'url': 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722',
18 'md5': '8b613ffc0c4bf9b9e377169fc19c214c',
20 'id': 'inccool8-02-10-2015-163722',
23 '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',
24 'thumbnail': 're:^https?://.*',
25 'upload_date': '20151002',
29 # multiple quality video
30 'url': 'https://www.la7.it/calcio-femminile/news/il-gol-di-lindsey-thomas-fiorentina-vs-milan-serie-a-calcio-femminile-26-11-2022-461736',
31 'md5': 'd2370e78f75e8d1238cb3a0db9a2eda3',
33 'id': 'il-gol-di-lindsey-thomas-fiorentina-vs-milan-serie-a-calcio-femminile-26-11-2022-461736',
35 'title': 'Il gol di Lindsey Thomas | Fiorentina vs Milan | Serie A Calcio Femminile',
36 'description': 'Il gol di Lindsey Thomas | Fiorentina vs Milan | Serie A Calcio Femminile',
37 'thumbnail': 're:^https?://.*',
38 'upload_date': '20221126',
42 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
43 'only_matching': True,
45 _HOST
= 'https://awsvodpkg.iltrovatore.it'
47 def _generate_mp4_url(self
, quality
, m3u8_formats
):
48 for f
in m3u8_formats
:
49 if f
['vcodec'] != 'none' and quality
in f
['url']:
50 http_url
= f
'{self._HOST}{quality}.mp4'
52 urlh
= self
._request
_webpage
(
53 HEADRequest(http_url
), quality
,
54 note
='Check filesize', fatal
=False)
57 del http_f
['manifest_url']
59 'format_id': http_f
['format_id'].replace('hls-', 'https-'),
62 'filesize_approx': int_or_none(urlh
.headers
.get('Content-Length', None)),
67 def _real_extract(self
, url
):
68 video_id
= self
._match
_id
(url
)
69 webpage
= self
._download
_webpage
(url
, video_id
)
71 if re
.search(r
'(?i)(drmsupport\s*:\s*true)\s*', webpage
):
72 self
.report_drm(video_id
)
74 video_path
= self
._search
_regex
(
75 r
'(/content/[\w/,]+?)\.mp4(?:\.csmil)?/master\.m3u8', webpage
, 'video_path')
77 formats
= self
._extract
_mpd
_formats
(
78 f
'{self._HOST}/local/dash/,{video_path}.mp4.urlset/manifest.mpd',
79 video_id
, mpd_id
='dash', fatal
=False)
80 m3u8_formats
= self
._extract
_m
3u8_formats
(
81 f
'{self._HOST}/local/hls/,{video_path}.mp4.urlset/master.m3u8',
82 video_id
, 'mp4', m3u8_id
='hls', fatal
=False)
83 formats
.extend(m3u8_formats
)
85 for q
in filter(None, video_path
.split(',')):
86 http_f
= self
._generate
_mp
4_url
(q
, m3u8_formats
)
88 formats
.append(http_f
)
92 'title': self
._og
_search
_title
(webpage
, default
=None),
93 'description': self
._og
_search
_description
(webpage
, default
=None),
94 'thumbnail': self
._og
_search
_thumbnail
(webpage
, default
=None),
96 'upload_date': unified_strdate(self
._search
_regex
(r
'datetime="(.+?)"', webpage
, 'upload_date', fatal
=False)),
100 class LA7PodcastEpisodeIE(InfoExtractor
):
101 IE_NAME
= 'la7.it:pod:episode'
102 _VALID_URL
= r
'https?://(?:www\.)?la7\.it/[^/]+/podcast/([^/]+-)?(?P<id>\d+)'
105 'url': 'https://www.la7.it/voicetown/podcast/la-carezza-delle-memoria-di-carlo-verdone-23-03-2021-371497',
106 'md5': '7737d4d79b3c1a34b3de3e16297119ed',
110 'title': '"La carezza delle memoria" di Carlo Verdone',
111 'description': 'md5:5abf07c3c551a687db80af3f9ceb7d52',
112 'thumbnail': 'https://www.la7.it/sites/default/files/podcast/371497.jpg',
113 'upload_date': '20210323',
117 'url': 'https://www.la7.it/embed/podcast/371497',
118 'only_matching': True,
120 # date already in the title
121 'url': 'https://www.la7.it/propagandalive/podcast/lintervista-di-diego-bianchi-ad-annalisa-cuzzocrea-puntata-del-1932021-20-03-2021-371130',
122 'only_matching': True,
124 # title same as show_title
125 'url': 'https://www.la7.it/otto-e-mezzo/podcast/otto-e-mezzo-26-03-2021-372340',
126 'only_matching': True,
129 def _extract_info(self
, webpage
, video_id
=None, ppn
=None):
131 video_id
= self
._search
_regex
(
132 r
'data-nid=([\'"])(?P<vid>\d+)\1',
133 webpage, 'video_id', group='vid')
135 media_url = self._search_regex(
136 (r'src\s*:\s*([\'"])(?P
<url
>\S
+?mp3
.+?
)\
1',
137 r'data
-podcast\s
*=\s
*([\'"])(?P<url>\S+?mp3.+?)\1'),
138 webpage, 'media_url', group='url')
141 'format_id': 'http-mp3',
147 title = self._html_search_regex(
148 (r'<div class="title
">(?P<title>.+?)</',
149 r'<title>(?P<title>[^<]+)</title>',
150 r'title:\s*([\'"])(?P
<title
>.+?
)\
1'),
151 webpage, 'title
', group='title
')
154 self._html_search_regex(
155 (r'<div
class="description">(.+?
)</div
>',
156 r'<div
class="description-mobile">(.+?
)</div
>',
157 r'<div
class="box-txt">([^
<]+?
)</div
>',
158 r'<div
class="field-content"><p
>(.+?
)</p
></div
>'),
159 webpage, 'description
', default=None)
160 or self._html_search_meta('description
', webpage))
162 thumb = self._html_search_regex(
163 (r'<div
class="podcast-image"><img src
="(.+?)"></div
>',
164 r'<div
class="container-embed"[^
<]+url\
((.+?
)\
);">',
165 r'<div class="field
-content
"><img src="(.+?
)"'),
166 webpage, 'thumbnail', fatal=False, default=None)
168 duration = parse_duration(self._html_search_regex(
169 r'<span class="(?
:durata|duration
)">([\d:]+)</span>',
170 webpage, 'duration', fatal=False, default=None))
172 date = self._html_search_regex(
173 r'class="data
">\s*(?:<span>)?([\d\.]+)\s*</',
174 webpage, 'date', default=None)
176 date_alt = self._search_regex(
177 r'(\d+[\./]\d+[\./]\d+)', title, 'date_alt', default=None)
178 ppn = ppn or self._search_regex(
179 r'ppN:\s*([\'"])(?P
<ppn
>.+?
)\
1',
180 webpage, 'ppn
', group='ppn
', default=None)
181 # if the date is not in the title
182 # and title is the same as the show_title
183 # add the date to the title
184 if date and not date_alt and ppn and ppn.lower() == title.lower():
185 title = f'{title}
del {date}
'
189 'description
': description,
190 'duration
': float_or_none(duration),
193 'upload_date
': unified_strdate(date),
196 def _real_extract(self, url):
197 video_id = self._match_id(url)
198 webpage = self._download_webpage(url, video_id)
200 return self._extract_info(webpage, video_id)
203 class LA7PodcastIE(LA7PodcastEpisodeIE): # XXX: Do not subclass from concrete IE
204 IE_NAME = 'la7
.it
:podcast
'
205 _VALID_URL = r'https?
://(?
:www\
.)?la7\
.it
/(?P
<id>[^
/]+)/podcast
/?
(?
:$|
[#?])'
208 'url': 'https://www.la7.it/propagandalive/podcast',
210 'id': 'propagandalive',
211 'title': 'Propaganda Live',
213 'playlist_mincount': 10,
216 def _real_extract(self
, url
):
217 playlist_id
= self
._match
_id
(url
)
218 webpage
= self
._download
_webpage
(url
, playlist_id
)
221 self
._html
_search
_regex
(
222 r
'<h1.*?>(.+?)</h1>', webpage
, 'title', fatal
=False, default
=None)
223 or self
._og
_search
_title
(webpage
))
224 ppn
= self
._search
_regex
(
225 r
'window\.ppN\s*=\s*([\'"])(?P<ppn>.+?)\1',
226 webpage, 'ppn', group='ppn', default=None)
229 for episode in re.finditer(
230 r'<div class="container
-podcast
-property">([\s\S]+?)(?:</div>\s*){3}',
232 entries.append(self._extract_info(episode.group(1), ppn=ppn))
234 return self.playlist_result(entries, playlist_id, title)