Add reverseSearchType util

This commit is contained in:
JonnyWong16 2021-06-18 14:21:43 -07:00
parent a5dfbe6eb7
commit 2562334ad4
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -148,6 +148,7 @@ def searchType(libtype):
Parameters: Parameters:
libtype (str): LibType to lookup (movie, show, season, episode, artist, album, track, libtype (str): LibType to lookup (movie, show, season, episode, artist, album, track,
collection) collection)
Raises: Raises:
:exc:`~plexapi.exceptions.NotFound`: Unknown libtype :exc:`~plexapi.exceptions.NotFound`: Unknown libtype
""" """
@ -159,6 +160,24 @@ def searchType(libtype):
raise NotFound('Unknown libtype: %s' % libtype) raise NotFound('Unknown libtype: %s' % libtype)
def reverseSearchType(libtype):
""" Returns the string value of the library type.
Parameters:
libtype (int): Integer value of the library type.
Raises:
:exc:`~plexapi.exceptions.NotFound`: Unknown libtype
"""
if libtype in SEARCHTYPES:
return libtype
libtype = int(libtype)
for k, v in SEARCHTYPES.items():
if libtype == v:
return k
raise NotFound('Unknown libtype: %s' % libtype)
def threaded(callback, listargs): def threaded(callback, listargs):
""" Returns the result of <callback> for each set of `*args` in listargs. Each call """ Returns the result of <callback> for each set of `*args` in listargs. Each call
to <callback> is called concurrently in their own separate threads. to <callback> is called concurrently in their own separate threads.