Function to grab all Plex libraries from PMS
This commit is contained in:
parent
ee85db4570
commit
d7bd6b0d13
2 changed files with 7 additions and 40 deletions
|
@ -258,43 +258,12 @@ def GetPlexOnDeck(viewId):
|
|||
return DownloadChunks("{server}/library/sections/%s/onDeck?" % viewId)
|
||||
|
||||
|
||||
def GetPlexCollections(mediatype):
|
||||
def get_plex_sections():
|
||||
"""
|
||||
Input:
|
||||
mediatype String or list of strings with possible values
|
||||
'movie', 'show', 'artist', 'photo'
|
||||
Output:
|
||||
List with an entry of the form:
|
||||
{
|
||||
'name': xxx Plex title for the media section
|
||||
'type': xxx Plex type: 'movie', 'show', 'artist', 'photo'
|
||||
'id': xxx Plex unique key for the section (1, 2, 3...)
|
||||
'uuid': xxx Other unique Plex key, e.g.
|
||||
74aec9f2-a312-4723-9436-de2ea43843c1
|
||||
}
|
||||
Returns an empty list if nothing is found.
|
||||
Returns all Plex sections (libraries) of the PMS as an etree xml
|
||||
"""
|
||||
collections = []
|
||||
url = "{server}/library/sections"
|
||||
xml = downloadutils.DownloadUtils().downloadUrl(url)
|
||||
try:
|
||||
xml.attrib
|
||||
except AttributeError:
|
||||
log.error('Could not download PMS sections for %s' % url)
|
||||
return {}
|
||||
for item in xml:
|
||||
contentType = item['type']
|
||||
if contentType in mediatype:
|
||||
name = item['title']
|
||||
contentId = item['key']
|
||||
uuid = item['uuid']
|
||||
collections.append({
|
||||
'name': name,
|
||||
'type': contentType,
|
||||
'id': str(contentId),
|
||||
'uuid': uuid
|
||||
})
|
||||
return collections
|
||||
return downloadutils.DownloadUtils().downloadUrl(
|
||||
'{server}/library/sections')
|
||||
|
||||
|
||||
def init_plex_playqueue(itemid, librarySectionUUID, mediatype='movie',
|
||||
|
|
|
@ -23,7 +23,7 @@ import videonodes
|
|||
import variables as v
|
||||
|
||||
from PlexFunctions import GetPlexMetadata, GetAllPlexLeaves, scrobble, \
|
||||
GetPlexSectionResults, GetAllPlexChildren, GetPMSStatus
|
||||
GetPlexSectionResults, GetAllPlexChildren, GetPMSStatus, get_plex_sections
|
||||
import PlexAPI
|
||||
from library_sync.get_metadata import Threaded_Get_Metadata
|
||||
from library_sync.process_metadata import Threaded_Process_Metadata
|
||||
|
@ -126,8 +126,7 @@ class LibrarySync(Thread):
|
|||
# change in lastViewedAt
|
||||
|
||||
# Get all Plex libraries
|
||||
sections = downloadutils.DownloadUtils().downloadUrl(
|
||||
"{server}/library/sections")
|
||||
sections = get_plex_sections()
|
||||
try:
|
||||
sections.attrib
|
||||
except AttributeError:
|
||||
|
@ -477,8 +476,7 @@ class LibrarySync(Thread):
|
|||
vnodes = self.vnodes
|
||||
|
||||
# Get views
|
||||
sections = downloadutils.DownloadUtils().downloadUrl(
|
||||
"{server}/library/sections")
|
||||
sections = get_plex_sections()
|
||||
try:
|
||||
sections.attrib
|
||||
except AttributeError:
|
||||
|
|
Loading…
Reference in a new issue