Files
images
plugins
archiver
disk_usage
favorites
file_properties
git_clone
movie_tv_info
py_run
searcher
template
translate
trasher
vod_thumbnailer
youtube_download
yt_dlp
__pyinstaller
compat
dependencies
downloader
extractor
__init__.py
_extractors.py
abc.py
abcnews.py
abcotvs.py
abematv.py
academicearth.py
acast.py
acfun.py
adn.py
adobeconnect.py
adobepass.py
adobetv.py
adultswim.py
aenetworks.py
aeonco.py
afreecatv.py
agora.py
airmozilla.py
airtv.py
aitube.py
aliexpress.py
aljazeera.py
allocine.py
alphaporno.py
alsace20tv.py
alura.py
amara.py
amazon.py
amazonminitv.py
amcnetworks.py
americastestkitchen.py
amp.py
anchorfm.py
angel.py
ant1newsgr.py
anvato.py
aol.py
apa.py
aparat.py
appleconnect.py
applepodcasts.py
appletrailers.py
archiveorg.py
arcpublishing.py
ard.py
arkena.py
arnes.py
arte.py
asiancrush.py
atresplayer.py
atscaleconf.py
atttechchannel.py
atvat.py
audimedia.py
audioboom.py
audiodraft.py
audiomack.py
audius.py
awaan.py
aws.py
azmedien.py
baidu.py
banbye.py
bandaichannel.py
bandcamp.py
bannedvideo.py
bbc.py
beatbump.py
beatport.py
beeg.py
behindkink.py
bellmedia.py
berufetv.py
bet.py
bfi.py
bfmtv.py
bibeltv.py
bigflix.py
bigo.py
bild.py
bilibili.py
biobiochiletv.py
biqle.py
bitchute.py
bitwave.py
blackboardcollaborate.py
bleacherreport.py
blerp.py
blogger.py
bloomberg.py
bokecc.py
bongacams.py
bostonglobe.py
box.py
boxcast.py
bpb.py
br.py
brainpop.py
bravotv.py
breakcom.py
breitbart.py
brightcove.py
bundesliga.py
businessinsider.py
buzzfeed.py
byutv.py
c56.py
cableav.py
callin.py
caltrans.py
cam4.py
camdemy.py
camfm.py
cammodels.py
camsoda.py
camtasia.py
camwithher.py
canalalpha.py
canalc2.py
canalplus.py
carambatv.py
cartoonnetwork.py
cbc.py
cbs.py
cbsinteractive.py
cbsnews.py
cbssports.py
ccc.py
ccma.py
cctv.py
cda.py
cellebrite.py
ceskatelevize.py
cgtn.py
channel9.py
charlierose.py
chaturbate.py
chilloutzone.py
chingari.py
chirbit.py
cinchcast.py
cinemax.py
cinetecamilano.py
ciscolive.py
ciscowebex.py
cjsw.py
clipchamp.py
cliphunter.py
clippit.py
cliprs.py
clipsyndicate.py
closertotruth.py
cloudflarestream.py
cloudy.py
clubic.py
clyp.py
cmt.py
cnbc.py
cnn.py
comedycentral.py
common.py
commonmistakes.py
commonprotocols.py
condenast.py
contv.py
corus.py
coub.py
cozytv.py
cpac.py
cracked.py
crackle.py
craftsy.py
crooksandliars.py
crowdbunker.py
crtvg.py
crunchyroll.py
cspan.py
ctsnews.py
ctv.py
ctvnews.py
cultureunplugged.py
curiositystream.py
cwtv.py
cybrary.py
dacast.py
daftsex.py
dailymail.py
dailymotion.py
dailywire.py
damtomo.py
daum.py
daystar.py
dbtv.py
dctp.py
deezer.py
defense.py
democracynow.py
detik.py
deuxm.py
dfb.py
dhm.py
digg.py
digitalconcerthall.py
digiteka.py
discogs.py
discovery.py
discoverygo.py
disney.py
dispeak.py
dlf.py
dlive.py
dotsub.py
douyutv.py
dplay.py
drbonanza.py
dreisat.py
drooble.py
dropbox.py
dropout.py
drtuber.py
drtv.py
dtube.py
duboku.py
dumpert.py
dvtv.py
dw.py
eagleplatform.py
ebaumsworld.py
ebay.py
echomsk.py
egghead.py
ehow.py
eighttracks.py
einthusan.py
eitb.py
elevensports.py
ellentube.py
elonet.py
elpais.py
embedly.py
engadget.py
epicon.py
epoch.py
eporner.py
eroprofile.py
ertgr.py
escapist.py
espn.py
esri.py
ettutv.py
europa.py
europeantour.py
eurosport.py
euscreen.py
expotv.py
expressen.py
extractors.py
extremetube.py
eyedotv.py
facebook.py
fancode.py
faz.py
fc2.py
fczenit.py
fifa.py
filmmodu.py
filmon.py
filmweb.py
firsttv.py
fivetv.py
flickr.py
folketinget.py
footyroom.py
formula1.py
fourtube.py
fourzerostudio.py
fox.py
fox9.py
foxgay.py
foxnews.py
foxsports.py
fptplay.py
franceinter.py
francetv.py
freesound.py
freespeech.py
freetv.py
frontendmasters.py
fujitv.py
funimation.py
funk.py
funker530.py
fusion.py
fuyintv.py
gab.py
gaia.py
gameinformer.py
gamejolt.py
gamespot.py
gamestar.py
gaskrank.py
gazeta.py
gdcvault.py
gedidigital.py
generic.py
genericembeds.py
genius.py
gettr.py
gfycat.py
giantbomb.py
giga.py
gigya.py
glide.py
globalplayer.py
globo.py
glomex.py
gmanetwork.py
go.py
godtube.py
gofile.py
golem.py
goodgame.py
googledrive.py
googlepodcasts.py
googlesearch.py
goplay.py
gopro.py
goshgay.py
gotostage.py
gputechconf.py
gronkh.py
groupon.py
harpodeon.py
hbo.py
hearthisat.py
heise.py
hellporno.py
helsinki.py
hgtv.py
hidive.py
historicfilms.py
hitbox.py
hitrecord.py
hketv.py
hollywoodreporter.py
holodex.py
hotnewhiphop.py
hotstar.py
howcast.py
howstuffworks.py
hrefli.py
hrfensehen.py
hrti.py
hse.py
huajiao.py
huffpost.py
hungama.py
huya.py
hypem.py
hypergryph.py
hytale.py
icareus.py
ichinanalive.py
idolplus.py
ign.py
iheart.py
iltalehti.py
imdb.py
imggaming.py
imgur.py
ina.py
inc.py
indavideo.py
infoq.py
instagram.py
internazionale.py
internetvideoarchive.py
iprima.py
iqiyi.py
islamchannel.py
israelnationalnews.py
itprotv.py
itv.py
ivi.py
ivideon.py
iwara.py
ixigua.py
izlesene.py
jable.py
jamendo.py
japandiet.py
jeuxvideo.py
jixie.py
joj.py
jove.py
jstream.py
jwplatform.py
kakao.py
kaltura.py
kanal2.py
kankanews.py
karaoketv.py
karrierevideos.py
keezmovies.py
kelbyone.py
khanacademy.py
kick.py
kicker.py
kickstarter.py
kinja.py
kinopoisk.py
kommunetv.py
kompas.py
konserthusetplay.py
koo.py
krasview.py
kth.py
ku6.py
kusi.py
kuwo.py
la7.py
laola1tv.py
lastfm.py
lbry.py
lci.py
lcp.py
lecture2go.py
lecturio.py
leeco.py
lefigaro.py
lego.py
lemonde.py
lenta.py
libraryofcongress.py
libsyn.py
lifenews.py
likee.py
limelight.py
linkedin.py
linuxacademy.py
liputan6.py
listennotes.py
litv.py
livejournal.py
livestream.py
livestreamfails.py
lnkgo.py
localnews8.py
lovehomeporn.py
lrt.py
lumni.py
lynda.py
m6.py
magellantv.py
magentamusik360.py
mailru.py
mainstreaming.py
malltv.py
mangomolo.py
manoto.py
manyvids.py
maoritv.py
markiza.py
massengeschmacktv.py
masters.py
matchtv.py
mdr.py
medaltv.py
mediaite.py
mediaklikk.py
medialaan.py
mediaset.py
mediasite.py
mediastream.py
mediaworksnz.py
medici.py
megaphone.py
megatvcom.py
meipai.py
melonvod.py
meta.py
metacafe.py
metacritic.py
mgoon.py
mgtv.py
miaopai.py
microsoftembed.py
microsoftstream.py
microsoftvirtualacademy.py
mildom.py
minds.py
ministrygrid.py
minoto.py
miomio.py
mirrativ.py
mirrorcouk.py
mit.py
mitele.py
mixch.py
mixcloud.py
mlb.py
mlssoccer.py
mnet.py
mocha.py
moevideo.py
mofosex.py
mojvideo.py
morningstar.py
motherless.py
motorsport.py
movieclips.py
moviepilot.py
moview.py
moviezine.py
movingimage.py
msn.py
mtv.py
muenchentv.py
murrtube.py
museai.py
musescore.py
musicdex.py
mwave.py
mxplayer.py
mychannels.py
myspace.py
myspass.py
myvi.py
myvideoge.py
myvidster.py
mzaalo.py
n1.py
nate.py
nationalgeographic.py
naver.py
nba.py
nbc.py
ndr.py
ndtv.py
nebula.py
nekohacker.py
nerdcubed.py
neteasemusic.py
netverse.py
netzkino.py
newgrounds.py
newspicks.py
newstube.py
newsy.py
nextmedia.py
nexx.py
nfb.py
nfhsnetwork.py
nfl.py
nhk.py
nhl.py
nick.py
niconico.py
ninecninemedia.py
ninegag.py
ninenow.py
nintendo.py
nitter.py
njpwworld.py
nobelprize.py
noice.py
nonktube.py
noodlemagazine.py
noovo.py
normalboots.py
nosnl.py
nosvideo.py
nova.py
novaplay.py
nowness.py
noz.py
npo.py
npr.py
nrk.py
nrl.py
ntvcojp.py
ntvde.py
ntvru.py
nubilesporn.py
nuevo.py
nuvid.py
nytimes.py
nzherald.py
nzonscreen.py
nzz.py
odatv.py
odkmedia.py
odnoklassniki.py
oftv.py
oktoberfesttv.py
olympics.py
on24.py
once.py
ondemandkorea.py
onefootball.py
onenewsnz.py
oneplace.py
onet.py
onionstudios.py
ooyala.py
opencast.py
openload.py
openrec.py
ora.py
orf.py
outsidetv.py
owncloud.py
packtpub.py
palcomp3.py
pandoratv.py
panopto.py
paramountplus.py
parler.py
parlview.py
patreon.py
pbs.py
pearvideo.py
peekvids.py
peertube.py
peertv.py
peloton.py
people.py
performgroup.py
periscope.py
pgatour.py
philharmoniedeparis.py
phoenix.py
photobucket.py
piapro.py
picarto.py
piksel.py
pinkbike.py
pinterest.py
pixivsketch.py
pladform.py
planetmarathi.py
platzi.py
playfm.py
playplustv.py
plays.py
playstuff.py
playsuisse.py
playtvak.py
playvid.py
playwire.py
pluralsight.py
plutotv.py
podbayfm.py
podchaser.py
podomatic.py
pokemon.py
pokergo.py
polsatgo.py
polskieradio.py
popcorntimes.py
popcorntv.py
porn91.py
porncom.py
pornez.py
pornflip.py
pornhd.py
pornhub.py
pornotube.py
pornovoisines.py
pornoxo.py
pr0gramm.py
prankcast.py
premiershiprugby.py
presstv.py
projectveritas.py
prosiebensat1.py
prx.py
puhutv.py
puls4.py
pyvideo.py
qdance.py
qingting.py
qqmusic.py
r7.py
radiko.py
radiobremen.py
radiocanada.py
radiode.py
radiofrance.py
radiojavan.py
radiokapital.py
radiozet.py
radlive.py
rai.py
raywenderlich.py
rbgtum.py
rbmaradio.py
rcs.py
rcti.py
rds.py
recurbate.py
redbee.py
redbulltv.py
reddit.py
redgifs.py
redtube.py
regiotv.py
rentv.py
restudy.py
reuters.py
reverbnation.py
rheinmaintv.py
rice.py
rmcdecouverte.py
rockstargames.py
rokfin.py
roosterteeth.py
rottentomatoes.py
rozhlas.py
rte.py
rtl2.py
rtlnl.py
rtnews.py
rtp.py
rtrfm.py
rts.py
rtvcplay.py
rtve.py
rtvnh.py
rtvs.py
rtvslo.py
ruhd.py
rule34video.py
rumble.py
rutube.py
rutv.py
ruutu.py
ruv.py
s4c.py
safari.py
saitosan.py
samplefocus.py
sapo.py
savefrom.py
sbs.py
screen9.py
screencast.py
screencastify.py
screencastomatic.py
scrippsnetworks.py
scrolller.py
scte.py
seeker.py
senalcolombia.py
senategov.py
sendtonews.py
servus.py
sevenplus.py
sexu.py
seznamzpravy.py
shahid.py
shared.py
sharevideos.py
shemaroome.py
showroomlive.py
sibnet.py
simplecast.py
sina.py
sixplay.py
skeb.py
sky.py
skyit.py
skylinewebcams.py
skynewsarabia.py
skynewsau.py
slideshare.py
slideslive.py
slutload.py
smotrim.py
snotr.py
sohu.py
sonyliv.py
soundcloud.py
soundgasm.py
southpark.py
sovietscloset.py
spankbang.py
spankwire.py
spiegel.py
spike.py
sport5.py
sportbox.py
sportdeutschland.py
spotify.py
spreaker.py
springboardplatform.py
sprout.py
srgssr.py
srmediathek.py
stacommu.py
stageplus.py
stanfordoc.py
startrek.py
startv.py
steam.py
stitcher.py
storyfire.py
streamable.py
streamcloud.py
streamcz.py
streamff.py
streetvoice.py
stretchinternet.py
stripchat.py
stv.py
substack.py
sunporno.py
sverigesradio.py
svt.py
swearnet.py
swrmediathek.py
syfy.py
syvdk.py
sztvhu.py
tagesschau.py
tass.py
tbs.py
tdslifeway.py
teachable.py
teachertube.py
teachingchannel.py
teamcoco.py
teamtreehouse.py
techtalks.py
ted.py
tele13.py
tele5.py
telebruxelles.py
telecaribe.py
telecinco.py
telegraaf.py
telegram.py
telemb.py
telemundo.py
telequebec.py
teletask.py
telewebion.py
tempo.py
tencent.py
tennistv.py
tenplay.py
testurl.py
tf1.py
tfo.py
theholetv.py
theintercept.py
theplatform.py
thestar.py
thesun.py
theta.py
theweatherchannel.py
thisamericanlife.py
thisav.py
thisoldhouse.py
thisvid.py
threeqsdn.py
threespeak.py
tiktok.py
tinypic.py
tmz.py
tnaflix.py
toggle.py
toggo.py
tokentube.py
tonline.py
toongoggles.py
toutv.py
toypics.py
traileraddict.py
triller.py
trilulilu.py
trovo.py
trtcocuk.py
trueid.py
trunews.py
truth.py
trutv.py
tube8.py
tubetugraz.py
tubitv.py
tumblr.py
tunein.py
tunepk.py
turbo.py
turner.py
tv2.py
tv24ua.py
tv2dk.py
tv2hu.py
tv4.py
tv5mondeplus.py
tv5unis.py
tva.py
tvanouvelles.py
tvc.py
tver.py
tvigle.py
tviplayer.py
tvland.py
tvn24.py
tvnet.py
tvnoe.py
tvnow.py
tvopengr.py
tvp.py
tvplay.py
tvplayer.py
tweakers.py
twentyfourvideo.py
twentymin.py
twentythreevideo.py
twitcasting.py
twitch.py
twitter.py
txxx.py
udemy.py
udn.py
ufctv.py
ukcolumn.py
uktvplay.py
umg.py
unistra.py
unity.py
unscripted.py
unsupported.py
uol.py
uplynk.py
urort.py
urplay.py
usanetwork.py
usatoday.py
ustream.py
ustudio.py
utreon.py
varzesh3.py
vbox7.py
veehd.py
veo.py
veoh.py
vesti.py
vevo.py
vgtv.py
vh1.py
vice.py
vidbit.py
viddler.py
videa.py
videocampus_sachsen.py
videodetective.py
videofyme.py
videoken.py
videomore.py
videopress.py
vidio.py
vidlii.py
viewlift.py
viidea.py
viki.py
vimeo.py
vimm.py
vimple.py
vine.py
viqeo.py
viu.py
vk.py
vocaroo.py
vodlocker.py
vodpl.py
vodplatform.py
voicerepublic.py
voicy.py
volejtv.py
voot.py
voxmedia.py
vrak.py
vrt.py
vrv.py
vshare.py
vtm.py
vuclip.py
vupload.py
vvvvid.py
vyborymos.py
vzaar.py
wakanim.py
walla.py
wasdtv.py
washingtonpost.py
wat.py
watchbox.py
watchindianporn.py
wdr.py
webcamerapl.py
webcaster.py
webofstories.py
weibo.py
weiqitv.py
weverse.py
wevidi.py
weyyak.py
whowatch.py
whyp.py
wikimedia.py
willow.py
wimbledon.py
wimtv.py
wistia.py
wordpress.py
worldstarhiphop.py
wppilot.py
wrestleuniverse.py
wsj.py
wwe.py
wykop.py
xanimu.py
xbef.py
xboxclips.py
xfileshare.py
xhamster.py
ximalaya.py
xinpianchang.py
xminus.py
xnxx.py
xstream.py
xtube.py
xuite.py
xvideos.py
xxxymovies.py
yahoo.py
yandexdisk.py
yandexmusic.py
yandexvideo.py
yapfiles.py
yappy.py
yesjapan.py
yinyuetai.py
yle_areena.py
ynet.py
youjizz.py
youku.py
younow.py
youporn.py
yourporn.py
yourupload.py
youtube.py
zaiko.py
zapiks.py
zattoo.py
zdf.py
zee5.py
zeenews.py
zhihu.py
zingmp3.py
zoom.py
zype.py
networking
postprocessor
utils
YoutubeDL.py
__init__.py
__main__.py
aes.py
cache.py
casefold.py
cookies.py
jsinterp.py
minicurses.py
options.py
plugins.py
socks.py
update.py
version.py
webvtt.py
__init__.py
__main__.py
download.sh
manifest.json
plugin.py
README.md
src
user_config
.gitignore
LICENSE
README.md
pyrightconfig.json
SolarFM/plugins/youtube_download/yt_dlp/extractor/mediaset.py
2023-08-13 20:13:21 -05:00

318 lines
13 KiB
Python

import functools
import re
from .theplatform import ThePlatformBaseIE
from ..utils import (
ExtractorError,
GeoRestrictedError,
int_or_none,
OnDemandPagedList,
try_get,
urljoin,
update_url_query,
)
class MediasetIE(ThePlatformBaseIE):
_TP_TLD = 'eu'
_GUID_RE = r'F[0-9A-Z]{15}'
_VALID_URL = rf'''(?x)
(?:
mediaset:|
https?://
(?:\w+\.)+mediaset\.it/
(?:
(?:video|on-demand|movie)/(?:[^/]+/)+[^/]+_|
player/(?:v\d+/)?index\.html\?\S*?\bprogramGuid=
)
)(?P<id>{_GUID_RE})
'''
_EMBED_REGEX = [
rf'<iframe[^>]+src=[\'"](?P<url>(?:https?:)?//(?:\w+\.)+mediaset\.it/player/(?:v\d+/)?index\.html\?\S*?programGuid={_GUID_RE})[\'"&]'
]
_TESTS = [{
# full episode
'url': 'https://mediasetinfinity.mediaset.it/video/mrwronglezionidamore/episodio-1_F310575103000102',
'md5': 'a7e75c6384871f322adb781d3bd72c26',
'info_dict': {
'id': 'F310575103000102',
'ext': 'mp4',
'title': 'Episodio 1',
'description': 'md5:e8017b7d7194e9bfb75299c2b8d81e02',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 2682.0,
'upload_date': '20210530',
'series': 'Mr Wrong - Lezioni d\'amore',
'timestamp': 1622413946,
'uploader': 'Canale 5',
'uploader_id': 'C5',
'season': 'Season 1',
'episode': 'Episode 1',
'season_number': 1,
'episode_number': 1,
'chapters': [{'start_time': 0.0, 'end_time': 439.88}, {'start_time': 439.88, 'end_time': 1685.84}, {'start_time': 1685.84, 'end_time': 2682.0}],
},
}, {
'url': 'https://mediasetinfinity.mediaset.it/video/matrix/puntata-del-25-maggio_F309013801000501',
'md5': '1276f966ac423d16ba255ce867de073e',
'info_dict': {
'id': 'F309013801000501',
'ext': 'mp4',
'title': 'Puntata del 25 maggio',
'description': 'md5:ee2e456e3eb1dba5e814596655bb5296',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 6565.008,
'upload_date': '20200903',
'series': 'Matrix',
'timestamp': 1599172492,
'uploader': 'Canale 5',
'uploader_id': 'C5',
'season': 'Season 5',
'episode': 'Episode 5',
'season_number': 5,
'episode_number': 5,
'chapters': [{'start_time': 0.0, 'end_time': 3409.08}, {'start_time': 3409.08, 'end_time': 6565.008}],
},
}, {
# DRM
'url': 'https://mediasetinfinity.mediaset.it/movie/selvaggi/selvaggi_F006474501000101',
'info_dict': {
'id': 'F006474501000101',
'ext': 'mp4',
'title': 'Selvaggi',
'description': 'md5:cfdedbbfdd12d4d0e5dcf1fa1b75284f',
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 5233.01,
'upload_date': '20210729',
'timestamp': 1627594716,
'uploader': 'Cine34',
'uploader_id': 'B6',
'chapters': [{'start_time': 0.0, 'end_time': 1938.56}, {'start_time': 1938.56, 'end_time': 5233.01}],
},
'params': {
'ignore_no_formats_error': True,
},
'expected_warnings': [
'None of the available releases match the specified AssetType, ProtectionScheme, and/or Format preferences',
'Content behind paywall and DRM',
],
'skip': True,
}, {
# old domain
'url': 'https://www.mediasetplay.mediaset.it/video/mrwronglezionidamore/episodio-1_F310575103000102',
'only_matching': True,
}, {
# iframe
'url': 'https://static3.mediasetplay.mediaset.it/player/index.html?appKey=5ad3966b1de1c4000d5cec48&programGuid=FAFU000000665924&id=665924',
'only_matching': True,
}, {
'url': 'mediaset:FAFU000000665924',
'only_matching': True,
}]
_WEBPAGE_TESTS = [{
# Mediaset embed
'url': 'http://www.tgcom24.mediaset.it/politica/serracchiani-voglio-vivere-in-una-societa-aperta-reazioni-sproporzionate-_3071354-201702a.shtml',
'info_dict': {
'id': 'FD00000000004929',
'ext': 'mp4',
'title': 'Serracchiani: "Voglio vivere in una società aperta, con tutela del patto di fiducia"',
'duration': 67.013,
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Mediaset Play',
'uploader_id': 'QY',
'upload_date': '20201005',
'timestamp': 1601866168,
'chapters': [],
},
'params': {
'skip_download': True,
}
}, {
# WittyTV embed
'url': 'https://www.wittytv.it/mauriziocostanzoshow/ultima-puntata-venerdi-25-novembre/',
'info_dict': {
'id': 'F312172801000801',
'ext': 'mp4',
'title': 'Ultima puntata - Venerdì 25 novembre',
'description': 'Una serata all\'insegna della musica e del buonumore ma non priva di spunti di riflessione',
'duration': 6203.01,
'thumbnail': r're:^https?://.*\.jpg$',
'uploader': 'Canale 5',
'uploader_id': 'C5',
'upload_date': '20221126',
'timestamp': 1669428689,
'chapters': list,
'series': 'Maurizio Costanzo Show',
'season': 'Season 12',
'season_number': 12,
'episode': 'Episode 8',
'episode_number': 8,
},
'params': {
'skip_download': True,
}
}]
def _parse_smil_formats_and_subtitles(
self, smil, smil_url, video_id, namespace=None, f4m_params=None, transform_rtmp_url=None):
for video in smil.findall(self._xpath_ns('.//video', namespace)):
video.attrib['src'] = re.sub(r'(https?://vod05)t(-mediaset-it\.akamaized\.net/.+?.mpd)\?.+', r'\1\2', video.attrib['src'])
return super(MediasetIE, self)._parse_smil_formats_and_subtitles(
smil, smil_url, video_id, namespace, f4m_params, transform_rtmp_url)
def _check_drm_formats(self, tp_formats, video_id):
has_nondrm, drm_manifest = False, ''
for f in tp_formats:
if '_sampleaes/' in (f.get('manifest_url') or ''):
drm_manifest = drm_manifest or f['manifest_url']
f['has_drm'] = True
if not f.get('has_drm') and f.get('manifest_url'):
has_nondrm = True
nodrm_manifest = re.sub(r'_sampleaes/(\w+)_fp_', r'/\1_no_', drm_manifest)
if has_nondrm or nodrm_manifest == drm_manifest:
return
tp_formats.extend(self._extract_m3u8_formats(
nodrm_manifest, video_id, m3u8_id='hls', fatal=False) or [])
def _real_extract(self, url):
guid = self._match_id(url)
tp_path = f'PR1GhC/media/guid/2702976343/{guid}'
info = self._extract_theplatform_metadata(tp_path, guid)
formats = []
subtitles = {}
first_e = geo_e = None
asset_type = 'geoNo:HD,browser,geoIT|geoNo:HD,geoIT|geoNo:SD,browser,geoIT|geoNo:SD,geoIT|geoNo|HD|SD'
# TODO: fixup ISM+none manifest URLs
for f in ('MPEG4', 'MPEG-DASH', 'M3U'):
try:
tp_formats, tp_subtitles = self._extract_theplatform_smil(
update_url_query(f'http://link.theplatform.{self._TP_TLD}/s/{tp_path}', {
'mbr': 'true',
'formats': f,
'assetTypes': asset_type,
}), guid, f'Downloading {f.split("+")[0]} SMIL data')
except ExtractorError as e:
if e.orig_msg == 'None of the available releases match the specified AssetType, ProtectionScheme, and/or Format preferences':
e.orig_msg = 'This video is DRM protected'
if not geo_e and isinstance(e, GeoRestrictedError):
geo_e = e
if not first_e:
first_e = e
continue
self._check_drm_formats(tp_formats, guid)
formats.extend(tp_formats)
subtitles = self._merge_subtitles(subtitles, tp_subtitles)
# check for errors and report them
if (first_e or geo_e) and not formats:
raise geo_e or first_e
feed_data = self._download_json(
f'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2/guid/-/{guid}',
guid, fatal=False)
if feed_data:
publish_info = feed_data.get('mediasetprogram$publishInfo') or {}
thumbnails = feed_data.get('thumbnails') or {}
thumbnail = None
for key, value in thumbnails.items():
if key.startswith('image_keyframe_poster-'):
thumbnail = value.get('url')
break
info.update({
'description': info.get('description') or feed_data.get('description') or feed_data.get('longDescription'),
'uploader': publish_info.get('description'),
'uploader_id': publish_info.get('channel'),
'view_count': int_or_none(feed_data.get('mediasetprogram$numberOfViews')),
'thumbnail': thumbnail,
})
if feed_data.get('programType') == 'episode':
info.update({
'episode_number': int_or_none(
feed_data.get('tvSeasonEpisodeNumber')),
'season_number': int_or_none(
feed_data.get('tvSeasonNumber')),
'series': feed_data.get('mediasetprogram$brandTitle'),
})
info.update({
'id': guid,
'formats': formats,
'subtitles': subtitles,
})
return info
class MediasetShowIE(MediasetIE): # XXX: Do not subclass from concrete IE
_VALID_URL = r'''(?x)
(?:
https?://
(\w+\.)+mediaset\.it/
(?:
(?:fiction|programmi-tv|serie-tv|kids)/(?:.+?/)?
(?:[a-z-]+)_SE(?P<id>\d{12})
(?:,ST(?P<st>\d{12}))?
(?:,sb(?P<sb>\d{9}))?$
)
)
'''
_TESTS = [{
# TV Show webpage (general webpage)
'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/leiene_SE000000000061',
'info_dict': {
'id': '000000000061',
'title': 'Le Iene 2022/2023',
},
'playlist_mincount': 6,
}, {
# TV Show webpage (specific season)
'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/leiene_SE000000000061,ST000000002763',
'info_dict': {
'id': '000000002763',
'title': 'Le Iene 2021/2022',
},
'playlist_mincount': 7,
}, {
# TV Show specific playlist (with multiple pages)
'url': 'https://mediasetinfinity.mediaset.it/programmi-tv/leiene/iservizi_SE000000000061,ST000000002763,sb100013375',
'info_dict': {
'id': '100013375',
'title': 'I servizi',
},
'playlist_mincount': 50,
}]
_BY_SUBBRAND = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2?byCustomValue={subBrandId}{%s}&sort=:publishInfo_lastPublished|desc,tvSeasonEpisodeNumber|desc&range=%d-%d'
_PAGE_SIZE = 25
def _fetch_page(self, sb, page):
lower_limit = page * self._PAGE_SIZE + 1
upper_limit = lower_limit + self._PAGE_SIZE - 1
content = self._download_json(
self._BY_SUBBRAND % (sb, lower_limit, upper_limit), sb)
for entry in content.get('entries') or []:
yield self.url_result(
'mediaset:' + entry['guid'],
playlist_title=entry['mediasetprogram$subBrandDescription'])
def _real_extract(self, url):
playlist_id, st, sb = self._match_valid_url(url).group('id', 'st', 'sb')
if not sb:
page = self._download_webpage(url, st or playlist_id)
entries = [self.url_result(urljoin('https://mediasetinfinity.mediaset.it', url))
for url in re.findall(r'href="([^<>=]+SE\d{12},ST\d{12},sb\d{9})">[^<]+<', page)]
title = self._html_extract_title(page).split('|')[0].strip()
return self.playlist_result(entries, st or playlist_id, title)
entries = OnDemandPagedList(
functools.partial(self._fetch_page, sb),
self._PAGE_SIZE)
title = try_get(entries, lambda x: x[0]['playlist_title'])
return self.playlist_result(entries, sb, title)