示例#1
0
def __build_item(xml_element):
    api = API(xml_element)
    listitem = api.CreateListItemFromPlexItem()
    resume = api.getResume()
    if resume:
        listitem.setProperty('resumetime', str(resume))
    if (api.getKey().startswith('/system/services') or
            api.getKey().startswith('http')):
        params = {
            'mode': 'plex_node',
            'key': xml_element.attrib.get('key'),
            'offset': xml_element.attrib.get('viewOffset', '0'),
        }
        url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
    elif api.getType() == v.PLEX_TYPE_PHOTO:
        url = api.get_picture_path()
    else:
        params = {
            'mode': 'play',
            'plex_id': api.getRatingKey(),
            'plex_type': api.getType(),
        }
        url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
    xbmcplugin.addDirectoryItem(handle=HANDLE,
                                url=url,
                                listitem=listitem)
示例#2
0
def __build_item(xml_element):
    api = API(xml_element)
    listitem = api.CreateListItemFromPlexItem()
    if (api.getKey().startswith('/system/services') or
            api.getKey().startswith('http')):
        params = {
            'mode': 'plex_node',
            'key': xml_element.attrib.get('key'),
            'view_offset': xml_element.attrib.get('viewOffset', '0'),
        }
        url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
    elif api.getType() == v.PLEX_TYPE_PHOTO:
        url = api.get_picture_path()
    else:
        params = {
            'mode': 'play',
            'filename': api.getKey(),
            'id': api.getRatingKey(),
            'dbid': listitem.getProperty('dbid')
        }
        url = "plugin://%s?%s" % (v.ADDON_ID, urlencode(params))
    xbmcplugin.addDirectoryItem(handle=HANDLE,
                                url=url,
                                listitem=listitem)
示例#3
0
 def add_trailer(self, item):
     # Playurl needs to point back so we can get metadata!
     path = "plugin://plugin.video.plexkodiconnect/movies/"
     params = {'mode': "play", 'dbid': 'plextrailer'}
     introAPI = API(item)
     listitem = introAPI.CreateListItemFromPlexItem()
     params['id'] = introAPI.getRatingKey()
     params['filename'] = introAPI.getKey()
     introPlayurl = path + '?' + urlencode(params)
     introAPI.set_listitem_artwork(listitem)
     # Overwrite the Plex url
     listitem.setPath(introPlayurl)
     log.info("Adding Plex trailer: %s" % introPlayurl)
     add_listitem_to_Kodi_playlist(self.playqueue,
                                   self.currentPosition,
                                   listitem,
                                   introPlayurl,
                                   xml_video_element=item)
     self.currentPosition += 1
示例#4
0
 def add_trailer(self, item):
     # Playurl needs to point back so we can get metadata!
     path = "plugin://plugin.video.plexkodiconnect/movies/"
     params = {
         'mode': "play",
         'dbid': 'plextrailer'
     }
     introAPI = API(item)
     listitem = introAPI.CreateListItemFromPlexItem()
     params['id'] = introAPI.getRatingKey()
     params['filename'] = introAPI.getKey()
     introPlayurl = path + '?' + urlencode(params)
     introAPI.set_listitem_artwork(listitem)
     # Overwrite the Plex url
     listitem.setPath(introPlayurl)
     log.info("Adding Plex trailer: %s" % introPlayurl)
     add_listitem_to_Kodi_playlist(
         self.playqueue,
         self.currentPosition,
         listitem,
         introPlayurl,
         xml_video_element=item)
     self.currentPosition += 1
def BrowsePlexContent(viewid, mediatype="", folderid=""):
    """
    Browse Plex Photos:
        viewid:          PMS name of the library
        mediatype:       mediatype, 'photos'
        nodetype:        e.g. 'ondeck' (TBD!!)
    """
    log.debug("BrowsePlexContent called with viewid: %s, mediatype: "
              "%s, folderid: %s" % (viewid, mediatype, folderid))

    if not folderid:
        # Top-level navigation, so get the content of this section
        # Get all sections
        xml = GetPlexSectionResults(viewid,
                                    containerSize=int(settings('limitindex')))
        try:
            xml.attrib
        except AttributeError:
            log.error("Error download section %s" % viewid)
            return xbmcplugin.endOfDirectory(HANDLE, False)
    else:
        # folderid was passed so we can directly access the folder
        xml = downloadutils.DownloadUtils().downloadUrl("{server}%s" %
                                                        folderid)
        try:
            xml.attrib
        except AttributeError:
            log.error("Error downloading %s" % folderid)
            return xbmcplugin.endOfDirectory(HANDLE, False)

    # Set the folder's name
    xbmcplugin.setPluginCategory(HANDLE, xml.attrib.get('librarySectionTitle'))

    # set the correct params for the content type
    if mediatype == "photos":
        xbmcplugin.setContent(HANDLE, 'photos')

    # process the listing
    for item in xml:
        api = API(item)
        if item.tag == 'Directory':
            li = ListItem(item.attrib.get('title', 'Missing title'))
            # for folders we add an additional browse request, passing the
            # folderId
            li.setProperty('IsFolder', 'true')
            li.setProperty('IsPlayable', 'false')
            path = "%s?id=%s&mode=browseplex&type=%s&folderid=%s" \
                   % (ARGV_0, viewid, mediatype, api.getKey())
            api.set_listitem_artwork(li)
            xbmcplugin.addDirectoryItem(handle=HANDLE,
                                        url=path,
                                        listitem=li,
                                        isFolder=True)
        else:
            li = api.CreateListItemFromPlexItem()
            api.set_listitem_artwork(li)
            xbmcplugin.addDirectoryItem(handle=HANDLE,
                                        url=li.getProperty("path"),
                                        listitem=li)

    xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_VIDEO_TITLE)
    xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
    xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_VIDEO_RATING)
    xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)

    xbmcplugin.endOfDirectory(
        handle=HANDLE, cacheToDisc=settings('enableTextureCache') == 'true')