diff --git a/README b/README deleted file mode 100644 index e69de29..0000000 diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c51ef6 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ + +Kodi VideoMediaset addon +=================================== + +### Info +A kodi plugin to access videomediaset website and its content. +The addon was originally created by Aracnoz. I updated it after site changes and with new features. + +### Features +- [ ] Watch Mediaset live channels +- [ ] Watch videos by program +- [ ] Watch video by category +- [ ] Watch video by channel +- [ ] Watch most popular videos +- [ ] Search videos in the archive + +### www +* [Official Topic](http://forum.xbmc.org/showthread.php?tid=292876) +* [Kodi Official Page](http://addons.kodi.tv/show//) + +### Latest release +Manual install: [Download ZIP](https://github.com/phate89/plugin.video.videomediaset/releases) +Require: [script.module.phate89 v1.0.0](https://github.com/phate89/script.module.phate89/releases/download/1.0.0/script.module.phate89.v1.0.0.zip) + +### Thanks +* To Aracnoz for the first addon version! +* To Mediaset for provinding the content and the api! + +### Issues +If you find some issue please post [in the forum](http://forum.xbmc.org/showthread.php?tid=292876) or [in the github issue page](https://github.com/phate89/plugin.video.videomediaset/issues) with a [debug log](http://kodi.wiki/view/Debug_Log) and all the steps to reproduce the issue + +### Support +* If you would like contribute to the projects, feel free to do: fork, pull-request, issues, etc... They're higly welcome +* Instead if you would like offer me a coffee or beer: [Donate with PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JD4LD62T6EJRS&lc=GB&item_name=phate89%20Kodi%20Addons¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) diff --git a/addon.xml b/addon.xml index 8397f49..4dba3d9 100644 --- a/addon.xml +++ b/addon.xml @@ -1,11 +1,11 @@ - + - - + + - video audio + video it @@ -14,5 +14,12 @@ Tutti i tuoi programmi preferiti sono disponibili per te il giorno dopo la messa in onda Tv. Ieri sera ti sei perso la tua fiction preferita? Nessun problema finalmente puoi rivederla comodamente su KODI ogni volta che vuoi. The broadcasts of Mediaset channels All your favorite shows are available to you the day after the airing Tv. Last night you missed your favorite TV drama? No problem, you can finally see her comfortably on KODI whenever you want. + GNU GENERAL PUBLIC LICENSE. Version 2, June 1991 + http://forum.kodi.tv/showthread.php?tid=292876 + https://github.com/phate89/plugin.video.videomediaset + v1.2.0 +- fixed the addon after website changes +- added images to program lists +- refactored the code diff --git a/changelog.txt b/changelog.txt index c1f5beb..806a14c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +[B]1.2.0[/B] +- fixed the addon after website changes +- added images to program lists +- refactored the code + [B]1.1.0[/B] - added section "Canali Live" diff --git a/default.py b/default.py index 5aa9480..44093bb 100644 --- a/default.py +++ b/default.py @@ -1,28 +1,9 @@ # -*- coding: utf-8 -*- -import os -import sys -import xbmc -import xbmcgui -import xbmcplugin -import xbmcaddon -import urllib -import urlparse from resources.lib.mediaset import Mediaset +from phate89lib import kodiutils, staticutils -# plugin constants -__plugin__ = "plugin.video.videomediaset" -__author__ = "aracnoz" - -Addon = xbmcaddon.Addon(id=__plugin__) - -# plugin handle -handle = int(sys.argv[1]) - -# utility functions -def parameters_string_to_dict(parameters): - paramDict = dict(urlparse.parse_qsl(parameters[1:])) - return paramDict - +mediaset = Mediaset() +mediaset.log = kodiutils.log def pulisci_cerca(s): s = s.lower() s = s.replace("à","a") @@ -35,191 +16,170 @@ def pulisci_cerca(s): s = s.replace("'","-") return s -def parameters (p): - return sys.argv[0] + '?' + urllib.urlencode(p) - -def addDir (s,p): - item = xbmcgui.ListItem(s) - return xbmcplugin.addDirectoryItem(handle=handle, url=parameters(p), listitem=item, isFolder=True) - -def addDir_ep (s,t,p): - item = xbmcgui.ListItem("[COLOR blue]"+s+"[/COLOR]",thumbnailImage=t) - return xbmcplugin.addDirectoryItem(handle=handle, url=parameters(p), listitem=item, isFolder=False) - def stamp_ep(ep): - addDir_ep(ep["titolo"],ep["thumbs"],{'mode':'playMediaset','title':ep["titolo"],'stream_id':ep["id"],'thumbs':ep["thumbs"],'desc':ep["desc"]}) + ep['mediatype'] = 'video' + kodiutils.addListItem("[COLOR blue]"+ep["title"]+"[/COLOR]", {'mode':'playMediaset','id':ep["id"]}, thumb=ep["thumbs"],videoInfo=ep,isFolder=False) def stamp_live(ch): - addDir_ep(ch["titolo"],ch["thumbs"],{'mode':'playLive','title':ch["titolo"],'stream_url':ch["url"],'thumbs':ch["thumbs"],'desc':ch["desc"]}) - -def endDir(): - return xbmcplugin.endOfDirectory(handle=handle, succeeded=True) - -# UI builder functions + ch['mediatype'] = 'video' + kodiutils.addListItem("[COLOR blue]"+ch["title"]+"[/COLOR]", {'mode':'playLive','stream_url':ch["url"]}, thumb=kodiutils.IMAGE_PATH_T + ch["thumbs"],videoInfo=ch,isFolder=False) def root(): - addDir("Canali Live",{'mode':'canali_live'}) - addDir("Elenco programmi",{'mode':'elenco_programmi'}) - addDir("Ultime puntate News",{'mode':'ultime_puntate','prog_tipo':'news'}) - addDir("Ultime puntate Sport",{'mode':'ultime_puntate','prog_tipo':'sport'}) - addDir("Ultime puntate Intrattenimento",{'mode':'ultime_puntate','prog_tipo':'intrattenimento'}) - addDir("Ultime puntate Fiction",{'mode':'ultime_puntate','prog_tipo':'fiction'}) - addDir("Ultime puntate Elenco canali",{'mode':'ultime_puntate_canali'}) - addDir("Ultime Sport Mediaset",{'mode':'sportmediaset'}) - addDir("Più visti Ieri",{'mode':'piuvisti','range_visti':'ieri'}) - addDir("Più visti Settimana",{'mode':'piuvisti','range_visti':'settimana'}) - addDir("Più visti Mese",{'mode':'piuvisti','range_visti':'mese'}) - addDir("Cerca...",{'mode':'cerca'}) - endDir() + kodiutils.addListItem("Canali Live",{'mode':'canali_live'}) + kodiutils.addListItem("Elenco programmi",{'mode':'elenco_programmi'}) + kodiutils.addListItem("Ultime puntate News",{'mode':'ultime_puntate','prog_tipo':'news'}) + kodiutils.addListItem("Ultime puntate Sport",{'mode':'ultime_puntate','prog_tipo':'sport'}) + kodiutils.addListItem("Ultime puntate Intrattenimento",{'mode':'ultime_puntate','prog_tipo':'intrattenimento'}) + kodiutils.addListItem("Ultime puntate Fiction",{'mode':'ultime_puntate','prog_tipo':'fiction'}) + kodiutils.addListItem("Ultime puntate Elenco canali",{'mode':'ultime_puntate_canali'}) + kodiutils.addListItem("Ultime Sport Mediaset",{'mode':'sportmediaset'}) + kodiutils.addListItem("Più visti Ieri",{'mode':'piuvisti','range_visti':'ieri'}) + kodiutils.addListItem("Più visti Settimana",{'mode':'piuvisti','range_visti':'settimana'}) + kodiutils.addListItem("Più visti Mese",{'mode':'piuvisti','range_visti':'mese'}) + kodiutils.addListItem("Cerca...",{'mode':'cerca'}) + kodiutils.endScript() def sportmediaset_root(): - addDir("Highlights",{'mode':'sportmediaset','progsport_tipo':'tutti_i_gol'}) - addDir("Calcio",{'mode':'sportmediaset','progsport_tipo':'calcio'}) - addDir("Champions League",{'mode':'sportmediaset','progsport_tipo':'champions_league'}) - addDir("Europa League",{'mode':'sportmediaset','progsport_tipo':'europa_league'}) - addDir("Altri sport",{'mode':'sportmediaset','progsport_tipo':'altrisport'}) - addDir("Motori",{'mode':'sportmediaset','progsport_tipo':'motori'}) - endDir() + kodiutils.addListItem("Highlights",{'mode':'sportmediaset','progsport_tipo':'/tutti_i_gol/'}) + kodiutils.addListItem("Calcio",{'mode':'sportmediaset','progsport_tipo':'/calcio/'}) + kodiutils.addListItem("Champions League",{'mode':'sportmediaset','progsport_tipo':'/champions_league/'}) + kodiutils.addListItem("Europa League",{'mode':'sportmediaset','progsport_tipo':'/europa_league/'}) + kodiutils.addListItem("Superbike",{'mode':'sportmediaset','progsport_tipo':'/superbike/'}) + kodiutils.addListItem("Altri sport",{'mode':'sportmediaset','progsport_tipo':'/altrisport/'}) + kodiutils.addListItem("Motori",{'mode':'sportmediaset','progsport_tipo':'/motori/'}) + kodiutils.endScript() def puntate_canali_root(): - addDir("Italia 1",{'mode':'ultime_puntate','prog_tipo':' i1 '}) - addDir("Canale 5",{'mode':'ultime_puntate','prog_tipo':' c5 '}) - addDir("Rete 4",{'mode':'ultime_puntate','prog_tipo':' r4 '}) - addDir("Italia 2",{'mode':'ultime_puntate','prog_tipo':' i2 '}) - addDir("La 5",{'mode':'ultime_puntate','prog_tipo':' ka '}) - endDir() + kodiutils.addListItem("Italia 1",{'mode':'ultime_puntate','prog_tipo':'I1'}, thumb=kodiutils.IMAGE_PATH_T + "Italia_1.png") + kodiutils.addListItem("Canale 5",{'mode':'ultime_puntate','prog_tipo':'C5'}, thumb=kodiutils.IMAGE_PATH_T + "Canale_5.png") + kodiutils.addListItem("Rete 4",{'mode':'ultime_puntate','prog_tipo':'R4'}, thumb=kodiutils.IMAGE_PATH_T + "Rete_4.png") + kodiutils.addListItem("Italia 2",{'mode':'ultime_puntate','prog_tipo':'I2'}, thumb=kodiutils.IMAGE_PATH_T + "Italia_2.png") + kodiutils.addListItem("La 5",{'mode':'ultime_puntate','prog_tipo':'KA'}, thumb=kodiutils.IMAGE_PATH_T + "La_5.png") + kodiutils.addListItem("TGCOM24",{'mode':'ultime_puntate','prog_tipo':'KF'}, thumb=kodiutils.IMAGE_PATH_T + "TGCOM24.png") + kodiutils.addListItem("Iris",{'mode':'ultime_puntate','prog_tipo':'KI'}, thumb=kodiutils.IMAGE_PATH_T + "Iris.png") + kodiutils.endScript() def canali_live_root(): - mediaset = Mediaset() + kodiutils.setContent('videos') for ch in mediaset.get_canali_live(): stamp_live(ch) - endDir() + kodiutils.endScript() def elenco_programmi_root(): - mediaset = Mediaset() for lettera in mediaset.get_prog_root(): - addDir(lettera["index"],{'mode':'elenco_programmi','prog_id':lettera["index"]}) - endDir() + kodiutils.addListItem(lettera["index"],{'mode':'elenco_programmi','prog_id':lettera["index"]}) + kodiutils.endScript() def elenco_programmi_list(progId): - mediaset = Mediaset() + kodiutils.setContent('videos') for lettera in mediaset.get_prog_root(): if lettera['index'] == progId: for programma in lettera["program"]: - addDir(programma["label"],{'mode':'elenco_programmi','prog_id':lettera["index"],'prog_url':programma["url"].replace("archivio-news.shtml","archivio-video.shtml")}) - endDir() + kodiutils.addListItem(programma["label"],{'mode':'elenco_programmi','prog_url':programma["url"]}, thumb=programma['thumbnail']) + kodiutils.endScript() -def elenco_programmi_epList(progId,progUrl): - mediaset = Mediaset() - for ep in mediaset.get_prog_epList(progUrl): - stamp_ep(ep) +def elenco_programmi_groupList(progUrl): + for group in mediaset.get_url_groupList(progUrl): + kodiutils.addListItem(group["title"], {'mode':'elenco_programmi', 'group_url': group["url"]}) for season in mediaset.get_prog_seasonList(progUrl): - addDir(season["titolo"],{'mode':'elenco_programmi','prog_id':progId,'prog_url':season["url"]}) - endDir() + kodiutils.addListItem(season["title"],{'mode':'elenco_programmi','prog_url':season["url"]}) + kodiutils.endScript() + +def elenco_programmi_epList(groupUrl): + kodiutils.setContent('videos') + for ep in mediaset.get_prog_epList(groupUrl): + stamp_ep(ep) + kodiutils.endScript() def sportmediaset_epList(progsportTipo): - mediaset = Mediaset() - for ep in mediaset.get_sport_epList(): - if (ep["tipo"].lower().find(progsportTipo) > 0): stamp_ep(ep) - endDir() + kodiutils.setContent('videos') + for ep in mediaset.get_global_epList(2): + if (progsportTipo in ep["url"]): stamp_ep(ep) + kodiutils.endScript() def puntate_epList(progTipo): - mediaset = Mediaset() - for ep in mediaset.get_global_epList(0,0): - if (ep["tipo"].lower().find(progTipo) > 0): stamp_ep(ep) - endDir() + kodiutils.setContent('videos') + for ep in mediaset.get_global_epList(0): + if (progTipo in ep["tipo"]): stamp_ep(ep) + kodiutils.endScript() def piuvisti_epList(rangeVisti): - mediaset = Mediaset() + kodiutils.setContent('videos') for ep in mediaset.get_global_epList(1,rangeVisti): stamp_ep(ep) - endDir() + kodiutils.endScript() def cerca(): - kb = xbmc.Keyboard() + kodiutils.setContent('videos') + kb = kodiutils.getKeyboard() kb.setHeading("Cerca un programma") kb.doModal() if kb.isConfirmed(): text = kb.getText() text = pulisci_cerca(text) - mediaset = Mediaset() for lettera in mediaset.get_prog_root(): for programma in lettera["program"]: if (programma["mc"].find(text) > 0): - addDir(programma["label"],{'mode':'elenco_programmi','prog_id':lettera["index"],'prog_url':programma["url"].replace("archivio-news.shtml","archivio-video.shtml")}) - endDir() + kodiutils.addListItem(programma["label"],{'mode':'elenco_programmi','prog_url':programma["url"]}, thumb=programma['thumbnail']) + kodiutils.endScript() -def playMediaset(title,streamId,thumbs,desc): - mediaset = Mediaset() +def playMediaset(streamId): url = mediaset.get_stream(streamId) - + if (url): + # Play the item + if ("mp4" in url): kodiutils.setResolvedUrl(url["mp4"]) + elif ("f4v" in url): kodiutils.setResolvedUrl(url["f4v"]) + elif ("wmv" in url): kodiutils.setResolvedUrl(url["wmv"]) + kodiutils.setResolvedUrl(solved=False) + +def playLive(streamUrl): # Play the item - item=xbmcgui.ListItem(title, thumbnailImage=thumbs) - item.setInfo(type="Video", infoLabels={"Title": title, "Plot":desc}) - - if (url["mp4"] != ""): stream = url["mp4"] - else: stream = url["wmv"] - - print "videomediaset: play %s" % stream - xbmc.Player().play(stream,item) - -def playLive(title,streamUrl,thumbs,desc): - # Play the item - item=xbmcgui.ListItem(title, thumbnailImage=thumbs) - item.setInfo(type="Video", infoLabels={"Title": title, "Plot":desc}) - - print "videomediaset: play %s" % streamUrl - xbmc.Player().play(streamUrl,item) + kodiutils.setResolvedUrl(streamUrl) # parameter values -params = parameters_string_to_dict(sys.argv[2]) +params = staticutils.getParams() mode = str(params.get("mode", "")) progId = str(params.get("prog_id", "")) progUrl = str(params.get("prog_url", "")) +groupUrl = str(params.get("group_url", "")) progTipo = str(params.get("prog_tipo", "")) progsportTipo = str(params.get("progsport_tipo", "")) title = str(params.get("title", "")) -streamId = str(params.get("stream_id", "")) +streamId = str(params.get("id", "")) streamUrl = str(params.get("stream_url", "")) thumbs = str(params.get("thumbs", "")) desc = str(params.get("desc", "")) rangeVisti = str(params.get("range_visti", "")) -if mode == "canali_live": - canali_live_root() - -elif mode == "elenco_programmi": - if progId == "": - elenco_programmi_root() - elif progUrl == "": - elenco_programmi_list(progId) - else: - elenco_programmi_epList(progId,progUrl) - -elif mode == "sportmediaset": - if progsportTipo == "": - sportmediaset_root() - else: - sportmediaset_epList(progsportTipo) - -elif mode == "ultime_puntate": - puntate_epList(progTipo) - -elif mode == "ultime_puntate_canali": - puntate_canali_root() - -elif mode == "piuvisti": - piuvisti_epList(rangeVisti) - -elif mode == "cerca": - cerca() - -elif mode == "playMediaset": - playMediaset(title, streamId, thumbs, desc) - -elif mode == "playLive": - playLive(title, streamUrl, thumbs, desc) - +if 'mode' in params: + if params['mode'] == "canali_live": + canali_live_root() + elif params['mode'] == "elenco_programmi": + if 'prog_id' in params: + elenco_programmi_list(params['prog_id']) + elif 'prog_url' in params: + elenco_programmi_groupList(params['prog_url']) + elif 'group_url' in params: + elenco_programmi_epList(params['group_url']) + else: + elenco_programmi_root() + elif params['mode'] == "sportmediaset": + if 'progsport_tipo'in params: + sportmediaset_epList(params['progsport_tipo']) + else: + sportmediaset_root() + elif params['mode'] == "ultime_puntate": + puntate_epList(params['prog_tipo']) + elif params['mode'] == "ultime_puntate_canali": + puntate_canali_root() + elif params['mode'] == "piuvisti": + piuvisti_epList(params['range_visti']) + elif params['mode'] == "cerca": + cerca() + elif params['mode'] == "playMediaset": + playMediaset(params['id']) + elif params['mode'] == "playLive": + playLive(params['stream_url']) else: root() diff --git a/resources/lib/mediaset.py b/resources/lib/mediaset.py index a007a82..027ca1e 100644 --- a/resources/lib/mediaset.py +++ b/resources/lib/mediaset.py @@ -1,172 +1,134 @@ -import urllib -import urllib2 -import json +from phate89lib import rutils import re import math -from bs4 import BeautifulSoup -class Mediaset: +class Mediaset(rutils.RUtils): - def get_prog_root(self): + USERAGENT="VideoMediaset Kodi Addon" - url = "http://www.video.mediaset.it/programma/game15.json" - data = json.load(urllib2.urlopen(url)) + def get_prog_root(self): + self.log('Trying to get the program list', 4) + url = "http://www.video.mediaset.it/programma/progr_archivio.json" + data = self.getJson(url) return data["programmi"]["group"] - def get_prog_epList(self, url): - - arrdata = [] - url = url.replace("http://www.video.mediaset.it","") - url = "http://www.video.mediaset.it%s" % (url) - response = urllib2.urlopen(url) - html = response.read() - response.close() - - matches = re.search(r'
',html) - try: - programma = matches.group(2) - stagione = matches.group(3) - maxres = int(matches.group(4)) - strip = matches.group(5) - tipo = matches.group(6) - - except: - return arrdata - + def get_url_groupList(self,url): + self.log('Trying to get the groups from program url ' + url, 4) + if not url.startswith("http"): + url="http://www.video.mediaset.it"+url + url=url.replace("archivio-news.shtml","archivio-video.shtml") + soup=self.getSoup(url) + container=soup.find("div", class_="main-container") + subparts=container.find_all('section') + elements = [] + for subpart in subparts: + name = subpart.find('h2') + if name and name.text.strip(): + data=subpart.find('div') + if data: + elements.append({'title': name.text.strip(), + 'url': "http://www.video.mediaset.it/{type}/{area}/{box}.shtml".format(type=data['data-type'],area=data['data-area'],box=data['data-box'])}) + return elements + + def get_prog_epList(self,url): + self.log('Trying to get the episodes from group url ' + url, 4) totres = 0 count = 0 page = 1 - totpage = 0 - url = "http://www.video.mediaset.it/%s/%s/%s.shtml" % (tipo,programma,stagione) - - while (count < maxres): - nurl = "%s?page=%s&dim=%s" % (url,page,strip) - response = urllib2.urlopen(nurl) - html = response.read() - response.close() - if (totres == 0): - try: - matches = re.search(r'
',html) - totres = int(matches.group(1)) - maxres = totres - totpage = math.ceil(float(totres) / float(strip)) - except: - break - - matches = re.findall(r'
([\s\S]*?)<',html) - for res in matches: - - tmp = str(BeautifulSoup(res[1])) - a = {'id': res[0],'titolo':tmp,'thumbs':res[3].replace("176x99","640x360"),'desc':res[4]} - arrdata.append(a); - count = count +1 - - page = page +1 - if page > totpage: break; + arrdata=[] + maxpage = 200 + while (page < maxpage): + nurl = "{url}?page={page}".format(url=url,page=page) + soup = self.getSoup(nurl) + videos = soup.find_all('div',class_='box') + if videos: + for video in videos: + if totres == 0 and video.has_attr('data-maxitem'): + totres = float(video['data-maxitem']) + maxpage = totres + totpage = math.ceil(totres / 2) + img = video.find('img') + p = video.find('p') + arrdata.append({'id': video['data-id'],'title':img['alt'].encode('utf-8'),'thumbs':img['data-src'].replace("176x99","640x360"),'plot':p.text.strip().encode('utf-8')}); + page = page + 1 return arrdata - def get_prog_seasonList(self, url): - + def get_prog_seasonList(self,url): + self.log('Trying to get the seasons from program url ' + url, 4) + if not url.startswith("http"): + url="http://www.video.mediaset.it"+url + url=url.replace("archivio-news.shtml","archivio-video.shtml") + soup = self.getSoup(url) arrdata = [] - url = url.replace("http://www.video.mediaset.it","") - url = "http://www.video.mediaset.it%s" % (url) - response = urllib2.urlopen(url) - html = response.read() - response.close() - matches = re.search(r'href="#">Stagione[\s\S]*?
    ([\s\S]*?)
',html) - try: - seasonHtml = matches.group(1) - except: - return arrdata - - - matches = re.findall(r'
  • [\s\S]*?[\s\S]*?title="([^"]+)"[\s\S]*?

    ([\s\S]*?)<',html) - for res in matches: - - tmp = "%s - %s" % (res[4],res[1]) - tmp = str(BeautifulSoup(tmp)) - a = {'id': res[2],'titolo':tmp,'tipo':res[0],'thumbs':res[3].replace("176x99","640x360"),'desc':res[5]} - arrdata.append(a); - + url = "http://www.video.mediaset.it/piu_visti/piuvisti-{range}.shtml?page=all".format(range=range) + elif mode == 2: + url = "http://www.video.mediaset.it/bacino/bacinostrip_5.shtml?page=all" + + soup = self.getSoup(url) + arrdata=[] + videos = soup.find_all('div',class_='box') + if videos: + for video in videos: + a = video.find('a', {'data-type': 'video'}) + img = a.find('img') + imgurl = img['data-src'] + res = re.search("([0-9][0-9][0-9][0-9][0-9]+)",imgurl) + if res: + idv = res.group(1) + else: + idv = re.search("([0-9][0-9][0-9][0-9][0-9]+)",a['href']).group(1) + p = video.find('p', class_='descr') + arrdata.append({'id': idv,'url':a['href'],'title':img['alt'].encode("utf-8"),'tipo':video['class'],'thumbs':imgurl.replace("176x99","640x360"),'plot':p.text.strip().encode("utf-8")}) return arrdata - - def get_sport_epList(self): - - arrdata = [] - url = "http://www.video.mediaset.it/bacino/bacinostrip_5.shtml?page=all" - response = urllib2.urlopen(url) - html = response.read() - response.close() - - matches = re.findall(r'

    [\s\S]*?href=.+([0-9][0-9][0-9][0-9][0-9][0-9])[\s\S]*?

    ([\s\S]*?)<',html) - for res in matches: - - tmp = str(BeautifulSoup(res[0])) - a = {'id': res[3],'titolo':tmp,'tipo':res[1],'thumbs':res[2].replace("176x99","640x360"),'desc':res[4]} - arrdata.append(a); - - return arrdata - - def get_canali_live(self): + self.log('Getting the list of live channels', 4) - url = "http://live1.msf.ticdn.it/Content/HLS/Live/Channel(CH%sHA)/Stream(04)/index.m3u8" - tmb = "https://raw.githubusercontent.com/aracnoz/videomediaset_logo/master/%s.png" + url = "http://live1.msf.ticdn.it/Content/HLS/Live/Channel(CH{ch}HA)/Stream(04)/index.m3u8" arrdata = [] - arrdata.append({'titolo':"Canale 5", 'url':url % ('01'),'desc':"",'thumbs':tmb % ("Canale_5")}) - arrdata.append({'titolo':"Italia 1", 'url':url % ('02'),'desc':"",'thumbs':tmb % ("Italia_1")}) - arrdata.append({'titolo':"Rete 4", 'url':url % ('03'),'desc':"",'thumbs':tmb % ("Rete_4")}) - arrdata.append({'titolo':"La 5", 'url':url % ('04'),'desc':"",'thumbs':tmb % ("La_5")}) - arrdata.append({'titolo':"Italia 2", 'url':url % ('05'),'desc':"",'thumbs':tmb % ("Italia_2")}) - arrdata.append({'titolo':"Iris", 'url':url % ('06'),'desc':"",'thumbs':tmb % ("Iris")}) - arrdata.append({'titolo':"Top Crime", 'url':url % ('07'),'desc':"",'thumbs':tmb % ("Top_Crime")}) - arrdata.append({'titolo':"Premium Extra", 'url':url % ('08'),'desc':"",'thumbs':tmb % ("Premium_Extra")}) - arrdata.append({'titolo':"Mediaset Extra", 'url':url % ('09'),'desc':"",'thumbs':tmb % ("Mediaset_Extra")}) - + arrdata.append({'title':"Canale 5", 'url':url.format(ch='01'),'thumbs': "Canale_5.png"}) + arrdata.append({'title':"Italia 1", 'url':url.format(ch='02'),'thumbs': "Italia_1.png"}) + arrdata.append({'title':"Rete 4", 'url':url.format(ch='03'),'thumbs': "Rete_4.png"}) + arrdata.append({'title':"La 5", 'url':url.format(ch='04'),'thumbs': "La_5.png"}) + arrdata.append({'title':"Italia 2", 'url':url.format(ch='05'),'thumbs': "Italia_2.png"}) + arrdata.append({'title':"Iris", 'url':url.format(ch='06'),'thumbs': "Iris.png"}) + arrdata.append({'title':"Top Crime", 'url':url.format(ch='07'),'thumbs': "Top_Crime.png"}) + arrdata.append({'title':"Mediaset Extra", 'url':url.format(ch='09'),'thumbs': "Mediaset_Extra.png"}) + arrdata.append({'title':"TGCOM24", 'url':url.format(ch='10'),'thumbs': "TGCOM24.png"}) return arrdata def get_stream(self, id): + self.log('Trying to get the stream with id ' + str(id), 4) - url = "http://cdnselector.xuniplay.fdnames.com/GetCDN.aspx?streamid=%s&format=json" % (id) - - response = urllib2.urlopen(url) - html = response.read() - response.close() + url = "http://cdnselector.xuniplay.fdnames.com/GetCDN.aspx?streamid={id}&format=json".format(id=id) - html = html.replace('(','') - html = html.replace(')','') - data = json.loads(html) + jsn = self.getJson(url) - stream = {"wmv":"","mp4":""} - for vlist in data["videoList"]: - print "videomediaset: streams %s" % vlist - if ( vlist.find("/wmv2/") > 0): stream["wmv"] = vlist - if ( vlist.find("/mp4/") > 0): stream["mp4"] = vlist + if jsn and jsn["state"]=="OK": - return stream \ No newline at end of file + stream = {} + for vlist in jsn["videoList"]: + self.log( "videomediaset: streams {url}".format(url=vlist)) + if ( vlist.find("/wmv2/") > 0): stream["wmv"] = vlist + if ( vlist.find("/mp4/") > 0): stream["mp4"] = vlist + if ( vlist.find("/mp4/") > 0): stream["f4v"] = vlist + if ( vlist.find("/mp4/") > 0): stream["smoothstream"] = vlist + return stream + return False \ No newline at end of file diff --git a/resources/media/Canale_5.png b/resources/media/Canale_5.png new file mode 100644 index 0000000..ef33ac1 Binary files /dev/null and b/resources/media/Canale_5.png differ diff --git a/resources/media/Iris.png b/resources/media/Iris.png new file mode 100644 index 0000000..775984d Binary files /dev/null and b/resources/media/Iris.png differ diff --git a/resources/media/Italia_1.png b/resources/media/Italia_1.png new file mode 100644 index 0000000..ff3d4b5 Binary files /dev/null and b/resources/media/Italia_1.png differ diff --git a/resources/media/Italia_2.png b/resources/media/Italia_2.png new file mode 100644 index 0000000..3e29ba1 Binary files /dev/null and b/resources/media/Italia_2.png differ diff --git a/resources/media/La_5.png b/resources/media/La_5.png new file mode 100644 index 0000000..9073ef1 Binary files /dev/null and b/resources/media/La_5.png differ diff --git a/resources/media/Mediaset_Extra.png b/resources/media/Mediaset_Extra.png new file mode 100644 index 0000000..7478df7 Binary files /dev/null and b/resources/media/Mediaset_Extra.png differ diff --git a/resources/media/Rete_4.png b/resources/media/Rete_4.png new file mode 100644 index 0000000..1a628d1 Binary files /dev/null and b/resources/media/Rete_4.png differ diff --git a/resources/media/TGCOM24.png b/resources/media/TGCOM24.png new file mode 100644 index 0000000..bda016d Binary files /dev/null and b/resources/media/TGCOM24.png differ diff --git a/resources/media/Top_Crime.png b/resources/media/Top_Crime.png new file mode 100644 index 0000000..8f92091 Binary files /dev/null and b/resources/media/Top_Crime.png differ