Skip to content

Commit

Permalink
Merge be6160f into f2f6d8b
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktwin committed Jun 6, 2020
2 parents f2f6d8b + be6160f commit 2d64f12
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plexapi/media.py
Expand Up @@ -650,6 +650,14 @@ class Role(MediaTag):
TAG = 'Role'
FILTER = 'role'

def _loadData(self, data):
self._data = data
self.id = data.attrib.get('id')
self.filter = data.attrib.get('filter')
self.role = data.attrib.get('role')
self.tag = data.attrib.get('tag')
self.thumb = data.attrib.get('thumb')


@utils.registerPlexObject
class Similar(MediaTag):
Expand Down
62 changes: 62 additions & 0 deletions plexapi/video.py
Expand Up @@ -358,6 +358,37 @@ def download(self, savepath=None, keep_original_name=False, **kwargs):
filepaths.append(filepath)
return filepaths

def addActor(self, index=0, name=None, role=None, thumb=None, locked=True):
""" Add an Actor.
Parameters:
index (int): Positional index
name (str): Name of Actor.
role (str): Role actor plays in video.
thumb (str): URL to image file.
locked (bool): True = 1, False = 0
"""
edits = {}
actor = 'actor[%s]' % index
if name:
edits['%s.tag.tag' % actor] = name
if role:
edits['%s.tagging.text' % actor] = role
if thumb:
edits['%s.tag.thumb' % actor] = thumb
if locked:
edits['%s.locked' % actor] = int(locked)
self.edit(**edits)

def removeActor(self, name):
""" Remove an Actor from item. """
actors = [actor.tag for actor in self.actors]
if name in actors:
edits = {'actor[].tag.tag-': name}
self.edit(**edits)
else:
raise NotFound('%s not found in items list of actors %s' % (name, actors))


@utils.registerPlexObject
class Show(Video):
Expand Down Expand Up @@ -528,6 +559,37 @@ def download(self, savepath=None, keep_original_name=False, **kwargs):
filepaths += episode.download(savepath, keep_original_name, **kwargs)
return filepaths

def addActor(self, index=0, name=None, role=None, thumb=None, locked=True):
""" Add an Actor.
Parameters:
index (int): Positional index
name (str): Name of Actor.
role (str): Role actor plays in video.
thumb (str): URL to image file.
locked (bool): True = 1, False = 0
"""
edits = {}
actor = 'actor[%s]' % index
if name:
edits['%s.tag.tag' % actor] = name
if role:
edits['%s.tagging.text' % actor] = role
if thumb:
edits['%s.tag.thumb' % actor] = thumb
if locked:
edits['%s.locked' % actor] = int(locked)
self.edit(**edits)

def removeActor(self, name):
""" Remove an Actor from item. """
actors = [actor.tag for actor in self.actors]
if name in actors:
edits = {'actor[].tag.tag-': name}
self.edit(**edits)
else:
raise NotFound('%s not found in items list of actors %s' % (name, actors))


@utils.registerPlexObject
class Season(Video):
Expand Down

0 comments on commit 2d64f12

Please sign in to comment.