示例#1
0
def get_raisport_videos(params):
    xbmc.log("Build Rai Sport video list for %s " % params)
    raiplay = RaiPlay()

    key = params.get('key', '')
    dominio = params.get('dominio', '')
    page = params.get('page', 0)

    response = raiplay.getRaiSportVideos(key, dominio, page)
    for r in response:
        #xbmc.log("Item %s" % r['title'])
        if r['mode'] == "raisport_video":
            liStyle = xbmcgui.ListItem(r['title'])
            liStyle.setArt({'thumb': r['icon']})
            liStyle.setInfo("video", {
                'duration': r['duration'],
                'aired': r['aired'],
                'plot': r['desc']
            })
            addLinkItem({"mode": "play", "url": r["url"]}, liStyle)
        elif r['mode'] == "raisport_subitem":
            liStyle = xbmcgui.ListItem(r['title'])
            addDirectoryItem(
                {
                    "mode": "raisport_subitem",
                    'dominio': dominio,
                    'key': key,
                    'page': r['page']
                }, liStyle)

    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#2
0
def play(url, pathId=""):
    xbmc.log("Playing...")
        
    if pathId != "":
        xbmc.log("PathID: " + pathId)
        raiplay = RaiPlay()
        url = raiplay.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 = raiplay.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)
示例#3
0
def show_ondemand_list(pathId):
    xbmc.log("Raiplay.show_ondemand_list with PathID: %s" % pathId)
    # indice ottenuto dal json
    raiplay = RaiPlay(Addon)
    xbmc.log("Url: %s" % raiplay.getUrl(pathId))

    index = raiplay.getIndexFromJSON(pathId)
    xbmc.log(str(index))

    for i in index:
        liStyle = xbmcgui.ListItem(i)
        addDirectoryItem(
            {
                "mode": "ondemand_list",
                "index": i,
                "path_id": pathId
            }, liStyle)

    addDirectoryItem(
        {
            "mode": "ondemand_list_all",
            "index": len(index) + 1,
            "path_id": pathId
        }, xbmcgui.ListItem(Addon.getLocalizedString(32011)))
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#4
0
def show_ondemand_programme(pathId):
    xbmc.log("Raiplay.show_ondemand_programme with PathID: %s" % pathId)
    raiplay = RaiPlay(Addon)
    xbmc.log("Url: %s" % raiplay.getUrl(pathId))
    
    programme = raiplay.getProgramme(pathId)
    
    if (len(programme["program_info"]["typologies"]) > 0) and programme["program_info"]["typologies"][0]["nome"] == "Film":
        # it's a movie
        if "first_item_path" in programme: 
            liStyle = xbmcgui.ListItem(programme["program_info"]["name"])
            liStyle.setThumbnailImage(raiplay.getThumbnailUrl(programme["program_info"]["images"]["landscape"]))
            liStyle.setInfo("video", {
                "Plot": programme["program_info"]["description"],
                "Cast": programme["program_info"]["actors"].split(", "),
                "Director": programme["program_info"]["direction"],
                "Country": programme["program_info"]["country"],
                "Year": programme["program_info"]["year"],
                })
            addLinkItem({"mode": "play", "path_id": programme["first_item_path"]}, liStyle)
    else:
        # other shows
        blocks = programme["blocks"]
        for block in blocks:
            for set in block["sets"]:
                liStyle = xbmcgui.ListItem(set["name"])
                addDirectoryItem({"mode": "ondemand_items", "url": set["path_id"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_programme(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    programme = raiplay.getProgramme(pathId)

    if programme["infoProg"]["tipologia"][0]["nome"] == "Film":
        if "pathFirstItem" in programme:
            liStyle = xbmcgui.ListItem(
                programme["infoProg"]["name"],
                thumbnailImage=raiplay.getThumbnailUrl(
                    programme["infoProg"]["images"]["landscape"]))
            liStyle.setProperty('IsPlayable', 'true')
            addLinkItem({
                "mode": "play",
                "path_id": programme["pathFirstItem"]
            }, liStyle)
    else:
        blocks = programme["Blocks"]
        for block in blocks:
            for set in block["Sets"]:
                liStyle = xbmcgui.ListItem(set["Name"])
                addDirectoryItem({
                    "mode": "ondemand_items",
                    "url": set["url"]
                }, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#6
0
def show_tv_channels():
    xbmc.log("Raiplay: get Rai channels: ")

    raiplay = RaiPlay()
    for station in tv_stations:
        liStyle = xbmcgui.ListItem(station["channel"])
        liStyle.setArt(
            {"thumb": raiplay.getThumbnailUrl(station["transparent-icon"])})
        liStyle.setInfo("video", {})
        addLinkItem({
            "mode": "play",
            "url": station["video"]["contentUrl"]
        }, liStyle)
    #rai sport web streams
    xbmc.log("Raiplay: get Rai sport web channels: ")

    chList = raiplay.getRaiSportLivePage()
    xbmc.log(str(chList))
    for ch in chList:
        liStyle = xbmcgui.ListItem(ch['title'])
        liStyle.setArt({"thumb": ch['icon']})
        liStyle.setInfo("video", {})
        addLinkItem({"mode": "play", "url": ch["url"]}, liStyle)

    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def search_ondemand_programmes():
    kb = xbmc.Keyboard()
    kb.setHeading("Cerca un programma")
    kb.doModal()
    if kb.isConfirmed():
        try:
            name = kb.getText().decode('utf8').lower()
        except:
            name = kb.getText().lower()
        xbmc.log("Searching for programme: " + name)
        raiplay = RaiPlay()
        dir = raiplay.getProgrammeList(raiplay.AzTvShowPath)
        for letter in dir:
            for item in dir[letter]:
                if item["name"].lower().find(name) != -1:
                    liStyle = xbmcgui.ListItem(
                        item["name"],
                        thumbnailImage=raiplay.getThumbnailUrl(
                            item["images"]["landscape"]))
                    addDirectoryItem(
                        {
                            "mode": "ondemand",
                            "path_id": item["PathID"],
                            "sub_type": "PLR programma Page"
                        }, liStyle)
        xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#8
0
def show_ondemand_root():
    xbmc.log("Raiplay.show_ondemand_root")
    raiplay = RaiPlay()
    items = raiplay.getMainMenu()
    for item in items:
        if item["sub-type"] in ("RaiPlay Tipologia Page",
                                "RaiPlay Genere Page",
                                "RaiPlay Tipologia Editoriale Page"):

            if not (item["name"] in ("Teatro", "Musica")):
                liStyle = xbmcgui.ListItem(item["name"])
                addDirectoryItem(
                    {
                        "mode": "ondemand",
                        "path_id": item["PathID"],
                        "sub_type": item["sub-type"]
                    }, liStyle)

    # add new item not in old json
    liStyle = xbmcgui.ListItem("Performing Arts")
    addDirectoryItem(
        {
            "mode": "ondemand",
            "path_id": "https://www.raiplay.it/performing-arts/index.json",
            "sub_type": "RaiPlay Tipologia Page"
        }, liStyle)

    liStyle = xbmcgui.ListItem("Cerca")
    addDirectoryItem({"mode": "ondemand_search_by_name"}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#9
0
def search_ondemand_programmes():
    kb = xbmc.Keyboard()
    kb.setHeading(Addon.getLocalizedString(32001))
    kb.doModal()
    if kb.isConfirmed():
        try:
            name = kb.getText().decode('utf8').lower()
        except:
            name = kb.getText().lower()
        xbmc.log("Searching for programme: " + name)
        raiplay = RaiPlay()
        # old style of json
        dir = raiplay.getProgrammeListOld(raiplay.AzTvShowPath)
        for letter in dir:
            for item in dir[letter]:
                if item["name"].lower().find(name) != -1:
                    #fix old version of url
                    url = item["PathID"]
                    if url.endswith('/?json'):
                        url = url.replace('/?json', '.json')

                    liStyle = xbmcgui.ListItem(item["name"])
                    liStyle.setArt({
                        "thumb":
                        raiplay.getThumbnailUrl(item["images"]["landscape"])
                    })
                    addDirectoryItem(
                        {
                            "mode": "ondemand",
                            "path_id": url,
                            "sub_type": "PLR programma Page"
                        }, liStyle)
        xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#10
0
def show_ondemand_programme(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    programme = raiplay.getProgramme(pathId)

    if (len(programme["infoProg"]["tipologia"]) >
            0) and programme["infoProg"]["tipologia"][0]["nome"] == "Film":
        if "pathFirstItem" in programme:
            liStyle = xbmcgui.ListItem(
                programme["infoProg"]["name"],
                thumbnailImage=raiplay.getThumbnailUrl(
                    programme["infoProg"]["images"]["landscape"]))
            liStyle.setInfo(
                "video", {
                    "Plot": programme["infoProg"]["description"],
                    "Cast": programme["infoProg"]["interpreti"].split(", "),
                    "Director": programme["infoProg"]["regia"],
                    "Country": programme["infoProg"]["country"],
                    "Year": programme["infoProg"]["anno"],
                })
            addLinkItem({
                "mode": "play",
                "path_id": programme["pathFirstItem"]
            }, liStyle)
    else:
        blocks = programme["Blocks"]
        for block in blocks:
            for set in block["Sets"]:
                liStyle = xbmcgui.ListItem(set["Name"])
                addDirectoryItem({
                    "mode": "ondemand_items",
                    "url": set["url"]
                }, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#11
0
def play(url, pathId=""):
    xbmc.log("Playing...")
        
    if pathId != "":
        xbmc.log("PathID: " + pathId)
        raiplay = RaiPlay()
        url = raiplay.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 = raiplay.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 + '|User-Agent=' + urllib.quote_plus(Relinker.UserAgent))
    xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=item)
示例#12
0
def show_tv_channels():
    raiplay = RaiPlay()
    for station in tv_stations:
        liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=raiplay.getThumbnailUrl(station["transparent-icon"]))
        liStyle.setInfo("video", {})
        addLinkItem({"mode": "play",
            "url": station["video"]["contentUrl"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#13
0
def show_replay_channels(date):
    raiplay = RaiPlay()
    for station in tv_stations:
        liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=raiplay.getThumbnailUrl(station["transparent-icon"]))
        addDirectoryItem({"mode": "replay",
            "channel_id": station["channel"],
            "date": date}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#14
0
def show_ondemand_programme(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    blocks = raiplay.getProgramme(pathId)
    for block in blocks:
        for set in block["Sets"]:
            liStyle = xbmcgui.ListItem(set["Name"])
            addDirectoryItem({"mode": "ondemand_items", "url": set["url"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#15
0
def show_ondemand_root():
    raiplay = RaiPlay()
    items = raiplay.getMainMenu()
    for item in items:
        if item["sub-type"] in ("RaiPlay Tipologia Page", "RaiPlay Genere Page"):
            liStyle = xbmcgui.ListItem(item["name"])
            addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
    liStyle = xbmcgui.ListItem("Cerca")
    addDirectoryItem({"mode": "ondemand_search_by_name"}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#16
0
def show_ondemand_root():
    raiplay = RaiPlay()
    items = raiplay.getMainMenu()
    for item in items:
        if item["sub-type"] in ("RaiPlay Tipologia Page", "RaiPlay Genere Page", "RaiPlay Tipologia Editoriale Page" ):
            liStyle = xbmcgui.ListItem(item["name"])
            addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
    liStyle = xbmcgui.ListItem("Cerca")
    addDirectoryItem({"mode": "ondemand_search_by_name"}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#17
0
def show_search_result(items):
    raiplay = RaiPlay()
    
    for item in items:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
        liStyle.setProperty('IsPlayable', 'true')
        addLinkItem({"mode": "play", "url": item["Url"]}, liStyle)

    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#18
0
def show_ondemand_index(index, pathId):
    xbmc.log("PathID: " + pathId)
    xbmc.log("Index: " + index)
    raiplay = RaiPlay()
    dir = raiplay.getProgrammeList(pathId)
    for item in dir[index]:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
        addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": "PLR programma Page"}, liStyle)
    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#19
0
def show_ondemand_index(index, pathId):
    xbmc.log("PathID: " + pathId)
    xbmc.log("Index: " + index)
    raiplay = RaiPlay()
    dir = raiplay.getProgrammeList(raiplay.baseUrl + pathId.replace(" ", "%20"))
    for item in dir[index]:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        #xbmc.log(item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": "PLR programma Page"}, liStyle)
    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#20
0
def show_search_result(items):
    raiplay = RaiPlay()
    
    for item in items:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
        liStyle.setInfo("video", {})
        # Using "Url" because "PathID" is broken upstream :-/
        addLinkItem({"mode": "play", "url": item["Url"]}, liStyle)

    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#21
0
def show_ondemand_index(index, pathId):
    xbmc.log("Raiplay.show_ondemand_index with index %s and PathID: %s" % (index, pathId) )

    raiplay = RaiPlay(Addon)
    dir = raiplay.getProgrammeList(pathId)
    for item in dir[index]:
        liStyle = xbmcgui.ListItem(item["name"])
        liStyle.setThumbnailImage(raiplay.getThumbnailUrl(item["images"]["landscape"]))
        addDirectoryItem({"mode": "ondemand", "path_id": item["path_id"], "sub_type": item["type"]}, liStyle)
    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#22
0
def show_ondemand_programmes(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    blocchi = raiplay.getCategory(pathId)

    if len(blocchi) > 1:
        xbmc.log("Blocchi: " + str(len(blocchi)))
        
    for item in blocchi[0]["lanci"]:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
        addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#23
0
def show_ondemand_programmes(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    blocchi = raiplay.getCategory(raiplay.baseUrl + pathId)

    if len(blocchi) > 1:
        xbmc.log("Blocchi: " + str(len(blocchi)))
        
    for item in blocchi[0]["lanci"]:
        liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#24
0
def show_ondemand_programme(pathId):
    xbmc.log("PathID: " + pathId)
    raiplay = RaiPlay()
    
    if pathId.find("://") == -1:
        pathId = raiplay.baseUrl + pathId
    
    blocks = raiplay.getProgramme(pathId)
    for block in blocks:
        for set in block["Sets"]:
            liStyle = xbmcgui.ListItem(set["Name"])
            addDirectoryItem({"mode": "ondemand_items", "url": set["url"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#25
0
def show_ondemand_items(url):
    xbmc.log("ContentSet URL: " + url)
    raiplay = RaiPlay()
    items = raiplay.getContentSet(url)
    for item in items:
        title = item["name"]
        if "subtitle" in item and item["subtitle"] != "" and item["subtitle"] != item["name"]:
            title = title + " (" + item["subtitle"] + ")"
        liStyle = xbmcgui.ListItem(title, thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
        liStyle.setInfo("video", {})
        addLinkItem({"mode": "play",
            "path_id": item["pathID"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#26
0
def show_collection(pathId):
    xbmc.log("Raiplay.show_collection with PathID: %s" % pathId )
    raiplay = RaiPlay(Addon)
    xbmc.log("Url: " + raiplay.getUrl(pathId))
   
    response = raiplay.getCategory(pathId)

    for item in response:
        liStyle = xbmcgui.ListItem(item["name"])
        liStyle.setThumbnailImage(raiplay.getThumbnailUrl(item["images"]["landscape"]))
        addDirectoryItem({"mode": "ondemand", "path_id": item["path_id"], "sub_type": item["type"]}, liStyle)
    
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#27
0
def show_ondemand_items(url):
    xbmc.log("ContentSet URL: " + url)
    raiplay = RaiPlay()
    items = raiplay.getContentSet(raiplay.baseUrl + url)
    for item in items:
        title = item["name"]
        if "subtitle" in item and item["subtitle"] != "" and item["subtitle"] != item["name"]:
            title = title + " (" + item["subtitle"] + ")"
        #xbmc.log(item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        liStyle = xbmcgui.ListItem(title, thumbnailImage=item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        liStyle.setProperty('IsPlayable', 'true')
        addLinkItem({"mode": "play",
            "path_id": item["pathID"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#28
0
def show_home():
    raiplay = RaiPlay(Addon)
    response = raiplay.getHomePage()
    
    for item in response:
        item_type = item.get("type","")

        if item_type == "RaiPlay Hero Block":
            for item2 in item["contents"]:
                sub_type = item2["type"]
                liStyle = xbmcgui.ListItem("%s: %s" % (Addon.getLocalizedString(32013), item2['name']))
                liStyle.setThumbnailImage(raiplay.getThumbnailUrl(item2["images"]["landscape"]))

                if sub_type == "RaiPlay Diretta Item":
                    liStyle.setInfo("video", {})
                    addLinkItem({"mode": "play", "url": item2["path_id"]}, liStyle)
                elif sub_type == "RaiPlay V2 Lancio Item":
                    if item2["sub_type"] == "RaiPlay Video Item":
                        liStyle.setInfo("video", {})
                        addLinkItem({"mode": "play", "path_id": item2["path_id"]}, liStyle)
                    else:
                        xbmc.log("Not handled sub-type in Hero Block: '%s'" % item2["sub_type"])
                elif sub_type == "RaiPlay Programma Item" :
                    addDirectoryItem({"mode": "ondemand", "path_id": item2["path_id"], "sub_type": sub_type }, liStyle)
                else:                    
                    xbmc.log("Not handled type in Hero Block: '%s'" % sub_type)
                    addDirectoryItem({"mode": "ondemand", "path_id": item2["path_id"], "sub_type": sub_type }, liStyle)

        elif item_type == "RaiPlay Configuratore Fascia Recommendation Item":
            title = item['name']
            if title.find('RCM') > 0:
                title = title[0:title.find('RCM')]
            if title.find('HP') > 0:
                title = title[0:title.find('HP')]
            if title.strip():
                liStyle = xbmcgui.ListItem(title)
                if "fallback_list" in item:
                    if item["fallback_list"]:
                        addDirectoryItem({"mode": "ondemand_collection", "path_id": item["fallback_list"]}, liStyle)
        elif "Slider" in item_type: 
            # populate subItems array
            subItems=[]
            for item2 in item["contents"]:
                subItems.append({"mode": "ondemand", "name": item2["name"], "path_id": item2["path_id"], "video_url": item2.get("video_url",""), "sub_type": item2["type"], "icon": raiplay.getThumbnailUrl(item2["images"]["landscape"])})
                
            liStyle = xbmcgui.ListItem(item['name'])
            addDirectoryItem({"mode": "ondemand_slider", "sub_items": json.dumps(subItems)}, liStyle)
        
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#29
0
def show_replay_tv_channels(date):
    raiplay = RaiPlay(Addon)
    for station in tv_stations:
        liStyle = xbmcgui.ListItem(station["channel"])
        liStyle.setArt(
            {"thumb": raiplay.getThumbnailUrl(station["transparent-icon"])})
        addDirectoryItem(
            {
                "mode": "replay",
                "media": "tv",
                "channel_id": station["channel"],
                "date": date
            }, liStyle)

    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#30
0
def search_ondemand_programmes():
    kb = xbmc.Keyboard()
    kb.setHeading("Cerca un programma")
    kb.doModal()
    if kb.isConfirmed():
        name = kb.getText().decode('utf8')
        xbmc.log("Searching for programme: " + name)
        raiplay = RaiPlay()
        dir = raiplay.getProgrammeList(raiplay.baseUrl + raiplay.AzTvShowPath)
        for letter in dir:
            for item in dir[letter]:
                if item["name"].lower().find(name) != -1:
                    liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
                    addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": "PLR programma Page"}, liStyle)
        xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#31
0
def show_replay_epg(channelId, date):
    xbmc.log("Showing EPG for " + channelId + " on " + date)
    raiplay = RaiPlay()
    programmes = raiplay.getProgrammes(channelId, date)
    
    for programme in programmes:
        if not programme:
            continue
    
        startTime = programme["timePublished"]
        title = programme["name"]
        
        if programme["images"]["landscape"] != "":
            thumb = programme["images"]["landscape"].replace("[RESOLUTION]", "256x-")
        elif programme["isPartOf"] and programme["isPartOf"]["images"]["landscape"] != "":
            thumb = programme["isPartOf"]["images"]["landscape"].replace("[RESOLUTION]", "256x-")
        else:
            raiplay = RaiPlay()
            thumb = raiplay.nothumb
        
        plot = programme["description"]
        
        if programme["hasVideo"]:
            videoUrl = programme["pathID"]
        else:
            videoUrl = None
        
        if videoUrl is None:
            # programme is not available
            liStyle = xbmcgui.ListItem(startTime + " [I]" + title + "[/I]",
                thumbnailImage=thumb)
            # liStyle.setInfo(type="Video", infoLabels={"Title" : title,
                # "Label": title,
                # "Plot": plot})
            liStyle.setProperty('IsPlayable', 'true')
            addLinkItem({"mode": "nop"}, liStyle)
        else:
            liStyle = xbmcgui.ListItem(startTime + " " + title,
                thumbnailImage=thumb)
            # liStyle.setInfo(type="Video", infoLabels={"Title" : title,
                # "Label": title,
                # "Plot": plot})
            liStyle.setProperty('IsPlayable', 'true')
            addLinkItem({"mode": "play",
                "path_id": videoUrl}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#32
0
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)
示例#33
0
def show_ondemand_items(url):
    xbmc.log("ContentSet URL: " + url)
    raiplay = RaiPlay()
    items = raiplay.getContentSet(raiplay.baseUrl + url)
    for item in items:
        title = item["name"]
        if "subtitle" in item and item["subtitle"] != "" and item[
                "subtitle"] != item["name"]:
            title = title + " (" + item["subtitle"] + ")"
        #xbmc.log(item["images"]["landscape"].replace("[RESOLUTION]", "256x-"))
        liStyle = xbmcgui.ListItem(
            title,
            thumbnailImage=item["images"]["landscape"].replace(
                "[RESOLUTION]", "256x-"))
        liStyle.setProperty('IsPlayable', 'true')
        addLinkItem({"mode": "play", "path_id": item["pathID"]}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#34
0
def show_replay_tv_epg(date, channelId):
    xbmc.log("Showing EPG for " + channelId + " on " + date)
    raiplay = RaiPlay()
    response = raiplay.getProgrammes(channelId, date)
    programmes = re.findall('(<li.*?</li>)', response)
    for i in programmes:
        icon = re.findall('''data-img=['"]([^'^"]+?)['"]''', i)
        if icon:
            icon = raiplay.getUrl(icon[0])
        else:
            icon = ''

        title = re.findall("<p class=\"info\">([^<]+?)</p>", i)
        if title:
            title = title[0]
        else:
            title = ''

        startTime = re.findall("<p class=\"time\">([^<]+?)</p>", i)
        if startTime:
            title = startTime[0] + " " + title

        desc = re.findall("<p class=\"descProgram\">([^<]+?)</p>", i, re.S)
        if desc:
            desc = desc[0]
        else:
            desc = ""

        videoUrl = re.findall('''data-href=['"]([^'^"]+?)['"]''', i)

        if not videoUrl:
            # programme is not available
            liStyle = xbmcgui.ListItem(" [I]" + title + "[/I]",
                                       thumbnailImage=icon)
            liStyle.setInfo("video", {})
            addLinkItem({"mode": "nop"}, liStyle)
        else:
            videoUrl = videoUrl[0]
            if not videoUrl.endswith('json'):
                videoUrl = videoUrl + "?json"

            liStyle = xbmcgui.ListItem(title, thumbnailImage=icon)
            liStyle.setInfo("video", {})
            addLinkItem({"mode": "play", "path_id": videoUrl}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#35
0
def show_ondemand_programmes(pathId):
    xbmc.log("Raiplay.show_ondemand_programmes with PathID: %s" % pathId )
    raiplay = RaiPlay(Addon)
    xbmc.log("Url: " + raiplay.getUrl(pathId))
   
    blocchi = raiplay.getCategory(pathId)

    if len(blocchi) > 1:
        xbmc.log("Blocchi: " + str(len(blocchi)))
        
    for b in blocchi:
        if b["type"] == "RaiPlay Slider Generi Block":
            for item in b["contents"]:
                liStyle = xbmcgui.ListItem(item["name"])
                liStyle.setThumbnailImage("raiplay.getThumbnailUrl")
                addDirectoryItem({"mode": "ondemand", "path_id": item["path_id"], "sub_type": item["sub_type"]}, liStyle)
    
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#36
0
def get_raisport_main():
    xbmc.log("Build Rai Sport menu with search keys....")
    raiplay = RaiPlay(Addon)
    
    for k in raisport_keys():
        liStyle = xbmcgui.ListItem(k['title'])
        addDirectoryItem({"mode": "raisport_item", 'dominio': k['dominio'], 'sub_keys': k['sub_keys']}, liStyle)

    xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#37
0
def show_tv_channels():
    xbmc.log("Raiplay: get Rai channels: ")

    raiplay = RaiPlay(Addon)
    onAirJson = raiplay.getOnAir()
    
    for station in tv_stations:
        chName = station["channel"]
        current = ""
        for d in onAirJson:
            if chName == d["channel"]:
                current = d["currentItem"].get("name","")
                thumb = d["currentItem"].get("image","")
                chName = "[COLOR yellow]" + chName + "[/COLOR]: " + current
                break
        
        liStyle = xbmcgui.ListItem(chName)
        if thumb:
            liStyle.setThumbnailImage(raiplay.getUrl(thumb))
        else:
            liStyle.setThumbnailImage(raiplay.getThumbnailUrl(station["transparent-icon"]))
        addLinkItem({"mode": "play",
            "url": station["video"]["contentUrl"]}, liStyle)
    #rai sport web streams
    xbmc.log("Raiplay: get Rai sport web channels: ")

    chList = raiplay.getRaiSportLivePage()
    xbmc.log(str(chList))
    for ch in chList:
        liStyle = xbmcgui.ListItem("[COLOR green]" + ch['title'] + "[/COLOR]")
        liStyle.setThumbnailImage(ch['icon'])
        liStyle.setInfo("video", {})
        addLinkItem({"mode": "play", "url": ch["url"]}, liStyle)
    
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#38
0
def show_replay_epg(channelId, date):
    xbmc.log("Showing EPG for " + channelId + " on " + date)
    raiplay = RaiPlay()
    programmes = raiplay.getProgrammes(channelId, date)

    for programme in programmes:
        if not programme:
            continue

        startTime = programme["timePublished"]
        title = programme["name"]

        if programme["images"]["landscape"] != "":
            thumb = raiplay.getThumbnailUrl(programme["images"]["landscape"])
        elif programme["isPartOf"] and programme["isPartOf"]["images"][
                "landscape"] != "":
            thumb = raiplay.getThumbnailUrl(
                programme["isPartOf"]["images"]["landscape"])
        else:
            thumb = raiplay.noThumbUrl

        plot = programme["description"]

        if programme["hasVideo"]:
            videoUrl = programme["pathID"]
        else:
            videoUrl = None

        if videoUrl is None:
            # programme is not available
            liStyle = xbmcgui.ListItem(startTime + " [I]" + title + "[/I]",
                                       thumbnailImage=thumb)
            liStyle.setProperty('IsPlayable', 'true')
            addLinkItem({"mode": "nop"}, liStyle)
        else:
            liStyle = xbmcgui.ListItem(startTime + " " + title,
                                       thumbnailImage=thumb)
            liStyle.setProperty('IsPlayable', 'true')
            addLinkItem({"mode": "play", "path_id": videoUrl}, liStyle)
    xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
示例#39
0
def log_country():
    raiplay = RaiPlay()
    country = raiplay.getCountry()
    xbmc.log("RAI geolocation: %s" % country)