def play(url, uniquename="", pathId=""): # Retrieve the file URL if missing if uniquename != "": xbmc.log("Uniquename: " + uniquename) ondemand = OnDemand() (url, mediatype) = ondemand.getMediaUrl(uniquename) if pathId != "": xbmc.log("PathID: " + pathId) ondemand = OnDemand() url = ondemand.getVideoUrl(pathId) # 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 != "" and url.find("://") == -1: url = ondemand.baseUrl + url xbmc.log("Media URL: " + url) # It seems that all .ram files I found are not working # because upstream file is no longer present if url[-4:].lower() == ".ram": dialog = xbmcgui.Dialog() dialog.ok("Errore", "I file RealAudio (.ram) non sono supportati.") return # Play the item item = xbmcgui.ListItem(path=url) xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=item)
def play(title, url, thumbailUrl="", uniquename="", mediatype="RaiTv Media Video Item"): # Retrieve the file URL if missing if uniquename != "": ondemand = OnDemand() (url, mediatype) = ondemand.getMediaUrl(uniquename) # Handle RAI relinker if url[:53] == "http://mediapolis.rai.it/relinker/relinkerServlet.htm" or \ url[:56] == "http://mediapolisvod.rai.it/relinker/relinkerServlet.htm": relinker = Relinker() url = relinker.getURL(url) # Add the server to the URL if missing if url !="" and url.find("://") == -1: url = ondemand.baseUrl + url print "Playing URL: %s" % url # It seems that all .ram files I found are not working # because upstream file is no longer present if url[-4:].lower() == ".ram": dialog = xbmcgui.Dialog() dialog.ok("Errore", "I file RealAudio (.ram) non sono supportati.") return # Play the item item=xbmcgui.ListItem(title, thumbnailImage=thumbailUrl) if mediatype == "RaiTv Media Video Item": item.setInfo(type="Video", infoLabels={"Title": title}) elif mediatype == "RaiTv Media Audio Item": item.setInfo(type="Audio", infoLabels={"Title": title}) xbmc.Player().play(url, item)
def play(title, url, thumbailUrl="", uniquename="", mediatype="RaiTv Media Video Item"): # Retrieve the file URL if missing if uniquename != "": ondemand = OnDemand() (url, mediatype) = ondemand.getMediaUrl(uniquename) # Handle RAI relinker if url[:53] == "http://mediapolis.rai.it/relinker/relinkerServlet.htm" or \ url[:56] == "http://mediapolisvod.rai.it/relinker/relinkerServlet.htm": relinker = Relinker() url = relinker.getURL(url) # Add the server to the URL if missing if url != "" and url.find("://") == -1: url = ondemand.baseUrl + url print "Playing URL: %s" % url # It seems that all .ram files I found are not working # because upstream file is no longer present if url[-4:].lower() == ".ram": dialog = xbmcgui.Dialog() dialog.ok("Errore", "I file RealAudio (.ram) non sono supportati.") return # Play the item item = xbmcgui.ListItem(title, thumbnailImage=thumbailUrl) if mediatype == "RaiTv Media Video Item": item.setInfo(type="Video", infoLabels={"Title": title}) elif mediatype == "RaiTv Media Audio Item": item.setInfo(type="Audio", infoLabels={"Title": title}) xbmc.Player().play(url, item)
def show_ondemand_items(uniquename, mediatype): ondemand = OnDemand() items = ondemand.getItems(uniquename, mediatype) for item in items: # Change date format item["date"] = item["date"].replace("/", ".") item["date"] = item["date"].replace("-", ".") # Get best thumbnail available if "image_medium" in item and item["image_medium"] != "": thumb = item["image_medium"] elif "image" in item and item["image"] != "": thumb = item["image"] else: thumb = ondemand.nothumb # Add the server to the URL if missing if thumb[:7] != "http://": thumb = ondemand.baseUrl + thumb if mediatype == "V": # Get best video available if "h264" in item and item["h264"] != "": url = item["h264"] elif "wmv" in item and item["wmv"] != "": url = item["wmv"] else: url = item["mediaUri"] labels = { "title": item["name"], "plot": item["desc"], "date": item["date"] } # Get length, if present if item["length"] != "": labels["duration"] = int(item["length"][:2]) * 60 + int( item["length"][3:5]) liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=thumb) liStyle.setInfo(type="Video", infoLabels=labels) if url != "": addLinkItem( { "mode": "play", "title": item["name"].encode('utf8'), "url": url, "thumbnail": thumb }, liStyle) else: addLinkItem( { "mode": "play", "title": item["name"].encode('utf8'), "uniquename": item["itemId"], "thumbnail": thumb }, liStyle) elif mediatype == "A": liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=thumb) liStyle.setInfo(type="Audio", infoLabels={ "title": item["name"], "date": item["date"] }) addLinkItem( { "mode": "play", "title": item["name"].encode('utf8'), "uniquename": item["itemId"], "thumbnail": thumb, "mediatype": "RaiTv Media Audio Item" }, liStyle) elif mediatype == "P": (url, mediatype) = ondemand.getMediaUrl(item["itemId"]) podcast = Podcast() poditems = podcast.getItems(url) for poditem in poditems: if poditem["thumbnail"] == "": poditem["thumbnail"] = thumb labels = { "title": item["name"], "plot": item["desc"], "date": item["date"] } # Get length, if present if poditem["length"] != "": labels["duration"] = int(poditem["length"][:2]) * 60 + int( poditem["length"][3:5]) liStyle = xbmcgui.ListItem(poditem["title"], thumbnailImage=poditem["thumbnail"]) liStyle.setInfo(type="Audio", infoLabels=labels) addLinkItem( { "mode": "play", "title": poditem["title"].encode('utf8'), "url": poditem["url"], "thumbnail": poditem["thumbnail"], "mediatype": "RaiTv Media Audio Item" }, liStyle) #xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_DATE) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_items(uniquename, mediatype): ondemand = OnDemand() items = ondemand.getItems(uniquename, mediatype) for item in items: # Change date format item["date"] = item["date"].replace("/",".") item["date"] = item["date"].replace("-",".") # Get best thumbnail available if "image_medium" in item and item["image_medium"] != "": thumb = item["image_medium"] elif "image" in item and item["image"] != "": thumb = item["image"] else: thumb = ondemand.nothumb # Add the server to the URL if missing if thumb[:7] != "http://": thumb = ondemand.baseUrl + thumb if mediatype == "V": # Get best video available if "h264" in item and item["h264"] != "": url = item["h264"] elif "wmv" in item and item["wmv"] != "": url = item["wmv"] else: url = item["mediaUri"] labels = {"title": item["name"], "plot": item["desc"], "date": item["date"]} # Get length, if present if item["length"] != "": labels["duration"] = int(item["length"][:2]) * 60 + int(item["length"][3:5]) liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=thumb) liStyle.setInfo(type="Video", infoLabels=labels) if url != "": addLinkItem({"mode": "play", "title": item["name"].encode('utf8'), "url": url, "thumbnail": thumb}, liStyle) else: addLinkItem({"mode": "play", "title": item["name"].encode('utf8'), "uniquename": item["itemId"], "thumbnail": thumb}, liStyle) elif mediatype == "A": liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=thumb) liStyle.setInfo(type="Audio", infoLabels={"title": item["name"], "date": item["date"]}) addLinkItem({"mode": "play", "title": item["name"].encode('utf8'), "uniquename": item["itemId"], "thumbnail": thumb, "mediatype": "RaiTv Media Audio Item"}, liStyle) elif mediatype == "P": (url, mediatype) = ondemand.getMediaUrl(item["itemId"]) podcast = Podcast() poditems = podcast.getItems(url) for poditem in poditems: if poditem["thumbnail"] == "": poditem["thumbnail"] = thumb labels = {"title": item["name"], "plot": item["desc"], "date": item["date"]} # Get length, if present if poditem["length"] != "": labels["duration"] = int(poditem["length"][:2]) * 60 + int(poditem["length"][3:5]) liStyle = xbmcgui.ListItem(poditem["title"], thumbnailImage=poditem["thumbnail"]) liStyle.setInfo(type="Audio", infoLabels=labels) addLinkItem({"mode": "play", "title": poditem["title"].encode('utf8'), "url": poditem["url"], "thumbnail": poditem["thumbnail"], "mediatype": "RaiTv Media Audio Item"}, liStyle) #xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_DATE) xbmcplugin.endOfDirectory(handle=handle, succeeded=True)