Skip to content

Commit

Permalink
Add method to lock/unlock a field for all items in a library
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyWong16 committed Dec 20, 2021
1 parent 77d8a0b commit 50ac4db
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions plexapi/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,36 @@ def defaultAdvanced(self):

self.edit(**data)

def _lockUnlockAllField(self, field, libtype=None, lock=True):
""" Lock or unlock a field for all items in the library. """
libtype = libtype or self.TYPE
args = {
'type': utils.searchType(libtype),
'%s.locked' % field: int(lock)
}
key = '/library/sections/%s/all%s' % (self.key, utils.joinArgs(args))
self._server.query(key, method=self._server._session.put)

def lockAllField(self, field, libtype=None):
""" Lock a field for all items in the library.
Parameters:
field (str): The field to lock (e.g. thumb, rating, collection).
libtype (str, optional): The library type to lock (movie, show, season, episode,
artist, album, track, photoalbum, photo). Default is the main library type.
"""
self._lockUnlockAllField(field, libtype=libtype, lock=True)

def unlockAllField(self, field, libtype=None):
""" Unlock a field for all items in the library.
Parameters:
field (str): The field to unlock (e.g. thumb, rating, collection).
libtype (str, optional): The library type to lock (movie, show, season, episode,
artist, album, track, photoalbum, photo). Default is the main library type.
"""
self._lockUnlockAllField(field, libtype=libtype, lock=False)

def timeline(self):
""" Returns a timeline query for this library section. """
key = '/library/sections/%s/timeline' % self.key
Expand Down

0 comments on commit 50ac4db

Please sign in to comment.