Пример #1
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)
Пример #2
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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
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)