def show_replay_radio_epg(date, channelId): xbmc.log("Showing EPG for " + channelId + " on " + date) raiplayradio = RaiPlayRadio() programmes = raiplayradio.getProgrammes(channelId.decode("utf-8"), date) for programme in programmes: if not programme: continue startTime = programme["timePublished"] title = programme["name"] if programme["images"]["landscape"] != "": thumb = raiplayradio.getThumbnailUrl(programme["images"]["square"]) elif programme["isPartOf"] and programme["isPartOf"]["images"]["square"] != "": thumb = raiplayradio.getThumbnailUrl(programme["isPartOf"]["images"]["square"]) else: thumb = raiplayradio.noThumbUrl if programme["hasAudio"]: audioUrl = programme["pathID"] else: audioUrl = None if audioUrl is None: # programme is not available liStyle = xbmcgui.ListItem(startTime + " [I]" + title + "[/I]") liStyle.setThumbnailImage(thumb) addLinkItem({"mode": "nop"}, liStyle) else: liStyle = xbmcgui.ListItem(startTime + " " + title) liStyle.setThumbnailImage(thumb) addLinkItem({"mode": "play", "path_id": audioUrl}, liStyle) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_radio_channels(date): raiplay = RaiPlayRadio() radio_stations = raiplay.getChannels() for station in radio_stations: liStyle = xbmcgui.ListItem(station["channel"]) liStyle.setArt({"thumb": station["stillFrame"]}) addDirectoryItem({"mode": "replay", "media": "radio", "channel_id": station["channel"].encode("utf-8"), "date": date}, liStyle) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_radio_stations(): raiplay = RaiPlayRadio() radio_stations = raiplay.getChannels() for station in radio_stations: liStyle = xbmcgui.ListItem(station["channel"]) liStyle.setArt({"thumb": station["stillFrame"]}) liStyle.setInfo("music", {}) if 'contentUrl' in station['audio']: addLinkItem({"mode": "play", "url": station["audio"]["contentUrl"]}, liStyle) else: addLinkItem({"mode": "play", "url": station["audio"]["castUrl"]}, liStyle) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def play(url, pathId="", srt=[]): xbmc.log("Playing...") if pathId != "": xbmc.log("PathID: " + pathId) # Ugly hack if pathId[:7] == "/audio/": raiplayradio = RaiPlayRadio() metadata = raiplayradio.getAudioMetadata(pathId) url = metadata["contentUrl"] srtUrl = "" else: raiplay = RaiPlay() xbmc.log("Url: " + raiplay.getUrl(pathId)) metadata = raiplay.getVideoMetadata(pathId) url = metadata["content_url"] srtUrl = metadata["subtitles"] if srtUrl != "": xbmc.log("SRT URL: " + srtUrl) srt.append(srtUrl) # Handle RAI relinker if url[:53] == "http://mediapolis.rai.it/relinker/relinkerServlet.htm" or \ url[:56] == "http://mediapolisvod.rai.it/relinker/relinkerServlet.htm" or \ url[:58] == "http://mediapolisevent.rai.it/relinker/relinkerServlet.htm": xbmc.log("Relinker URL: " + url) relinker = Relinker() url = relinker.getURL(url) # Add the server to the URL if missing if url[0] == "/": url = raiplay.baseUrl[:-1] + url xbmc.log("Media URL: " + url) # Play the item try: item = xbmcgui.ListItem(path=url + '|User-Agent=' + urllib.quote_plus(Relinker.UserAgent)) except: item = xbmcgui.ListItem(path=url + '|User-Agent=' + urllib.parse.quote_plus(Relinker.UserAgent)) if len(srt) > 0: item.setSubtitles(srt) xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=item)
import resources.lib.utils as utils import re # plugin constants __plugin__ = "plugin.video.raitv" __author__ = "Nightflyer" Addon = xbmcaddon.Addon(id=__plugin__) # plugin handle handle = int(sys.argv[1]) # Cache channels for 1 hour cache = StorageServer.StorageServer("plugin.video.raitv", 1) # (Your plugin name, Cache time in hours) tv_stations = cache.cacheFunction(RaiPlay().getChannels) radio_stations = cache.cacheFunction(RaiPlayRadio().getChannels) # utility functions def parameters_string_to_dict(parameters): ''' Convert parameters encoded in a URL to a dict. ''' paramDict = dict(urlparse.parse_qsl(parameters[1:])) return paramDict def addDirectoryItem(parameters, li): url = sys.argv[0] + '?' + urlencode(parameters) return xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=li, isFolder=True) def addLinkItem(parameters, li, url=""): if url == "": url = sys.argv[0] + '?' + urlencode(parameters)
from resources.lib.tgr import TGR from resources.lib.search import Search from resources.lib.raiplay import RaiPlay from resources.lib.raiplayradio import RaiPlayRadio from resources.lib.relinker import Relinker import resources.lib.utils as utils import re # plugin constants __plugin__ = "plugin.video.raitv" __author__ = "Nightflyer" Addon = xbmcaddon.Addon(id=__plugin__) tv_stations = RaiPlay(Addon).getChannels radio_stations = RaiPlayRadio().getChannels raisport_keys = RaiPlay(Addon).fillRaiSportKeys # plugin handle handle = int(sys.argv[1]) # utility functions def parameters_string_to_dict(parameters): ''' Convert parameters encoded in a URL to a dict. ''' paramDict = dict(urlparse.parse_qsl(parameters[1:])) return paramDict def addDirectoryItem(parameters, li):