KoD 1.7.1
This commit is contained in:
@@ -138,6 +138,7 @@ def newest(categoria):
|
||||
|
||||
|
||||
def check(item):
|
||||
item.contentType = 'tvshow'
|
||||
def get_season(pageData, seas_url, season):
|
||||
data = ''
|
||||
episodes = support.match(pageData if pageData else seas_url, patronBlock=patron_episode, patron=patron_option).matches
|
||||
@@ -155,7 +156,7 @@ def check(item):
|
||||
url = support.match(item, patron=r'<iframe id="iframeVid" width="[^"]+" height="[^"]+" src="([^"]+)" allowfullscreen').match
|
||||
seasons = support.match(url, patronBlock=patron_season, patron=patron_option)
|
||||
if not seasons.match:
|
||||
item.contentType = 'tvshow'
|
||||
item.contentType = 'movie'
|
||||
return findvideos(item)
|
||||
|
||||
data = ''
|
||||
|
||||
@@ -35,7 +35,9 @@ def mainlist(item):
|
||||
|
||||
def liveDict():
|
||||
livedict = {}
|
||||
for key in session.get(api + '/cms/routes/home?decorators=viewingHistory&include=default', headers=headers).json()['included']:
|
||||
|
||||
for key in session.get(api + '/cms/routes/canali?decorators=viewingHistory&include=default', headers=headers).json()['included']:
|
||||
|
||||
if key['type'] == 'channel' and key.get('attributes',{}).get('hasLiveStream', '') and 'Free' in key.get('attributes',{}).get('packages', []):
|
||||
title = key['attributes']['name']
|
||||
livedict[title] = {}
|
||||
|
||||
@@ -68,7 +68,7 @@ def episodios(item):
|
||||
data = support.match(item.url, headers=headers).data
|
||||
if 'accordion-item' in data:
|
||||
patronBlock = r'<span class="season[^>]*>\d+[^>]+>[^>]+>[^>]+>[^>]+>\D*(?:STAGIONE|Stagione)[ -]+(?P<lang>[a-zA-Z\- ]+)[^<]*</span>(?P<block>.*?)<div id="(?:season|disqus)'
|
||||
patron = r'<img src="(?P<thumb>[^"]+)">.*?<li class="season-no">(?P<season>\d+)(?:×|×|x)(?P<episode>\d+)[^<0-9]*<\/li>(?P<data>.*?javascript:;">(?P<title>[^<]+).*?</tbody>)'
|
||||
patron = r'<img src="(?P<thumb>[^"]+)"(?:[^>]*>){4}\s*<li class="season-no">(?P<season>\d+)(?:×|×|x)(?P<episode>\d+)[^<0-9]*<\/li>(?P<data>.*?javascript:;">(?P<title>[^<]+).*?</tbody>)'
|
||||
else:
|
||||
patronBlock = r'(?:STAGIONE|Stagione)(?:<[^>]+>)?\s*(?:(?P<lang>[A-Za-z- ]+))?(?P<block>.*?)(?: |<strong>|<div class="addtoany)'
|
||||
patron = r'(?:/>|p>)\s*(?P<season>\d+)(?:×|×|x)(?P<episode>\d+)[^<]+(?P<data>.*?)(?:<br|</p)'
|
||||
|
||||
+4
-1
@@ -84,6 +84,8 @@ def search(item, text):
|
||||
def peliculas(item):
|
||||
search = item.search
|
||||
disabletmdb = True
|
||||
addVideolibrary = False
|
||||
downloadEnabled = False
|
||||
action = 'episodios'
|
||||
patron = r'<a href="(?P<url>[^"]+)"[^>]+><div class="[^"]+" data-background-image="(?P<t>[^"]+)"></div><div class="titolo">\s*(?P<title>[^<]+)<'
|
||||
def itemHook(item):
|
||||
@@ -96,7 +98,7 @@ def peliculas(item):
|
||||
@support.scrape
|
||||
def episodios(item):
|
||||
data = support.match(item).data
|
||||
debug = True
|
||||
# debug = True
|
||||
action = 'play'
|
||||
if '>puntate<' in data:
|
||||
patronBlock = r'>puntate<(?P<block>.*?)home-block-outbrain'
|
||||
@@ -109,6 +111,7 @@ def episodios(item):
|
||||
patron = r'(?:<a href="(?P<url>[^"]+)">[^>]+><div class="[^"]+" data-background-image="(?P<t>[^"]*)">[^>]+>[^>]+>[^>]+>(?:[^>]+>)?(?:[^>]+>){6}?)\s*(?P<title>[^<]+)<(?:[^>]+>[^>]+>[^>]+><div class="data">(?P<date>[^<]+))?|class="heading">[^>]+>(?P<Title>[^<]+).*?window.shareUrl = "(?P<Url>[^"]+)".*?poster:\s*"(?P<Thumb>[^"]+)", title: "(?P<desc>[^"]+)"'
|
||||
patronNext = r'<a href="([^"]+)">›'
|
||||
addVideolibrary = False
|
||||
downloadEnabled = False
|
||||
|
||||
def itemHook(item):
|
||||
if item.Thumb: item.t = item.Thumb
|
||||
|
||||
@@ -8,6 +8,23 @@
|
||||
"categories": ["movie", "tvshow", "documentary", "live"],
|
||||
"not_active": ["include_in_newest"],
|
||||
"default_off": ["include_in_global_search"],
|
||||
"settings": [],
|
||||
"cloudflare": true
|
||||
"settings": [
|
||||
{
|
||||
"id": "mpd",
|
||||
"type": "bool",
|
||||
"label": "Preferisci mpd",
|
||||
"default": true,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "pagination",
|
||||
"type": "list",
|
||||
"label": "Pagination",
|
||||
"default": 1,
|
||||
"enabled": true,
|
||||
"visible": true,
|
||||
"lvalues": ["10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+259
-286
@@ -2,359 +2,332 @@
|
||||
# ------------------------------------------------------------
|
||||
# Canale per Mediaset Play
|
||||
# ------------------------------------------------------------
|
||||
from platformcode import logger
|
||||
import uuid
|
||||
|
||||
from platformcode import logger, config
|
||||
import uuid, datetime, xbmc
|
||||
|
||||
import requests, sys
|
||||
from core import support
|
||||
if sys.version_info[0] >= 3: from urllib.parse import urlencode, quote
|
||||
else: from urllib import urlencode, quote
|
||||
if sys.version_info[0] >= 3: from concurrent import futures
|
||||
else: from concurrent_py2 import futures
|
||||
from collections import OrderedDict
|
||||
if sys.version_info[0] >= 3:
|
||||
from urllib.parse import urlencode, quote
|
||||
else:
|
||||
from urllib import urlencode, quote
|
||||
|
||||
PAGINATION = 4
|
||||
host = 'https://www.mediasetplay.mediaset.it'
|
||||
loginUrl = 'https://api-ott-prod-fe.mediaset.net/PROD/play/idm/anonymous/login/v2.0'
|
||||
|
||||
host = ''
|
||||
post_url = '?assetTypes=HD,browser,widevine,geoIT|geoNo:HD,browser,geoIT|geoNo:HD,geoIT|geoNo:SD,browser,widevine,geoIT|geoNo:SD,browser,geoIT|geoNo:SD,geoIT|geoNo&auto=true&balance=true&format=smil&formats=MPEG-DASH,MPEG4,M3U&tracking=true'
|
||||
deviceid = '61d27df7-5cbf-4419-ba06-cfd27ecd4588'
|
||||
loginUrl = 'https://api-ott-prod-fe.mediaset.net/PROD/play/idm/anonymous/login/v1.0'
|
||||
loginData = {"cid": deviceid, "platform": "pc", "appName": "web/mediasetplay-web/d667681"}
|
||||
lic_url = 'https://widevine.entitlement.theplatform.eu/wv/web/ModularDrm/getRawWidevineLicense?releasePid=%s&account=http://access.auth.theplatform.com/data/Account/2702976343&schema=1.0&token={token}|Accept=*/*&Content-Type=&User-Agent=' + support.httptools.get_user_agent() + '|R{{SSM}}|'
|
||||
entry = 'https://api.one.accedo.tv/content/entry/{id}?locale=it'
|
||||
entries = 'https://api.one.accedo.tv/content/entries?id={id}&locale=it'
|
||||
clientid = 'f66e2a01-c619-4e53-8e7c-4761449dd8ee'
|
||||
|
||||
|
||||
loginData = {"client_id": clientid, "platform": "pc", "appName": "web//mediasetplay-web/5.1.493-plus-da8885b"}
|
||||
sessionUrl = "https://api.one.accedo.tv/session?appKey=59ad346f1de1c4000dfd09c5&uuid={uuid}&gid=default"
|
||||
|
||||
current_session = requests.Session()
|
||||
current_session.headers.update({'Content-Type': 'application/json', 'User-Agent': support.httptools.get_user_agent(), 'Referer': support.config.get_channel_url()})
|
||||
session = requests.Session()
|
||||
session.headers.update({'Content-Type': 'application/json', 'User-Agent': support.httptools.get_user_agent(), 'Referer': host})
|
||||
|
||||
entry = 'https://api.one.accedo.tv/content/entry/{id}?locale=it'
|
||||
entries = 'https://api.one.accedo.tv/content/entries?id={id}&locale=it'
|
||||
|
||||
# login anonimo
|
||||
res = current_session.post(loginUrl, json=loginData, verify=False)
|
||||
Token = res.headers['t-cts']
|
||||
current_session.headers.update({'t-apigw': res.headers['t-apigw'], 't-cts': Token})
|
||||
lic_url = lic_url.format(token=Token)
|
||||
tracecid = res.json()['response']['traceCid']
|
||||
cwid = res.json()['response']['cwId']
|
||||
res = session.post(loginUrl, json=loginData, verify=False)
|
||||
Token = res.json()['response']['beToken']
|
||||
sid = res.json()['response']['sid']
|
||||
session.headers.update({'authorization': 'Bearer ' + Token})
|
||||
|
||||
# sessione
|
||||
res = current_session.get(sessionUrl.format(uuid=str(uuid.uuid4())), verify=False)
|
||||
current_session.headers.update({'x-session': res.json()['sessionKey']})
|
||||
sessionKey = session.get(sessionUrl.format(uuid=str(uuid.uuid4())), verify=False).json()['sessionKey']
|
||||
session.headers.update({'x-session': sessionKey})
|
||||
|
||||
cdict = {'CWFILMTOPVIEWED':'filmPiuVisti24H',
|
||||
'CWFILMCOMEDY':'filmCommedia',
|
||||
'CWFILMACTION':'filmAzioneThrillerAvventura',
|
||||
'CWFILMDRAMATIC':'filmDrammatico',
|
||||
'CWFILMSENTIMENTAL':'filmSentimentale',
|
||||
'CWFILMCLASSIC':'filmClassici',
|
||||
'personToContentFilm':'personToContentFilm',
|
||||
'CWHOMEFICTIONNOWELITE':'stagioniFictionSerieTvSezione',
|
||||
'CWFICTIONSOAP':'mostRecentSoapOpera',
|
||||
'CWFICTIONDRAMATIC':'stagioniFictionDrammatico',
|
||||
'CWFICTIONPOLICE':'stagioniFictionPoliziesco',
|
||||
'CWFICTIONCOMEDY':'stagioniFictionCommedia',
|
||||
'CWFICTIONSITCOM':'stagioniFictionSitCom',
|
||||
'CWFICTIONSENTIMENTAL':'stagioniFictionSentimentale',
|
||||
'CWFICTIONBIOGRAPHICAL':'stagioniFictionBiografico',
|
||||
'CWPROGTVPRIME':'stagioniPrimaSerata',
|
||||
'CWPROGTVDAY':'stagioniDaytime',
|
||||
'CWPROGTVTOPVIEWED':'programmiTvClip24H',
|
||||
'CWPROGTVTALENT':'stagioniReality',
|
||||
'CWPROGTVVARIETY':'stagioniVarieta',
|
||||
'CWPROGTVTALK':'stagioniTalk',
|
||||
'CWPROGTVTG':'mostRecentTg',
|
||||
'CWPROGTVSPORT':'mostRecentSport',
|
||||
'CWPROGTVMAGAZINE':'stagioniCucinaLifestyle',
|
||||
'CWDOCUMOSTRECENT':'mostRecentDocumentariFep',
|
||||
'CWDOCUTOPVIEWED':'stagioniDocumentari',
|
||||
'CWDOCUSPAZIO':'documentariSpazio',
|
||||
'CWDOCUNATURANIMALI':'documentariNatura',
|
||||
'CWDOCUSCIENZATECH':'documentariScienza',
|
||||
'CWDOCUBIOSTORIE':'documentariBioStoria',
|
||||
'CWDOCUINCHIESTE':'documentariInchiesta',
|
||||
'CWFILMDOCU':'filmDocumentario',
|
||||
'CWKIDSBOINGFORYOU':'kidsBoing',
|
||||
'CWKIDSCARTOONITO':'kidsCartoonito',
|
||||
'CWKIDSMEDIASETBRAND':'kidsMediaset',
|
||||
'CWENABLERKIDS':'stagioniKids'}
|
||||
pagination = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100][config.get_setting('pagination', 'mediasetplay')]
|
||||
|
||||
|
||||
@support.menu
|
||||
def mainlist(item):
|
||||
top = [('Dirette {bold}', ['https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-stations?sort=ShortTitle', 'live'])]
|
||||
top = [('Dirette {bold}', ['', 'live'])]
|
||||
|
||||
menu = [('Film {bullet bold}', ['5acfcbc423eec6000d64a6bb', 'menu', ['Tutti','all','searchMovie']]),
|
||||
('Fiction / Serie TV {bullet bold}', ['5acfcb3c23eec6000d64a6a4', 'menu', ['Tutte','all','searchStagioni'], 'tvshow']),
|
||||
('Programmi TV{ bullet bold}', ['5acfc8011de1c4000b6ec953', 'menu', ['Tutti','all','searchStagioni'], 'tvshow']),
|
||||
('Documentari {bullet bold}', ['5bfd17c423eec6001aec49f9', 'menu', ['Tutti','all',''], 'undefined']),
|
||||
('Kids {bullet bold}', ['5acfcb8323eec6000d64a6b3', 'menu',['Tutti','all',''], 'undefined']),
|
||||
('Family {bullet bold}', ['5e662d01a0e845001d56875b', 'menu',['Tutti','all',''], 'undefined']),
|
||||
]
|
||||
menu = [('Film {bullet bold}', ['/cinema', 'peliculas', {'uxReference':'filmUltimiArrivi'}, 'movie']),
|
||||
('Fiction / Serie TV {bullet bold}', ['/fiction', 'menu', '5acfcb3c23eec6000d64a6a4', 'tvshow']),
|
||||
('Programmi TV{ bullet bold}', ['/programmitv', 'menu', '5acfc8011de1c4000b6ec953', 'tvshow']),
|
||||
('Documentari {bullet bold}', ['/documentari', 'menu', '5bfd17c423eec6001aec49f9', 'undefined']),
|
||||
('Kids {bullet bold}', ['/kids', 'menu', '5acfcb8323eec6000d64a6b3', 'undefined'])]
|
||||
|
||||
search = ''
|
||||
return locals()
|
||||
|
||||
def menu(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
res = get_from_id(item)
|
||||
for it in res:
|
||||
if 'uxReference' in it:
|
||||
itemlist.append(item.clone(title=support.typo(it['title'], 'bullet bold'),
|
||||
url= it['landingUrl'],
|
||||
args={'uxReference':it.get('uxReferenceV2', ''), 'params':it.get('uxReferenceV2Params', ''), 'feed':it.get('feedurlV2','')},
|
||||
action='peliculas'))
|
||||
return itemlist
|
||||
|
||||
|
||||
def live(item):
|
||||
itemlist = []
|
||||
|
||||
res = session.get('https://static3.mediasetplay.mediaset.it/apigw/nownext/nownext.json').json()['response']
|
||||
allguide = res['listings']
|
||||
stations = res['stations']
|
||||
|
||||
for it in stations.values():
|
||||
plot = ''
|
||||
title = it['title']
|
||||
url = 'https:' + it['mediasetstation$pageUrl']
|
||||
if 'plus' in title.lower() or 'premium' in title.lower(): continue
|
||||
if it['callSign'] in allguide:
|
||||
|
||||
guide = allguide[it['callSign']]
|
||||
plot = '[B]{}[/B]\n{}\n\nA Seguire:\n[B]{}[/B]\n{}'.format(guide['currentListing']['mediasetlisting$epgTitle'],
|
||||
guide['currentListing']['description'],
|
||||
guide['nextListing']['mediasetlisting$epgTitle'],
|
||||
guide['nextListing']['description'],)
|
||||
|
||||
itemlist.append(item.clone(title=support.typo(title, 'bold'), fulltitle=title, callSign=it['callSign'], urls=guide['tuningInstruction']['urn:theplatform:tv:location:any'], plot=plot, url=url, action='play', forcethumb=True))
|
||||
|
||||
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
||||
support.thumb(itemlist, live=True)
|
||||
return itemlist
|
||||
|
||||
|
||||
def search(item, text):
|
||||
itemlist = []
|
||||
logger.debug(text)
|
||||
item.search = text
|
||||
item.args = {'uxReference':'main', 'params':'channel≈', 'query':text}
|
||||
|
||||
try:
|
||||
itemlist = peliculas(item)
|
||||
return peliculas(item)
|
||||
# Continua la ricerca in caso di errore
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
support.logger.error("%s" % line)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def menu(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
if item.url:
|
||||
json = get_from_id(item)
|
||||
for it in json:
|
||||
if 'uxReference' in it: itemlist.append(
|
||||
item.clone(title=support.typo(it['title'], 'bullet bold'), url= it['landingUrl'], ref=it['uxReference'], args='', action='peliculas'))
|
||||
return itemlist
|
||||
|
||||
|
||||
def liveDict():
|
||||
livedict = OrderedDict({})
|
||||
json = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-stations?sort=ShortTitle').json()['entries']
|
||||
for it in json:
|
||||
urls = []
|
||||
if it.get('tuningInstruction') and not it.get('mediasetstation$digitalOnly'):
|
||||
guide=current_session.get('https://static3.mediasetplay.mediaset.it/apigw/nownext/' + it['callSign'] + '.json').json()['response']
|
||||
for key in it['tuningInstruction']['urn:theplatform:tv:location:any']:
|
||||
urls += key['publicUrls']
|
||||
title = it['title']
|
||||
livedict[title] = {}
|
||||
livedict[title]['urls'] = urls
|
||||
livedict[title]['plot'] = support.typo(guide['currentListing']['mediasetlisting$epgTitle'],'bold') + '\n' + guide['currentListing']['mediasetlisting$shortDescription'] + '\n' + guide['currentListing']['description'] + '\n\n' + support.typo('A Seguire:' + guide['nextListing']['mediasetlisting$epgTitle'], 'bold')
|
||||
return livedict
|
||||
|
||||
|
||||
def live(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
for key, value in liveDict().items():
|
||||
itemlist.append(item.clone(title=support.typo(key, 'bold'),
|
||||
fulltitle=key,
|
||||
show=key,
|
||||
contentTitle=key,
|
||||
forcethumb=True,
|
||||
urls=value['urls'],
|
||||
plot=value['plot'],
|
||||
action='play',
|
||||
no_return=True))
|
||||
return support.thumb(itemlist, live=True)
|
||||
return []
|
||||
|
||||
|
||||
def peliculas(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
titlelist = []
|
||||
contentType = ''
|
||||
if item.text:
|
||||
json = []
|
||||
itlist = []
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
for arg in ['searchMovie', 'searchStagioni', 'searchClip']:
|
||||
item.args = ['', 'search', arg]
|
||||
itlist += [executor.submit(get_programs, item)]
|
||||
for res in futures.as_completed(itlist):
|
||||
json += res.result()
|
||||
else:
|
||||
json = get_programs(item)
|
||||
for it in json:
|
||||
if item.search.lower() in it['title'].lower() and it['title'] not in titlelist:
|
||||
titlelist.append(it['title'])
|
||||
if 'media' in it:
|
||||
action = 'findvideos'
|
||||
contentType = 'movie'
|
||||
urls = []
|
||||
for key in it['media']:
|
||||
urls.append(key['publicUrl'])
|
||||
res = get_programs(item)
|
||||
video_id= ''
|
||||
|
||||
for it in res['items']:
|
||||
if not 'MediasetPlay_ANY' in it.get('mediasetprogram$channelsRights',['MediasetPlay_ANY']): continue
|
||||
thumb = ''
|
||||
fanart = ''
|
||||
contentSerieName = ''
|
||||
url = 'https:'+ it.get('mediasettvseason$pageUrl', it.get('mediasetprogram$videoPageUrl', it.get('mediasetprogram$pageUrl')))
|
||||
title = it.get('mediasetprogram$brandTitle', it.get('title'))
|
||||
title2 = it['title']
|
||||
if title != title2:
|
||||
title = '{} - {}'.format(title, title2)
|
||||
plot = it.get('longDescription', it.get('description', it.get('mediasettvseason$brandDescription', '')))
|
||||
|
||||
if it.get('seriesTitle') or it.get('seriesTvSeasons'):
|
||||
contentSerieName = it.get('seriesTitle', it.get('title'))
|
||||
contentType = 'tvshow'
|
||||
action = 'epmenu'
|
||||
else:
|
||||
contentType = 'movie'
|
||||
video_id = it['guid']
|
||||
action = 'play'
|
||||
for k, v in it['thumbnails'].items():
|
||||
if 'image_vertical' in k and not thumb:
|
||||
thumb = v['url'].replace('.jpg', '@3.jpg')
|
||||
if 'image_header_poster' in k and not fanart:
|
||||
fanart = v['url'].replace('.jpg', '@3.jpg')
|
||||
if thumb and fanart:
|
||||
break
|
||||
|
||||
itemlist.append(item.clone(title=support.typo(title, 'bold'),
|
||||
fulltitle=title,
|
||||
contentTitle=title,
|
||||
contentSerieName=contentSerieName,
|
||||
action=action,
|
||||
contentType=contentType,
|
||||
thumbnail=thumb,
|
||||
fanart=fanart,
|
||||
plot=plot,
|
||||
url=url,
|
||||
video_id=video_id,
|
||||
seriesid = it.get('seriesTvSeasons', it.get('id','')),
|
||||
disable_videolibrary = True,
|
||||
forcethumb=True))
|
||||
if res['next']:
|
||||
item.page = res['next']
|
||||
support.nextPage(itemlist, item)
|
||||
|
||||
else:
|
||||
action = 'epmenu'
|
||||
contentType = 'tvshow'
|
||||
urls = it['mediasetprogram$brandId']
|
||||
if urls:
|
||||
title = it['mediasetprogram$brandTitle'] + ' - ' if 'mediasetprogram$brandTitle' in it and it['mediasetprogram$brandTitle'] != it['title'] else ''
|
||||
itemlist.append(
|
||||
item.clone(channel=item.channel,
|
||||
action=action,
|
||||
title=support.typo(title + it['title'], 'bold'),
|
||||
fulltitle=it['title'],
|
||||
show=it['title'],
|
||||
contentType=contentType if contentType else item.contentType,
|
||||
contentTitle=it['title'] if 'movie' in [contentType, item.contentType] else '',
|
||||
contentSerieName=it['title'] if 'tvshow' in [contentType, item.contentType] else '',
|
||||
thumbnail=it['thumbnails']['image_vertical-264x396']['url'] if 'image_vertical-264x396' in it['thumbnails'] else '',
|
||||
fanart=it['thumbnails']['image_keyframe_poster-1280x720']['url'] if 'image_keyframe_poster-1280x720' in it['thumbnails'] else '',
|
||||
plot=it['longDescription'] if 'longDescription' in it else it['description'] if 'description' in it else '',
|
||||
urls=urls,
|
||||
seriesid = it.get('seriesId',''),
|
||||
url=it['mediasetprogram$pageUrl'],
|
||||
forcethumb=True,
|
||||
no_return=True))
|
||||
return itemlist
|
||||
|
||||
|
||||
def epmenu(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
|
||||
epUrl = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-subbrands-v2?byTvSeasonId={}&sort=mediasetprogram$order'
|
||||
|
||||
if item.seriesid:
|
||||
seasons = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-tv-seasons?bySeriesId=' + item.seriesid).json()['entries']
|
||||
for season in seasons:
|
||||
if 'mediasettvseason$brandId' in season and 'mediasettvseason$displaySeason' in season:
|
||||
if type(item.seriesid) == list:
|
||||
res = []
|
||||
for s in item.seriesid:
|
||||
itemlist.append(
|
||||
item.clone(seriesid = s['id'],
|
||||
title=support.typo(s['title'], 'bold')))
|
||||
if len(itemlist) == 1: return epmenu(itemlist[0])
|
||||
else:
|
||||
res = requests.get(epUrl.format(item.seriesid)).json()['entries']
|
||||
for it in res:
|
||||
itemlist.append(
|
||||
item.clone(seriesid = '',
|
||||
title=support.typo(season['mediasettvseason$displaySeason'], 'bold'),
|
||||
urls=season['mediasettvseason$brandId']))
|
||||
itemlist = sorted(itemlist, key=lambda it: it.title, reverse=True)
|
||||
if len(itemlist) == 1: return epmenu(itemlist[0])
|
||||
if not itemlist:
|
||||
entries = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-brands?byCustomValue={brandId}{' + item.urls + '}').json()['entries']
|
||||
for entry in entries:
|
||||
if 'mediasetprogram$subBrandId' in entry:
|
||||
itemlist.append(
|
||||
item.clone(action='episodios',
|
||||
title=support.typo(entry['description'], 'bold'),
|
||||
url=entry['mediasetprogram$subBrandId'],
|
||||
order=entry.get('mediasetprogram$order',0)))
|
||||
if len(itemlist) == 1: return episodios(itemlist[0])
|
||||
itemlist = sorted(itemlist, key=lambda it: it.order)
|
||||
return itemlist
|
||||
title=support.typo(it['description'], 'bold'),
|
||||
subbrand=it['mediasetprogram$subBrandId'],
|
||||
action='episodios'))
|
||||
itemlist = sorted(itemlist, key=lambda it: it.title, reverse=True)
|
||||
if len(itemlist) == 1: return episodios(itemlist[0])
|
||||
|
||||
return itemlist
|
||||
|
||||
def episodios(item):
|
||||
logger.debug()
|
||||
# create month list
|
||||
months = []
|
||||
try:
|
||||
for month in range(21, 33): months.append(xbmc.getLocalizedString(month))
|
||||
except: # per i test, xbmc.getLocalizedString non è supportato
|
||||
for month in range(21, 33): months.append('dummy')
|
||||
|
||||
itemlist = []
|
||||
if not item.nextIndex: item.nextIndex = 1
|
||||
res = requests.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2?byCustomValue={subBrandId}{' + item.subbrand +'}&sort=:publishInfo_lastPublished|asc,tvSeasonEpisodeNumber').json()['entries']
|
||||
|
||||
url = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={subBrandId}{'+ item.url + '}&range=' + str(item.nextIndex) + '-' + str(item.nextIndex + PAGINATION)
|
||||
json = current_session.get(url).json()['entries']
|
||||
for it in res:
|
||||
thumb = ''
|
||||
titleDate = ''
|
||||
if 'mediasetprogram$publishInfo_lastPublished' in it:
|
||||
date = datetime.date.fromtimestamp(it['mediasetprogram$publishInfo_lastPublished'] / 1000)
|
||||
titleDate =' [{} {}]'.format(date.day, months[date.month])
|
||||
title = '[B]{}[/B]{}'.format(it['title'], titleDate)
|
||||
for k, v in it['thumbnails'].items():
|
||||
if 'image_keyframe' in k and not thumb:
|
||||
thumb = v['url'].replace('.jpg', '@3.jpg')
|
||||
break
|
||||
if not thumb: thumb = item.thumbnail
|
||||
|
||||
for it in json:
|
||||
urls = []
|
||||
if 'media' in it:
|
||||
for key in it['media']:
|
||||
urls.append(key['publicUrl'])
|
||||
if urls:
|
||||
title = it['title']
|
||||
itemlist.append(
|
||||
item.clone(action='findvideos',
|
||||
title=support.typo(title, 'bold'),
|
||||
contentType='episode',
|
||||
thumbnail=it['thumbnails']['image_vertical-264x396']['url'] if 'image_vertical-264x396' in it['thumbnails'] else '',
|
||||
fanart=it['thumbnails']['image_keyframe_poster-1280x720']['url'] if 'image_keyframe_poster-1280x720' in it['thumbnails'] else '',
|
||||
plot=it['longDescription'] if 'longDescription' in it else it['description'],
|
||||
urls=urls,
|
||||
url=it['mediasetprogram$pageUrl'],
|
||||
year=it.get('year',''),
|
||||
ep= it.get('tvSeasonEpisodeNumber', 0) if it.get('tvSeasonEpisodeNumber', 0) else 0,
|
||||
forcethumb=True,
|
||||
no_return=True))
|
||||
|
||||
if len(itemlist) == 1: return findvideos(itemlist[0])
|
||||
|
||||
if (len(json) >= PAGINATION):
|
||||
item.nextIndex += PAGINATION + 1
|
||||
support.nextPage(itemlist, item)
|
||||
itemlist.append(item.clone(title=title,
|
||||
thumbnail=thumb,
|
||||
forcethumb=True,
|
||||
contentType='episode',
|
||||
action='play',
|
||||
video_id=it['guid']))
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.debug()
|
||||
itemlist = [item.clone(server='directo', title='Mediaset Play', urls=item.urls, action='play')]
|
||||
return support.server(item, itemlist=itemlist, Download=False)
|
||||
|
||||
|
||||
def play(item):
|
||||
logger.debug()
|
||||
for url in item.urls:
|
||||
sec_data = support.match(url + post_url).data
|
||||
item.no_return=True
|
||||
mpd = config.get_setting('mpd', item.channel)
|
||||
|
||||
|
||||
lic_url = 'https://widevine.entitlement.theplatform.eu/wv/web/ModularDrm/getRawWidevineLicense?releasePid={pid}&account=http://access.auth.theplatform.com/data/Account/2702976343&schema=1.0&token={token}|Accept=*/*&Content-Type=&User-Agent={ua}|R{{SSM}}|'
|
||||
url = ''
|
||||
|
||||
if item.urls:
|
||||
url = ''
|
||||
pid = ''
|
||||
Format = 'dash+xml' if mpd else 'x-mpegURL'
|
||||
for it in item.urls:
|
||||
if Format in it['format']:
|
||||
item.url = requests.head(it['publicUrls'][0]).headers['Location']
|
||||
pid = it['releasePids'][0]
|
||||
|
||||
if mpd:
|
||||
item.manifest = 'mpd'
|
||||
item.drm = 'com.widevine.alpha'
|
||||
item.license = lic_url.format(pid=pid, token=Token, ua=support.httptools.get_user_agent())
|
||||
|
||||
else:
|
||||
item.manifest = 'hls'
|
||||
return[item]
|
||||
|
||||
elif item.video_id:
|
||||
payload = '{"contentId":"' + item.video_id + ' ","streamType":"VOD","delivery":"Streaming","createDevice":true}'
|
||||
res = session.post('https://api-ott-prod-fe.mediaset.net/PROD/play/playback/check/v2.0?sid=' + sid, data=payload).json()['response']['mediaSelector']
|
||||
|
||||
else:
|
||||
payload = '{"channelCode":"' + item.callSign + '","streamType":"LIVE","delivery":"Streaming","createDevice":true}'
|
||||
res = session.post('https://api-ott-prod-fe.mediaset.net/PROD/play/playback/check/v2.0?sid=' + sid, data=payload).json()['response']['mediaSelector']
|
||||
|
||||
url = res['url']
|
||||
mpd = True if 'dash' in res['formats'].lower() else False
|
||||
|
||||
if url:
|
||||
|
||||
sec_data = support.match(url + '?' + urlencode(res)).data
|
||||
item.url = support.match(sec_data, patron=r'<video src="([^"]+)').match
|
||||
pid = support.match(sec_data, patron=r'pid=([^|]+)').match
|
||||
item.manifest = 'mpd'
|
||||
|
||||
if pid:
|
||||
if mpd and pid:
|
||||
item.manifest = 'mpd'
|
||||
item.drm = 'com.widevine.alpha'
|
||||
item.license = lic_url % pid
|
||||
break
|
||||
item.license = lic_url.format(pid=pid, token=Token, ua=support.httptools.get_user_agent())
|
||||
else:
|
||||
item.manifest = 'hls'
|
||||
|
||||
return [item]
|
||||
|
||||
|
||||
def subBrand(json):
|
||||
logger.debug()
|
||||
subBrandId = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-brands?byCustomValue={brandId}{' + json + '}').json()['entries'][-1]['mediasetprogram$subBrandId']
|
||||
json = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={subBrandId}{' + subBrandId + '}').json()['entries']
|
||||
return json
|
||||
return [item]
|
||||
|
||||
|
||||
def get_from_id(item):
|
||||
logger.debug()
|
||||
json = current_session.get(entry.format(id=item.url)).json()
|
||||
if 'components' in json:
|
||||
id = quote(",".join(json["components"]))
|
||||
json = current_session.get(entries.format(id=id)).json()
|
||||
if 'entries' in json:
|
||||
return json['entries']
|
||||
sessionKey = session.get(sessionUrl.format(uuid=str(uuid.uuid4())), verify=False).json()['sessionKey']
|
||||
session.headers.update({'x-session': sessionKey})
|
||||
res = session.get(entry.format(id=item.args)).json()
|
||||
if 'components' in res:
|
||||
id = quote(",".join(res["components"]))
|
||||
res = session.get(entries.format(id=id)).json()
|
||||
if 'entries' in res:
|
||||
return res['entries']
|
||||
return {}
|
||||
|
||||
|
||||
def get_programs(item, ret=[], args={}):
|
||||
hasMore = False
|
||||
def get_programs(item):
|
||||
url = ''
|
||||
pag = item.page if item.page else 1
|
||||
ret = {}
|
||||
|
||||
if 'search' in item.args:
|
||||
args['uxReference'] = item.args[2]
|
||||
args["query"] = item.text
|
||||
args['traceCid'] = tracecid
|
||||
args['cwId'] = cwid
|
||||
args['page'] = 1
|
||||
args['platform'] = 'pc'
|
||||
args['hitsPerPage'] = 500
|
||||
url = 'https://api-ott-prod-fe.mediaset.net/PROD/play/rec2/search/v1.0?' + urlencode(args)
|
||||
elif not args:
|
||||
if item.ref in cdict:
|
||||
args['uxReference'] = cdict[item.ref]
|
||||
args['platform'] = 'pc'
|
||||
else:
|
||||
args = {"query": "*:*"}
|
||||
if item.args[2]:
|
||||
args['categories'] = item.args[2]
|
||||
if item.args.get('feed'):
|
||||
pag = item.page if item.page else 1
|
||||
url='{}&range={}-{}'.format(item.args.get('feed'), pag, pag + pagination - 1)
|
||||
ret['next'] = pag + pagination
|
||||
res = requests.get(url).json()
|
||||
|
||||
args['cwId'] = cwid
|
||||
args['traceCid'] = tracecid
|
||||
args['hitsPerPage'] = 500
|
||||
args['page'] = '0'
|
||||
args['deviceId'] = deviceid
|
||||
url="https://api-ott-prod-fe.mediaset.net/PROD/play/rec2/cataloguelisting/v1.0?" + urlencode(args)
|
||||
|
||||
# if 'all' in item.args: url = 'https://api-ott-prod-fe.mediaset.net/PROD/play/rec/azlisting/v1.0?' + urlencode(args)
|
||||
if url:
|
||||
json = current_session.get(url).json()
|
||||
if 'response' in json:
|
||||
json = json['response']
|
||||
if 'hasMore' in json:
|
||||
hasMore = json['hasMore']
|
||||
if 'components' in json:
|
||||
id = quote(",".join(json["components"]))
|
||||
json = current_session.get(entries.format(id=id)).json()
|
||||
if 'entries' in json:
|
||||
ret += json['entries']
|
||||
if hasMore:
|
||||
args['page'] = str(int(args['page']) + 1)
|
||||
return get_programs(item, ret, args)
|
||||
else:
|
||||
return ret
|
||||
else:
|
||||
return ret
|
||||
args = {key:value for key, value in item.args.items()}
|
||||
args['context'] = 'platform≈web'
|
||||
args['sid'] = sid
|
||||
args['sessionId'] = sid
|
||||
args['hitsPerPage'] = pagination
|
||||
args['property'] = 'search' if args.get('query') else 'play'
|
||||
args['tenant'] = 'play-prod-v2'
|
||||
args['page'] = pag
|
||||
args['deviceId'] = '017ac511182d008322c989f3aac803083002507b00bd0'
|
||||
url="https://api-ott-prod-fe.mediaset.net/PROD/play/reco/anonymous/v2.0?" + urlencode(args)
|
||||
|
||||
res = session.get(url).json()
|
||||
|
||||
if res:
|
||||
res = res.get('response', res)
|
||||
if 'entries' in res:
|
||||
ret['items'] = res['entries']
|
||||
elif 'blocks' in res:
|
||||
items = []
|
||||
for block in res['blocks']:
|
||||
items += block['items']
|
||||
ret['items'] = items
|
||||
if not 'next' in ret:
|
||||
next = res.get('pagination',{}).get('hasNextPage', False)
|
||||
ret['next'] = pag + 1 if next else 0
|
||||
return ret
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
# Canale per Mediaset Play
|
||||
# ------------------------------------------------------------
|
||||
from platformcode import logger, config
|
||||
import uuid
|
||||
|
||||
import requests, sys
|
||||
from core import support, jsontools
|
||||
if sys.version_info[0] >= 3: from urllib.parse import urlencode, quote
|
||||
else: from urllib import urlencode, quote
|
||||
if sys.version_info[0] >= 3: from concurrent import futures
|
||||
else: from concurrent_py2 import futures
|
||||
from collections import OrderedDict
|
||||
|
||||
PAGINATION = 4
|
||||
|
||||
host = config.get_channel_url()
|
||||
post_url = '?assetTypes=HD,browser,widevine,geoIT|geoNo:HD,browser,geoIT|geoNo:HD,geoIT|geoNo:SD,browser,widevine,geoIT|geoNo:SD,browser,geoIT|geoNo:SD,geoIT|geoNo&auto=true&balance=true&format=smil&formats=MPEG-DASH,MPEG4,M3U&tracking=true'
|
||||
deviceid = '61d27df7-5cbf-4419-ba06-cfd27ecd4588'
|
||||
loginUrl = 'https://api-ott-prod-fe.mediaset.net/PROD/play/idm/anonymous/login/v2.0'
|
||||
loginData = {"cid": deviceid, "platform": "pc", "appName": "web/mediasetplay-web/d667681"}
|
||||
lic_url = 'https://widevine.entitlement.theplatform.eu/wv/web/ModularDrm/getRawWidevineLicense?releasePid=%s&account=http://access.auth.theplatform.com/data/Account/2702976343&schema=1.0&token={token}|Accept=*/*&Content-Type=&User-Agent=' + support.httptools.get_user_agent() + '|R{{SSM}}|'
|
||||
entry = 'https://api.one.accedo.tv/content/entry/{id}?locale=it'
|
||||
entries = 'https://api.one.accedo.tv/content/entries?id={id}&locale=it'
|
||||
sessionUrl = "https://api.one.accedo.tv/session?appKey=59ad346f1de1c4000dfd09c5&uuid={uuid}&gid=default"
|
||||
|
||||
current_session = requests.Session()
|
||||
current_session.headers.update({'Content-Type': 'application/json', 'User-Agent': support.httptools.get_user_agent(), 'Referer': support.config.get_channel_url()})
|
||||
|
||||
# login anonimo
|
||||
res = current_session.post(loginUrl, json=loginData, verify=False)
|
||||
support.dbg()
|
||||
Token = res.json['response']['beToken']
|
||||
sid = res.json['response']['sid']
|
||||
current_session.headers.update({'authorization': 'Bearer' + Token})
|
||||
lic_url = lic_url.format(token=Token)
|
||||
tracecid = res.json()['response']['traceCid']
|
||||
cwid = res.json()['response']['cwId']
|
||||
|
||||
# sessione
|
||||
res = current_session.get(sessionUrl.format(uuid=str(uuid.uuid4())), verify=False)
|
||||
current_session.headers.update({'x-session': res.json()['sessionKey']})
|
||||
|
||||
cdict = {'CVFILM':'filmUltimiArrivi',
|
||||
'CWFILMTOPVIEWED':'filmPiuVisti24H',
|
||||
'CWFILMCOMEDY':'filmCommedia',
|
||||
'CWFILMACTION':'filmAzioneThrillerAvventura',
|
||||
'CWFILMDRAMATIC':'filmDrammatico',
|
||||
'CWFILMSENTIMENTAL':'filmSentimentale',
|
||||
'CWFILMCLASSIC':'filmClassici',
|
||||
'personToContentFilm':'personToContentFilm',
|
||||
'CWHOMEFICTIONNOWELITE':'stagioniFictionSerieTvSezione',
|
||||
'CWFICTIONSOAP':'mostRecentSoapOpera',
|
||||
'CWFICTIONDRAMATIC':'stagioniFictionDrammatico',
|
||||
'CWFICTIONPOLICE':'stagioniFictionPoliziesco',
|
||||
'CWFICTIONCOMEDY':'stagioniFictionCommedia',
|
||||
'CWFICTIONSITCOM':'stagioniFictionSitCom',
|
||||
'CWFICTIONSENTIMENTAL':'stagioniFictionSentimentale',
|
||||
'CWFICTIONBIOGRAPHICAL':'stagioniFictionBiografico',
|
||||
'CWPROGTVPRIME':'stagioniPrimaSerata',
|
||||
'CWPROGTVDAY':'stagioniDaytime',
|
||||
'CWPROGTVTOPVIEWED':'programmiTvClip24H',
|
||||
'CWPROGTVTALENT':'stagioniReality',
|
||||
'CWPROGTVVARIETY':'stagioniVarieta',
|
||||
'CWPROGTVTALK':'stagioniTalk',
|
||||
'CWPROGTVTG':'mostRecentTg',
|
||||
'CWPROGTVSPORT':'mostRecentSport',
|
||||
'CWPROGTVMAGAZINE':'stagioniCucinaLifestyle',
|
||||
'CWDOCUMOSTRECENT':'mostRecentDocumentariFep',
|
||||
'CWDOCUTOPVIEWED':'stagioniDocumentari',
|
||||
'CWDOCUSPAZIO':'documentariSpazio',
|
||||
'CWDOCUNATURANIMALI':'documentariNatura',
|
||||
'CWDOCUSCIENZATECH':'documentariScienza',
|
||||
'CWDOCUBIOSTORIE':'documentariBioStoria',
|
||||
'CWDOCUINCHIESTE':'documentariInchiesta',
|
||||
'CWFILMDOCU':'filmDocumentario',
|
||||
'CWKIDSBOINGFORYOU':'kidsBoing',
|
||||
'CWKIDSCARTOONITO':'kidsCartoonito',
|
||||
'CWKIDSMEDIASETBRAND':'kidsMediaset',
|
||||
'CWENABLERKIDS':'stagioniKids'}
|
||||
|
||||
|
||||
@support.menu
|
||||
def mainlist(item):
|
||||
top = [('Dirette {bold}', ['https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-stations?sort=ShortTitle', 'live'])]
|
||||
|
||||
menu = [('Fiction / Serie TV {bullet bold}', ['/fiction', 'menu', ['Tutte','all','searchStagioni', '5acfcb3c23eec6000d64a6a4'], 'tvshow']),
|
||||
('Programmi TV{ bullet bold}', ['/programmitv', 'menu', ['Tutti','all','searchStagioni', '5acfc8011de1c4000b6ec953'], 'tvshow']),
|
||||
('Documentari {bullet bold}', ['/documentari', 'menu', ['Tutti','all','', '5bfd17c423eec6001aec49f9'], 'undefined']),
|
||||
('Kids {bullet bold}', ['/kids', 'menu',['Tutti','all','', '5acfcb8323eec6000d64a6b3'], 'undefined'])]
|
||||
|
||||
search = ''
|
||||
return locals()
|
||||
|
||||
|
||||
def search(item, text):
|
||||
itemlist = []
|
||||
logger.debug(text)
|
||||
item.search = text
|
||||
|
||||
try:
|
||||
itemlist = peliculas(item)
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
support.logger.error("%s" % line)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def menu(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
if item.url:
|
||||
json = get_from_id(item)
|
||||
for it in json:
|
||||
logger.debug(jsontools.dump(it))
|
||||
if 'uxReference' in it: itemlist.append(
|
||||
item.clone(title=support.typo(it['title'], 'bullet bold'), url= it['landingUrl'], feed = it.get('feedurlV2',''), ref=it['uxReference'], args='', action='peliculas'))
|
||||
return itemlist
|
||||
|
||||
|
||||
def liveDict():
|
||||
livedict = OrderedDict({})
|
||||
json = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-stations?sort=ShortTitle').json()['entries']
|
||||
for it in json:
|
||||
urls = []
|
||||
if it.get('tuningInstruction') and not it.get('mediasetstation$digitalOnly'):
|
||||
guide=current_session.get('https://static3.mediasetplay.mediaset.it/apigw/nownext/' + it['callSign'] + '.json').json()['response']
|
||||
for key in it['tuningInstruction']['urn:theplatform:tv:location:any']:
|
||||
urls += key['publicUrls']
|
||||
title = it['title']
|
||||
livedict[title] = {}
|
||||
livedict[title]['urls'] = urls
|
||||
livedict[title]['plot'] = support.typo(guide['currentListing']['mediasetlisting$epgTitle'],'bold') + '\n' + guide['currentListing']['mediasetlisting$shortDescription'] + '\n' + guide['currentListing']['description'] + '\n\n' + support.typo('A Seguire:' + guide['nextListing']['mediasetlisting$epgTitle'], 'bold')
|
||||
return livedict
|
||||
|
||||
|
||||
def live(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
for key, value in liveDict().items():
|
||||
itemlist.append(item.clone(title=support.typo(key, 'bold'),
|
||||
fulltitle=key,
|
||||
show=key,
|
||||
contentTitle=key,
|
||||
forcethumb=True,
|
||||
urls=value['urls'],
|
||||
plot=value['plot'],
|
||||
action='play',
|
||||
no_return=True))
|
||||
return support.thumb(itemlist, live=True)
|
||||
|
||||
|
||||
def peliculas(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
titlelist = []
|
||||
contentType = ''
|
||||
if item.text:
|
||||
json = []
|
||||
itlist = []
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
for arg in ['searchMovie', 'searchStagioni', 'searchClip']:
|
||||
item.args = ['', 'search', arg]
|
||||
itlist += [executor.submit(get_programs, item)]
|
||||
for res in futures.as_completed(itlist):
|
||||
json += res.result()
|
||||
else:
|
||||
json = get_programs(item)
|
||||
|
||||
for it in json:
|
||||
if item.search.lower() in it['title'].lower() and it['title'] not in titlelist:
|
||||
titlelist.append(it['title'])
|
||||
if 'media' in it:
|
||||
action = 'findvideos'
|
||||
contentType = 'movie'
|
||||
urls = []
|
||||
for key in it['media']:
|
||||
urls.append(key['publicUrl'])
|
||||
|
||||
else:
|
||||
action = 'epmenu'
|
||||
contentType = 'tvshow'
|
||||
urls = it['mediasetprogram$brandId']
|
||||
if urls:
|
||||
title = it['mediasetprogram$brandTitle'] + ' - ' if 'mediasetprogram$brandTitle' in it and it['mediasetprogram$brandTitle'] != it['title'] else ''
|
||||
itemlist.append(
|
||||
item.clone(channel=item.channel,
|
||||
action=action,
|
||||
title=support.typo(title + it['title'], 'bold'),
|
||||
fulltitle=it['title'],
|
||||
show=it['title'],
|
||||
contentType=contentType if contentType else item.contentType,
|
||||
contentTitle=it['title'] if 'movie' in [contentType, item.contentType] else '',
|
||||
contentSerieName=it['title'] if 'tvshow' in [contentType, item.contentType] else '',
|
||||
thumbnail=it['thumbnails']['image_vertical-264x396']['url'] if 'image_vertical-264x396' in it['thumbnails'] else '',
|
||||
fanart=it['thumbnails']['image_keyframe_poster-1280x720']['url'] if 'image_keyframe_poster-1280x720' in it['thumbnails'] else '',
|
||||
plot=it['longDescription'] if 'longDescription' in it else it['description'] if 'description' in it else '',
|
||||
urls=urls,
|
||||
seriesid = it.get('seriesId',''),
|
||||
url=it['mediasetprogram$pageUrl'],
|
||||
forcethumb=True,
|
||||
no_return=True))
|
||||
if item.feed:
|
||||
item.page = item.page + 100 if item.page else 101
|
||||
support.nextPage(itemlist, item)
|
||||
return itemlist
|
||||
|
||||
|
||||
def epmenu(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
|
||||
if item.seriesid:
|
||||
seasons = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-tv-seasons?bySeriesId=' + item.seriesid).json()['entries']
|
||||
for season in seasons:
|
||||
if 'mediasettvseason$brandId' in season and 'mediasettvseason$displaySeason' in season:
|
||||
itemlist.append(
|
||||
item.clone(seriesid = '',
|
||||
title=support.typo(season['mediasettvseason$displaySeason'], 'bold'),
|
||||
urls=season['mediasettvseason$brandId']))
|
||||
itemlist = sorted(itemlist, key=lambda it: it.title, reverse=True)
|
||||
if len(itemlist) == 1: return epmenu(itemlist[0])
|
||||
if not itemlist:
|
||||
entries = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-brands?byCustomValue={brandId}{' + item.urls + '}').json()['entries']
|
||||
for entry in entries:
|
||||
if 'mediasetprogram$subBrandId' in entry:
|
||||
itemlist.append(
|
||||
item.clone(action='episodios',
|
||||
title=support.typo(entry['description'], 'bold'),
|
||||
url=entry['mediasetprogram$subBrandId'],
|
||||
order=entry.get('mediasetprogram$order',0)))
|
||||
if len(itemlist) == 1: return episodios(itemlist[0])
|
||||
itemlist = sorted(itemlist, key=lambda it: it.order)
|
||||
return itemlist
|
||||
|
||||
|
||||
def episodios(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
if not item.nextIndex: item.nextIndex = 1
|
||||
|
||||
url = 'https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={subBrandId}{'+ item.url + '}&range=' + str(item.nextIndex) + '-' + str(item.nextIndex + PAGINATION)
|
||||
json = current_session.get(url).json()['entries']
|
||||
|
||||
for it in json:
|
||||
urls = []
|
||||
if 'media' in it:
|
||||
for key in it['media']:
|
||||
urls.append(key['publicUrl'])
|
||||
if urls:
|
||||
title = it['title']
|
||||
itemlist.append(
|
||||
item.clone(action='findvideos',
|
||||
title=support.typo(title, 'bold'),
|
||||
contentType='episode',
|
||||
thumbnail=it['thumbnails']['image_vertical-264x396']['url'] if 'image_vertical-264x396' in it['thumbnails'] else '',
|
||||
fanart=it['thumbnails']['image_keyframe_poster-1280x720']['url'] if 'image_keyframe_poster-1280x720' in it['thumbnails'] else '',
|
||||
plot=it['longDescription'] if 'longDescription' in it else it['description'],
|
||||
urls=urls,
|
||||
url=it['mediasetprogram$pageUrl'],
|
||||
year=it.get('year',''),
|
||||
ep= it.get('tvSeasonEpisodeNumber', 0) if it.get('tvSeasonEpisodeNumber', 0) else 0,
|
||||
forcethumb=True,
|
||||
no_return=True))
|
||||
|
||||
if len(itemlist) == 1: return findvideos(itemlist[0])
|
||||
|
||||
if (len(json) >= PAGINATION):
|
||||
item.nextIndex += PAGINATION + 1
|
||||
support.nextPage(itemlist, item)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
logger.debug()
|
||||
itemlist = [item.clone(server='directo', title='Mediaset Play', urls=item.urls, action='play')]
|
||||
return support.server(item, itemlist=itemlist, Download=False)
|
||||
|
||||
|
||||
def play(item):
|
||||
logger.debug()
|
||||
for url in item.urls:
|
||||
sec_data = support.match(url + post_url).data
|
||||
item.url = support.match(sec_data, patron=r'<video src="([^"]+)').match
|
||||
pid = support.match(sec_data, patron=r'pid=([^|]+)').match
|
||||
item.manifest = 'mpd'
|
||||
|
||||
if pid:
|
||||
item.drm = 'com.widevine.alpha'
|
||||
item.license = lic_url % pid
|
||||
break
|
||||
|
||||
return [item]
|
||||
|
||||
|
||||
def subBrand(json):
|
||||
logger.debug()
|
||||
subBrandId = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-brands?byCustomValue={brandId}{' + json + '}').json()['entries'][-1]['mediasetprogram$subBrandId']
|
||||
json = current_session.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs?byCustomValue={subBrandId}{' + subBrandId + '}').json()['entries']
|
||||
return json
|
||||
|
||||
|
||||
def get_from_id(item):
|
||||
logger.debug()
|
||||
json = current_session.get(entry.format(id=item.args[3])).json()
|
||||
if 'components' in json:
|
||||
id = quote(",".join(json["components"]))
|
||||
json = current_session.get(entries.format(id=id)).json()
|
||||
if 'entries' in json:
|
||||
return json['entries']
|
||||
return {}
|
||||
|
||||
|
||||
def get_programs(item, ret=[], args={}):
|
||||
hasMore = False
|
||||
url = ''
|
||||
# support.dbg()
|
||||
|
||||
if 'search' in item.args:
|
||||
args['uxReference'] = item.args[2]
|
||||
args["query"] = item.text
|
||||
args['traceCid'] = tracecid
|
||||
args['cwId'] = cwid
|
||||
args['page'] = 1
|
||||
args['platform'] = 'pc'
|
||||
args['hitsPerPage'] = 500
|
||||
url = 'https://api-ott-prod-fe.mediaset.net/PROD/play/rec2/search/v1.0?' + urlencode(args)
|
||||
elif item.feed:
|
||||
pag = item.page if item.page else 1
|
||||
url='{}&range={}-{}'.format(item.feed, pag, pag + 99)
|
||||
elif not args:
|
||||
if item.ref in cdict:
|
||||
args['uxReference'] = cdict[item.ref]
|
||||
args['platform'] = 'pc'
|
||||
else:
|
||||
args = {"query": "*:*"}
|
||||
if item.args[2]:
|
||||
args['categories'] = item.args[2]
|
||||
|
||||
args['cwId'] = cwid
|
||||
args['traceCid'] = tracecid
|
||||
args['hitsPerPage'] = 500
|
||||
args['page'] = '0'
|
||||
args['deviceId'] = deviceid
|
||||
url="https://api-ott-prod-fe.mediaset.net/PROD/play/rec2/cataloguelisting/v1.0?" + urlencode(args)
|
||||
|
||||
|
||||
if url:
|
||||
json = current_session.get(url).json()
|
||||
if 'response' in json:
|
||||
json = json['response']
|
||||
if 'hasMore' in json:
|
||||
hasMore = json['hasMore']
|
||||
if 'components' in json:
|
||||
id = quote(",".join(json["components"]))
|
||||
json = current_session.get(entries.format(id=id)).json()
|
||||
if 'entries' in json:
|
||||
ret += json['entries']
|
||||
if hasMore:
|
||||
args['page'] = str(int(args['page']) + 1)
|
||||
return get_programs(item, ret, args)
|
||||
else:
|
||||
return ret
|
||||
else:
|
||||
return ret
|
||||
+223
-357
@@ -3,35 +3,35 @@
|
||||
# Canale per Rai Play
|
||||
# ------------------------------------------------------------
|
||||
|
||||
import requests, sys, inspect
|
||||
from core import support, channeltools
|
||||
from platformcode import autorenumber, logger, platformtools
|
||||
from collections import OrderedDict
|
||||
from core.item import Item
|
||||
import datetime, xbmc
|
||||
import requests, sys
|
||||
|
||||
from core import jsontools, support
|
||||
from platformcode import logger
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
from concurrent import futures
|
||||
else:
|
||||
from concurrent_py2 import futures
|
||||
|
||||
current_session = requests.Session()
|
||||
host = support.config.get_channel_url()
|
||||
onair = host + '/palinsesto/onAir.json'
|
||||
|
||||
|
||||
@support.menu
|
||||
def mainlist(item):
|
||||
top = [('Dirette {bold}', ['', 'live']),
|
||||
('Replay {bold}', ['/dl/RaiPlay/2016/PublishingBlock-9a2ff311-fcf0-4539-8f8f-c4fee2a71d58.html?json', 'replay_menu'])]
|
||||
top = [('Dirette {bold}', ['/dirette', 'live', '/palinsesto/onAir.json']),
|
||||
('Replay {bold}', ['/guidatv', 'replayMenu', '/guidatv.json'])]
|
||||
|
||||
menu = [('Film {bullet bold}', ['/tipologia/film/index.json', 'menu']),
|
||||
('Serie TV {bullet bold}', ['/tipologia/serietv/index.json', 'menu']),
|
||||
('Fiction {bullet bold}', ['/tipologia/fiction/index.json', 'menu']),
|
||||
('Documentari {bullet bold}', ['/tipologia/documentari/index.json', 'menu']),
|
||||
('Programmi TV{bullet bold}', ['/tipologia/programmi/index.json', 'menu']),
|
||||
('Programmi per Bambini {bullet bold}', ['/tipologia/bambini/index.json', 'menu']),
|
||||
('Teen {bullet bold}', ['/tipologia/teen/index.json', 'learning']),
|
||||
('Learning {bullet bold}', ['/tipologia/learning/index.json', 'learning']),
|
||||
('Teche Rai {bullet bold storia}', ['/tipologia/techerai/index.json', 'menu']),
|
||||
('Musica e Teatro {bullet bold}', ['/tipologia/musica-e-teatro/index.json', 'menu'])
|
||||
menu = [('Film {bullet bold}', ['/film', 'menu', '/tipologia/film/index.json']),
|
||||
('Serie TV {bullet bold}', ['/serietv', 'menu', '/tipologia/serietv/index.json']),
|
||||
('Fiction {bullet bold}', ['/fiction', 'menu', '/tipologia/fiction/index.json']),
|
||||
('Documentari {bullet bold}', ['/documentari', 'menu', '/tipologia/documentari/index.json']),
|
||||
('Programmi TV{bullet bold}', ['/programmi', 'menu', '/tipologia/programmi/index.json']),
|
||||
('Programmi per Bambini {bullet bold}', ['/bambini', 'menu', '/tipologia/bambini/index.json']),
|
||||
('Teen {bullet bold}', ['/teen', 'menu', '/tipologia/teen/index.json']),
|
||||
('Learning {bullet bold}', ['/learning', 'menu', '/tipologia/learning/index.json']),
|
||||
('Teche Rai {bullet bold storia}', ['/techerai', 'menu', '/tipologia/techerai/index.json']),
|
||||
('Musica e Teatro {bullet bold}', ['/musica-e-teatro', 'menu', '/tipologia/musica-e-teatro/index.json'])
|
||||
]
|
||||
|
||||
search = ''
|
||||
@@ -40,46 +40,115 @@ def mainlist(item):
|
||||
|
||||
|
||||
def menu(item):
|
||||
support.info()
|
||||
itemlist = [item.clone(title = support.typo('Tutti','bullet bold'), action = 'peliculas'),
|
||||
item.clone(title = support.typo('Generi','submenu'), args = 'genre', action = 'submenu'),
|
||||
item.clone(title = support.typo('A-Z','submenu'), args = 'az', action = 'submenu'),
|
||||
item.clone(title = support.typo('Cerca','submenu'), action = 'search')]
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
item.disable_videolibrary = True
|
||||
action = 'peliculas'
|
||||
|
||||
return support.thumb(itemlist)
|
||||
if item.data:
|
||||
for it in item.data:
|
||||
url = getUrl(it['path_id'])
|
||||
action = 'genres'
|
||||
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), url=url.replace('.json','.html'), genre_url=url, data='', action=action))
|
||||
support.thumb(itemlist, genre=True)
|
||||
else:
|
||||
items = item.data if item.data else requests.get(host + item.args).json()['contents']
|
||||
for it in items:
|
||||
if 'RaiPlay Slider Block' in it['type'] or 'RaiPlay Slider Generi Block' in it['type']:
|
||||
thumb = item.thumbnail
|
||||
if 'RaiPlay Slider Generi Block' in it['type']:
|
||||
action = 'menu'
|
||||
thumb = support.thumb('genres')
|
||||
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), data=it.get('contents', item.data), thumbnail=thumb, action=action))
|
||||
|
||||
|
||||
def learning(item):
|
||||
support.info()
|
||||
itemlist =[]
|
||||
json = current_session.get(item.url).json()['contents']
|
||||
for key in json:
|
||||
itemlist.append(item.clone(title = support.typo(key['name'],'bold'), fulltitle = key['name'],
|
||||
show = key['name'], data = key['contents'], action = 'peliculas'))
|
||||
return itemlist
|
||||
|
||||
|
||||
def submenu(item):
|
||||
support.info()
|
||||
def genres(item):
|
||||
itemlist = []
|
||||
json = current_session.get(item.url).json()['contents'][-1]['contents']
|
||||
if item.args == 'az':
|
||||
json_url = getUrl(json[-1]['path_id'])
|
||||
json = current_session.get(json_url).json()['contents']
|
||||
for key in json:
|
||||
itemlist.append(item.clone(title = support.typo(key,'bold'), fulltitle = key,
|
||||
show = key, data = json[key], action = 'peliculas'))
|
||||
else:
|
||||
for key in json:
|
||||
itemlist.append(item.clone(title = support.typo(key['name'],'bold'), fulltitle = key['name'], show = key['name'],
|
||||
thumbnail = getUrl(key['image']), url = getUrl(key['path_id']), action = 'peliculas'))
|
||||
itemlist.pop(-1)
|
||||
return support.thumb(itemlist)
|
||||
items = requests.get(getUrl(item.genre_url)).json()['contents']
|
||||
for title, it in items.items():
|
||||
if it: itemlist.append(item.clone(title=support.typo(title, 'bold'), data=it, action='peliculas', thumbnail=support.thumb('az')))
|
||||
return itemlist
|
||||
|
||||
|
||||
def replay_menu(item):
|
||||
support.info()
|
||||
import datetime, xbmc
|
||||
def search(item, text):
|
||||
logger.debug(text)
|
||||
post = {'page':0, 'pagesize': 1000, 'param':text}
|
||||
|
||||
try:
|
||||
item.data = requests.post(host + '/atomatic/raiplay-search-service/api/v3/search', json=post).json()['agg']['titoli']['cards']
|
||||
return peliculas(item)
|
||||
# Continua la ricerca in caso di errore
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
support.logger.error("%s" % line)
|
||||
return []
|
||||
|
||||
|
||||
def peliculas(item):
|
||||
logger.debug()
|
||||
return addinfo(item.data, item)
|
||||
|
||||
|
||||
def episodios(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
|
||||
if item.data:
|
||||
items = item.data
|
||||
elif item.season_url:
|
||||
items = requests.get(item.season_url).json()['items']
|
||||
elif item.video_url:
|
||||
items = requests.get(item.video_url).json()['blocks']
|
||||
|
||||
if 'sets' in items[0]:
|
||||
if len(items) > 1:
|
||||
itemlist = epMenu(item.clone(data=items))
|
||||
else:
|
||||
if len(items[0]['sets']) > 1:
|
||||
itemlist = epMenu(item.clone(data=items[0]['sets']))
|
||||
else:
|
||||
items = requests.get(getUrl(items[0]['sets'][0]['path_id'])).json()['items']
|
||||
|
||||
if not itemlist:
|
||||
itemlist = addinfo(items, item)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def epMenu(item):
|
||||
video_url = ''
|
||||
itemlist = []
|
||||
for it in item.data:
|
||||
if 'sets' in it:
|
||||
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), data=[it]))
|
||||
else:
|
||||
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), season_url=getUrl(it['path_id']), data=''))
|
||||
return itemlist
|
||||
|
||||
|
||||
def live(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
item.forcethumb = True
|
||||
items = requests.get(getUrl(item.args)).json()['on_air']
|
||||
for it in items:
|
||||
title = it['channel']
|
||||
url = '{}/dirette/{}'.format(host, title.lower().replace(' ',''))
|
||||
fanart = getUrl(it['currentItem']['image'])
|
||||
current = it['currentItem']
|
||||
next = it['nextItem']
|
||||
plot = '[B]{}[/B]\n{}\n\nA Seguire: [B]{}[/B]\n{}'.format(current['name'], current['description'], next['name'], next['description'])
|
||||
itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, video_url=url + '.json', action='play'))
|
||||
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
||||
support.thumb(itemlist, live=True)
|
||||
return itemlist
|
||||
|
||||
|
||||
def replayMenu(item):
|
||||
logger.debug()
|
||||
|
||||
# create day and month list
|
||||
days = []
|
||||
@@ -98,336 +167,133 @@ def replay_menu(item):
|
||||
today = datetime.date.today()
|
||||
for d in range(7):
|
||||
day = today - datetime.timedelta(days=d)
|
||||
support.info(day)
|
||||
itemlist.append(item.clone(action = 'replay_channels', date = day.strftime("%d-%m-%Y"),
|
||||
title = support.typo(days[int(day.strftime("%w"))] + " " + day.strftime("%d") + " " + months[int(day.strftime("%m"))-1], 'bold')))
|
||||
dayName = days[int(day.strftime("%w"))]
|
||||
dayNumber = day.strftime("%d")
|
||||
monthName = months[int(day.strftime("%m"))-1]
|
||||
title = '{} {} {}'.format(dayName, dayNumber, monthName)
|
||||
itemlist.append(item.clone(title = support.typo(title, 'bold'),
|
||||
action='replayChannels',
|
||||
date=day.strftime("%d-%m-%Y")))
|
||||
return itemlist
|
||||
|
||||
|
||||
def replay_channels(item):
|
||||
support.info()
|
||||
def replayChannels(item):
|
||||
logger.debug()
|
||||
itemlist = []
|
||||
json = current_session.get(item.url).json()['dirette']
|
||||
for key in json:
|
||||
itemlist.append(item.clone(title = support.typo(key['channel'], 'bold'), fulltitle = key['channel'], show = key['channel'], plot = item.title, action = 'replay',
|
||||
thumbnail = key['transparent-icon'].replace("[RESOLUTION]", "256x-"), url = '%s/palinsesto/app/old/%s/%s.json' % (host, key['channel'].lower().replace(' ','-'), item.date)))
|
||||
return itemlist
|
||||
items = requests.get(getUrl(item.args)).json()['channels']
|
||||
|
||||
for it in items:
|
||||
if 'RaiPlay' in it['name']: continue
|
||||
url = '{}?channel={}&date={}'.format(item.url, it['absolute_path'], item.date)
|
||||
channel_url = '{}/palinsesto/app/{}/{}.json'.format(host, it['absolute_path'], item.date)
|
||||
itemlist.append(item.clone(title=support.typo(it['label'], 'bold'),
|
||||
fulltitle=it['label'],
|
||||
url=url,
|
||||
channel_url=channel_url,
|
||||
action='replay'))
|
||||
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
||||
support.thumb(itemlist, live=True)
|
||||
return itemlist
|
||||
|
||||
def replay(item):
|
||||
support.info()
|
||||
logger.debug()
|
||||
|
||||
def itInfo(it):
|
||||
info = requests.get(getUrl(it['program']['info_url'])).json()
|
||||
image = getUrl(info['images']['landscape'])
|
||||
return item.clone(title = '{} - {}'.format(it['hour'], it['name']),
|
||||
thumbnail = image,
|
||||
fanart = image,
|
||||
plot = info['description'],
|
||||
url = getUrl(it['weblink']),
|
||||
video_url = getUrl(it['path_id']),
|
||||
action = 'play',
|
||||
forcethumb = True)
|
||||
|
||||
|
||||
itemlist = []
|
||||
json = current_session.get(item.url).json()[item.fulltitle][0]['palinsesto'][0]['programmi']
|
||||
for key in json:
|
||||
support.info('KEY=',key)
|
||||
if key and key['pathID']: itemlist.append(item.clone(thumbnail = getUrl(key['images']['landscape']), fanart = getUrl(key['images']['landscape']), url = getUrl(key['pathID']), fulltitle = key['name'], show = key['name'],
|
||||
title = support.typo(key['timePublished'], 'color kod bold') + support.typo(' | ' + key['name'], ' bold'), plot = key['testoBreve'], action = 'findvideos'))
|
||||
return itemlist
|
||||
|
||||
def search(item, text):
|
||||
support.info()
|
||||
itemlist =[]
|
||||
try:
|
||||
if item.url != host:
|
||||
item.search = text
|
||||
itemlist = peliculas(item)
|
||||
else:
|
||||
json = current_session.get(host + '/dl/RaiTV/RaiPlayMobile/Prod/Config/programmiAZ-elenco.json').json()
|
||||
for key in json:
|
||||
for key in json[key]:
|
||||
if 'PathID' in key and (text.lower() in key['name'].lower()):
|
||||
itemlist.append(item.clone(title = support.typo(key['name'],'bold'), fulltitle = key['name'], show = key['name'], url = key['PathID'].replace('/?json', '.json'), action = 'Type',
|
||||
thumbnail = getUrl(key['images']['portrait'] if 'portrait' in key['images'] else key['images']['portrait43'] if 'portrait43' in key['images'] else key['images']['landscape']),
|
||||
fanart = getUrl(key['images']['landscape'] if 'landscape' in key['images'] else key['images']['landscape43'])))
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
support.logger.error("%s" % line)
|
||||
return []
|
||||
return itemlist
|
||||
|
||||
|
||||
def Type(item):
|
||||
logger.debug(item.url)
|
||||
json = current_session.get(item.url).json()
|
||||
if json['program_info']['layout'] == 'single':
|
||||
item.contentTitle = item.fulltitle
|
||||
item.contentType = 'movie'
|
||||
return findvideos(item)
|
||||
else:
|
||||
item.contentType = 'tvshow'
|
||||
return select(item)
|
||||
|
||||
|
||||
def liveDict():
|
||||
livedict = OrderedDict({})
|
||||
info = {}
|
||||
url = host + '/dirette.json'
|
||||
json = current_session.get(url).json()['contents']
|
||||
onAir = current_session.get(onair).json()['on_air']
|
||||
for key in onAir:
|
||||
channel = key['channel']
|
||||
info[channel] = {}
|
||||
info[channel]['fanart'] = getUrl(key['currentItem']['image'])
|
||||
info[channel]['plot'] = support.typo(key['currentItem']['name'],'bold')+ '\n\n' + key['currentItem']['description']
|
||||
for key in json:
|
||||
channel = key['channel']
|
||||
livedict[channel] = {}
|
||||
livedict[channel]['url'] = key['video']['content_url']
|
||||
livedict[channel]['plot'] = info[channel]['plot']
|
||||
livedict[channel]['fanart'] = info[channel]['fanart']
|
||||
|
||||
return livedict
|
||||
|
||||
|
||||
def live(item):
|
||||
support.info()
|
||||
itemlist =[]
|
||||
for channel, value in liveDict().items():
|
||||
itemlist.append(item.clone(title = support.typo(channel, 'bold'), fulltitle = channel, show = channel, url = value['url'],
|
||||
plot = value['plot'], action = 'play', fanart = value['fanart'], manifest='hls', no_return=True))
|
||||
return support.thumb(itemlist, live=True)
|
||||
|
||||
|
||||
def peliculas(item):
|
||||
support.info()
|
||||
itemlist = []
|
||||
keys = []
|
||||
key_list = []
|
||||
|
||||
# pagination options
|
||||
pag = item.page if item.page else 1
|
||||
pagination = 40 if not item.search else ''
|
||||
|
||||
# load json
|
||||
if item.data:
|
||||
json = item.data
|
||||
for key in json:
|
||||
if item.search.lower() in key['name'].lower():
|
||||
keys.append(key)
|
||||
else:
|
||||
json = current_session.get(item.url).json()
|
||||
|
||||
# load json for main menu item
|
||||
if not item.args:
|
||||
json_url = getUrl(json['contents'][-1]['contents'][-1]['path_id'])
|
||||
json = current_session.get(json_url).json()['contents']
|
||||
else:
|
||||
json = json['contents']
|
||||
for key in json:
|
||||
if len(json[key]) > 0:
|
||||
for key in json[key]:
|
||||
if item.search.lower() in key['name'].lower():
|
||||
keys.append(key)
|
||||
|
||||
# load titles
|
||||
for i, key in enumerate(keys):
|
||||
if pagination and (pag - 1) * pagination > i: continue # pagination
|
||||
if pagination and i >= pag * pagination: break
|
||||
key_list.append(key)
|
||||
items = requests.get(item.channel_url).json().get('events', {})
|
||||
now = datetime.datetime.now()
|
||||
h = int('{}{:02d}'.format(now.hour, now.minute))
|
||||
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
itlist = [executor.submit(addinfo, key, item) for key in key_list]
|
||||
itlist = [executor.submit(itInfo, it) for it in items if it['has_video'] and int(it['hour'].replace(':','')) <= h]
|
||||
for res in futures.as_completed(itlist):
|
||||
if res.result():
|
||||
itemlist.append(res.result())
|
||||
itemlist = sorted(itemlist, key=lambda it: it.title)
|
||||
|
||||
if not item.search and len(keys) > pag * pagination:
|
||||
itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), page=pag + 1, thumbnail=support.thumb()))
|
||||
if not itemlist:
|
||||
return [Item(title='Non ci sono Replay per questo Canale')]
|
||||
return itemlist
|
||||
|
||||
def play(item):
|
||||
logger.debug()
|
||||
|
||||
def select(item):
|
||||
support.info()
|
||||
itemlist = []
|
||||
if type(item.data) in [list, dict]:
|
||||
json = item.data
|
||||
else:
|
||||
json = current_session.get(item.url).json()
|
||||
if 'blocks' in json:
|
||||
json = json['blocks']
|
||||
season = ''
|
||||
for key in json:
|
||||
if item.fulltitle in key['name']: season = key['name'].replace(item.fulltitle, '').strip()
|
||||
if not season.isdigit(): season = ''
|
||||
itemlist.append(item.clone(title = support.typo(key['name'],'bold'), season = season, data = key['sets'], action = 'select'))
|
||||
if len(itemlist) == 1:
|
||||
return select(itemlist[0])
|
||||
else:
|
||||
if item.data:
|
||||
for key in item.data:
|
||||
itemlist.append(item.clone(title = support.typo(key['name'], 'bold'), data = getUrl(key['path_id']), url = getUrl(key['path_id']), contentType = 'tvshow', action = 'episodios'))
|
||||
if len(itemlist) == 1:
|
||||
return episodios(itemlist[0])
|
||||
elif 'contents' in json:
|
||||
for letter in json['contents'].keys():
|
||||
if json['contents'][letter]:
|
||||
itemlist.extend(peliculas(item.clone(data=json['contents'][letter])))
|
||||
return itemlist
|
||||
res = requests.get(item.video_url).json()
|
||||
|
||||
if 'first_item_path' in res:
|
||||
res = requests.get(getUrl(res['first_item_path'])).json()
|
||||
|
||||
url, lic = support.match(res['video']['content_url'] + '&output=56', patron=r'content"><!\[CDATA\[([^\]]+)(?:.*?"WIDEVINE","licenceUrl":"([^"]+))?').match
|
||||
|
||||
if lic:
|
||||
item.drm = 'com.widevine.alpha'
|
||||
item.license = lic + '|' + host + '|R{SSM}|'
|
||||
|
||||
item = item.clone(server='directo', url=url, no_return=True, manifest='hls')
|
||||
|
||||
return [item]
|
||||
|
||||
|
||||
def episodios(item):
|
||||
support.info()
|
||||
itemlist = []
|
||||
if type(item.data) in [list, dict] and len(item.data) > 1 and ('name' in item.data[0] and 'stagione' not in item.data[0]['name'].lower()):
|
||||
for key in item.data:
|
||||
itemlist.append(item.clone(title = support.typo(key['name'], 'bold'), url = getUrl(key['path_id']), contentType = 'tvshow', action = 'episodios'))
|
||||
def getUrl(url):
|
||||
logger.debug()
|
||||
|
||||
elif type(item.data) in [list, dict]:
|
||||
for key in item.data:
|
||||
load_episodes(key, item)
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
itlist = [executor.submit(load_episodes, key, item) for key in item.data]
|
||||
for res in futures.as_completed(itlist):
|
||||
if res.result():
|
||||
itemlist += res.result()
|
||||
if itemlist and itemlist[0].VL:
|
||||
# itemlist.reverse()
|
||||
itemlist = sorted(itemlist, key=lambda it: it.order)
|
||||
item.action = 'episodios'
|
||||
support.videolibrary(itemlist, item)
|
||||
else:
|
||||
itemlist = sorted(itemlist, key=lambda it: it.title)
|
||||
if url.startswith("/raiplay/"): url = url.replace("/raiplay/", host +'/')
|
||||
elif url.startswith("//"): url = "https:" + url
|
||||
elif url.startswith("/"): url = host + url
|
||||
|
||||
else:
|
||||
date = ''
|
||||
if type(item.data) in [list, dict]: item.data = getUrl(item.url[0]['path_id'])
|
||||
json = current_session.get(item.url).json()['items']
|
||||
for key in json:
|
||||
ep = support.match(key['subtitle'], patron=r'(?:St\s*(\d+))?\s*Ep\s*(\d+)').match
|
||||
if ep:
|
||||
season = '1' if not ep[0] else ep[0]
|
||||
episode = ep[1].zfill(2)
|
||||
title = support.re.sub(r'(?:St\s*\d+)?\s*Ep\s*\d+','',key['subtitle'])
|
||||
title = season + 'x' + episode + (' - ' + title if not title.startswith(' ') else title if title else '')
|
||||
elif item.season and support.match(item.title.lower(), patron =r'(puntate)').match:
|
||||
title = key['subtitle'].strip()
|
||||
if not title: title = key['name']
|
||||
date = support.match(title, patron=r'(\d+/\d+/\d+)').match
|
||||
if date:
|
||||
date = title.split('/')
|
||||
date = date[2][-2] + '/' + date[1] + '/' + date[0]
|
||||
|
||||
else:
|
||||
title = key['subtitle'].strip()
|
||||
if not title:
|
||||
title = key['name']
|
||||
itemlist.append(item.clone(title = support.typo(title, 'bold'), action = 'findvideos', VL=True if ep else False, plot = key['description'],
|
||||
fanart = getUrl(key['images']['landscape']), url = key['video_url'], contentType = 'episode', date=date))
|
||||
|
||||
if item.season and support.match(item.title.lower(), patron =r'(puntate)').match:
|
||||
itemlist = sorted(itemlist, key=lambda it: it.date)
|
||||
for i, it in enumerate(itemlist):
|
||||
episode = str(i + 1)
|
||||
it.title = support.typo(item.season + 'x' + episode, 'bold') + (' - ' + it.title)
|
||||
|
||||
if itemlist and itemlist[0].VL: support.videolibrary(itemlist, item)
|
||||
|
||||
if itemlist and not support.match(itemlist[0].title, patron=r'[Ss]?(\d+)(?:x|_|\.|\s+)[Ee]?[Pp]?(\d+)').match and inspect.stack()[1][3] not in ['find_episodes']:
|
||||
autorenumber.start(itemlist, item)
|
||||
return itemlist
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
support.info()
|
||||
itemlist = []
|
||||
if item.url.endswith('json'):
|
||||
json = current_session.get(item.url).json()
|
||||
|
||||
if 'first_item_path' in json:
|
||||
url = current_session.get(getUrl(json['first_item_path'])).json()['video']['content_url']
|
||||
else:
|
||||
url = json['video']['content_url']
|
||||
else:
|
||||
url = item.url
|
||||
|
||||
itemlist.append(item.clone(server = 'directo', title = 'Rai Play', url = getUrl(url) + '&output=56', action = 'play'))
|
||||
return support.server(item, itemlist=itemlist, Download=False)
|
||||
|
||||
|
||||
def getUrl(pathId):
|
||||
support.info()
|
||||
url = pathId.replace(" ", "%20")
|
||||
if url.startswith("/raiplay/"):
|
||||
url = url.replace("/raiplay/",host +'/')
|
||||
|
||||
if url.startswith("//"):
|
||||
url = "https:" + url
|
||||
elif url.startswith("/"):
|
||||
url = host + url
|
||||
|
||||
# fix format of url for json
|
||||
if url.endswith(".html?json"):
|
||||
url = url.replace(".html?json", ".json")
|
||||
elif url.endswith("/?json"):
|
||||
url = url.replace("/?json",".json")
|
||||
elif url.endswith("?json"):
|
||||
url = url.replace("?json",".json")
|
||||
url = url.replace(".html?json", ".json").replace("/?json",".json").replace("?json",".json").replace(" ", "%20")
|
||||
|
||||
return url
|
||||
|
||||
|
||||
def addinfo(key, item):
|
||||
support.info()
|
||||
info = current_session.get(getUrl(key['info_url'])).json() if 'info_url' in key else {}
|
||||
if 'images' in key:
|
||||
fanart = key['images']['landscape']
|
||||
if key['images']['portrait_logo']:
|
||||
thumb = key['images']['portrait_logo']
|
||||
def addinfo(items, item):
|
||||
def itInfo(key, item):
|
||||
logger.debug(jsontools.dump(key))
|
||||
item.forcethumb = True
|
||||
if key.get('titolo', ''):
|
||||
key = requests.get(getUrl(key['path_id'])).json()['program_info']
|
||||
|
||||
|
||||
info = requests.get(getUrl(key['info_url'])).json() if 'info_url' in key else {}
|
||||
|
||||
images = info.get('images', {})
|
||||
fanart = images.get('landscape', '')
|
||||
thumb = images.get('portrait_logo', '')
|
||||
if not thumb: thumb = fanart
|
||||
title = key.get('name', '')
|
||||
|
||||
it = item.clone(title=support.typo(title, 'bold'),
|
||||
data='',
|
||||
fulltitle=title,
|
||||
show=title,
|
||||
thumbnail= getUrl(thumb),
|
||||
fanart=getUrl(fanart),
|
||||
url=getUrl(key.get('weblink', '')),
|
||||
video_url=getUrl(key['path_id']),
|
||||
plot=info.get('description', ''))
|
||||
|
||||
if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'):
|
||||
it.action = 'play'
|
||||
it.contentTitle = it.fulltitle
|
||||
else:
|
||||
thumb = key['images']['landscape']
|
||||
else:
|
||||
thumb = ''
|
||||
fanart = ''
|
||||
it = item.clone(title=support.typo(key.get('name', ''), 'bold'), fulltitle=key.get('name', ''),
|
||||
show=key.get('name', ''), data='', thumbnail=getUrl(thumb),
|
||||
fanart=getUrl(fanart), url=getUrl(key['path_id']), plot=info.get('description', ''))
|
||||
it.action = 'episodios'
|
||||
it.contentSerieName = it.fulltitle
|
||||
return it
|
||||
|
||||
if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'):
|
||||
it.action = 'findvideos'
|
||||
it.contentType = 'movie'
|
||||
it.contentTitle = it.fulltitle
|
||||
else:
|
||||
it.action = 'select'
|
||||
it.contentType = 'tvshow'
|
||||
it.contentSerieName = it.fulltitle
|
||||
return it
|
||||
|
||||
|
||||
def load_episodes(key, item):
|
||||
support.info()
|
||||
itemlist = []
|
||||
json = current_session.get(getUrl(key['path_id'])).json()['items']
|
||||
order = 0
|
||||
for key in json:
|
||||
ep = support.match(key['subtitle'], patron=r'(?:St\s*(\d+))?\s*Ep\s*(\d+)').match
|
||||
if ep:
|
||||
season = '1' if not ep[0] else ep[0]
|
||||
episode = ep[1].zfill(2)
|
||||
title = season + 'x' + episode + support.re.sub(r'(?:St\s*\d+)?\s*Ep\s*\d+','',key['subtitle'])
|
||||
order = int(season + episode)
|
||||
else:
|
||||
title = key['subtitle'].strip()
|
||||
if not title:
|
||||
title = key['name']
|
||||
|
||||
itemlist.append(item.clone(title = support.typo(title, 'bold'), url = key['video_url'], contentType = 'episode',
|
||||
fanart = getUrl(key['images']['landscape']), plot = key['description'],
|
||||
action = 'findvideos', VL=True if ep else False, order=order))
|
||||
return itemlist
|
||||
|
||||
|
||||
def play(item):
|
||||
if item.livefilter:
|
||||
d = liveDict()
|
||||
item = item.clone(server='directo', fulltitle=item.livefilter, url=d[item.livefilter]['url'], plot=d[item.livefilter]['plot'], forcethumb=True, no_return=True)
|
||||
support.thumb(item, live=True)
|
||||
if '&output=56' in item.url:
|
||||
match = support.match(item, patron=r'content"><!\[CDATA\[([^\]]+)(?:.*?"WIDEVINE","licenceUrl":"([^"]+))?').match
|
||||
item.url = match[0]
|
||||
if len(match) == 2:
|
||||
item.drm = 'com.widevine.alpha'
|
||||
item.license = match[1] + '|' + host + '|R{SSM}|'
|
||||
logger.debug('PLAY URL', item.url)
|
||||
return [item]
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
itlist = [executor.submit(itInfo, it, item) for it in items]
|
||||
for res in futures.as_completed(itlist):
|
||||
if res.result():
|
||||
itemlist.append(res.result())
|
||||
return itemlist
|
||||
Reference in New Issue
Block a user