示例#1
0
def show_ondemand_programmes(pathId):
    xbmc.log("Raiplay.show_ondemand_programmes with PathID: %s" % pathId)
    raiplay = RaiPlay()
    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.setArt(
                    {"thumb": raiplay.getThumbnailUrl(item["image"])})
                liStyle.setArt(
                    {"fanart": raiplay.getThumbnailUrl(item["image"])})
                addDirectoryItem(
                    {
                        "mode": "ondemand",
                        "path_id": item["path_id"],
                        "sub_type": item["sub_type"]
                    }, 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)
示例#3
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)
示例#4
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)
示例#5
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 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)
示例#7
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)
示例#8
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)
示例#9
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)
示例#10
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)
示例#11
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)
示例#12
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)
示例#13
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)
示例#14
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)
示例#15
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)
示例#16
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)
示例#17
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)
示例#18
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)
示例#19
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)
示例#20
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)
示例#21
0
def show_ondemand_index_all(index, pathId):
    xbmc.log(
        "Raiplay.show_ondemand_index_all with index from 0 to %sS and PathID: %s"
        % (index, pathId))
    raiplay = RaiPlay(Addon)
    dir = raiplay.getProgrammeList(pathId)
    dictKeys = dir.keys()
    for currKey in dictKeys:
        for item in dir[currKey]:
            liStyle = xbmcgui.ListItem(item["name"])
            liStyle.setArt({
                "thumb":
                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_replay_tv_epg(date, channelId):
    xbmc.log("Showing EPG for " + channelId + " on " + date)
    raiplay = RaiPlay()
    programmes = raiplay.getProgrammes(channelId, date)
    if(programmes):
      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
          
          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("video", {})
              addLinkItem({"mode": "nop"}, liStyle)
          else:
              liStyle = xbmcgui.ListItem(startTime + " " + title,
                  thumbnailImage=thumb)
              liStyle.setInfo("video", {})
              addLinkItem({"mode": "play",
                  "path_id": videoUrl}, liStyle)
    else:
      response = raiplay.getProgrammesHtml(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)