mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-23 04:03:05 +00:00
Move all tag editing to a mixin
This commit is contained in:
parent
db344e9e6b
commit
7aaf56a62d
6 changed files with 233 additions and 36 deletions
|
@ -4,6 +4,7 @@ from urllib.parse import quote_plus
|
||||||
from plexapi import library, media, utils
|
from plexapi import library, media, utils
|
||||||
from plexapi.base import Playable, PlexPartialObject
|
from plexapi.base import Playable, PlexPartialObject
|
||||||
from plexapi.exceptions import BadRequest
|
from plexapi.exceptions import BadRequest
|
||||||
|
from plexapi.mixin import EditCollection, EditCountry, EditGenre, EditLabel, EditMood, EditSimilarArtist, EditStyle
|
||||||
|
|
||||||
|
|
||||||
class Audio(PlexPartialObject):
|
class Audio(PlexPartialObject):
|
||||||
|
@ -123,7 +124,7 @@ class Audio(PlexPartialObject):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Artist(Audio):
|
class Artist(Audio, EditCollection, EditCountry, EditGenre, EditMood, EditSimilarArtist, EditStyle):
|
||||||
""" Represents a single Artist.
|
""" Represents a single Artist.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
@ -226,7 +227,7 @@ class Artist(Audio):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Album(Audio):
|
class Album(Audio, EditCollection, EditGenre, EditLabel, EditMood, EditStyle):
|
||||||
""" Represents a single Album.
|
""" Represents a single Album.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
@ -332,7 +333,7 @@ class Album(Audio):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Track(Audio, Playable):
|
class Track(Audio, Playable, EditMood):
|
||||||
""" Represents a single Track.
|
""" Represents a single Track.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
|
@ -468,34 +468,6 @@ class PlexPartialObject(PlexObject):
|
||||||
self.edit(**d)
|
self.edit(**d)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def addCollection(self, collections):
|
|
||||||
""" Add a collection(s).
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
collections (list): list of strings
|
|
||||||
"""
|
|
||||||
self._edit_tags('collection', collections)
|
|
||||||
|
|
||||||
def removeCollection(self, collections):
|
|
||||||
""" Remove a collection(s). """
|
|
||||||
self._edit_tags('collection', collections, remove=True)
|
|
||||||
|
|
||||||
def addLabel(self, labels):
|
|
||||||
""" Add a label(s). """
|
|
||||||
self._edit_tags('label', labels)
|
|
||||||
|
|
||||||
def removeLabel(self, labels):
|
|
||||||
""" Remove a label(s). """
|
|
||||||
self._edit_tags('label', labels, remove=True)
|
|
||||||
|
|
||||||
def addGenre(self, genres):
|
|
||||||
""" Add a genre(s). """
|
|
||||||
self._edit_tags('genre', genres)
|
|
||||||
|
|
||||||
def removeGenre(self, genres):
|
|
||||||
""" Remove a genre(s). """
|
|
||||||
self._edit_tags('genre', genres, remove=True)
|
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
""" Refreshing a Library or individual item causes the metadata for the item to be
|
""" Refreshing a Library or individual item causes the metadata for the item to be
|
||||||
refreshed, even if it already has metadata. You can think of refreshing as
|
refreshed, even if it already has metadata. You can think of refreshing as
|
||||||
|
|
|
@ -4,6 +4,7 @@ from urllib.parse import quote, quote_plus, unquote, urlencode
|
||||||
from plexapi import X_PLEX_CONTAINER_SIZE, log, media, utils
|
from plexapi import X_PLEX_CONTAINER_SIZE, log, media, utils
|
||||||
from plexapi.base import OPERATORS, PlexObject, PlexPartialObject
|
from plexapi.base import OPERATORS, PlexObject, PlexPartialObject
|
||||||
from plexapi.exceptions import BadRequest, NotFound
|
from plexapi.exceptions import BadRequest, NotFound
|
||||||
|
from plexapi.mixin import EditLabel
|
||||||
from plexapi.settings import Setting
|
from plexapi.settings import Setting
|
||||||
from plexapi.utils import deprecated
|
from plexapi.utils import deprecated
|
||||||
|
|
||||||
|
@ -1525,7 +1526,7 @@ class FirstCharacter(PlexObject):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Collections(PlexPartialObject):
|
class Collections(PlexPartialObject, EditLabel):
|
||||||
""" Represents a single Collection.
|
""" Represents a single Collection.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
221
plexapi/mixin.py
Normal file
221
plexapi/mixin.py
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
class EditCollection(object):
|
||||||
|
""" Mixin for Plex objects that can have collections. """
|
||||||
|
|
||||||
|
def addCollection(self, collections):
|
||||||
|
""" Add a collection tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
collections (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('collection', collections)
|
||||||
|
|
||||||
|
def removeCollection(self, collections):
|
||||||
|
""" Remove a collection tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
collections (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('collection', collections, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditCountry(object):
|
||||||
|
""" Mixin for Plex objects that can have countries. """
|
||||||
|
|
||||||
|
def addCountry(self, countries):
|
||||||
|
""" Add a country tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
countries (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('country', countries)
|
||||||
|
|
||||||
|
def removeCountry(self, countries):
|
||||||
|
""" Remove a country tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
countries (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('country', countries, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditDirector(object):
|
||||||
|
""" Mixin for Plex objects that can have directors. """
|
||||||
|
|
||||||
|
def addDirector(self, directors):
|
||||||
|
""" Add a director tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
directors (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('director', directors)
|
||||||
|
|
||||||
|
def removeDirector(self, directors):
|
||||||
|
""" Remove a director tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
directors (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('director', directors, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditGenre(object):
|
||||||
|
""" Mixin for Plex objects that can have genres. """
|
||||||
|
|
||||||
|
def addGenre(self, genres):
|
||||||
|
""" Add a genre tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
genres (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('genre', genres)
|
||||||
|
|
||||||
|
def removeGenre(self, genres):
|
||||||
|
""" Remove a genre tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
genres (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('genre', genres, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditLabel(object):
|
||||||
|
""" Mixin for Plex objects that can have labels. """
|
||||||
|
|
||||||
|
def addLabel(self, labels):
|
||||||
|
""" Add a label tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
labels (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('label', labels)
|
||||||
|
|
||||||
|
def removeLabel(self, labels):
|
||||||
|
""" Remove a label tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
labels (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('label', labels, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditMood(object):
|
||||||
|
""" Mixin for Plex objects that can have moods. """
|
||||||
|
|
||||||
|
def addMood(self, moods):
|
||||||
|
""" Add a mood tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
moods (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('mood', moods)
|
||||||
|
|
||||||
|
def removeMood(self, moods):
|
||||||
|
""" Remove a mood tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
moods (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('mood', moods, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditProducer(object):
|
||||||
|
""" Mixin for Plex objects that can have producers. """
|
||||||
|
|
||||||
|
def addProducer(self, producers):
|
||||||
|
""" Add a producer tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
producers (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('producer', producers)
|
||||||
|
|
||||||
|
def removeProducer(self, producers):
|
||||||
|
""" Remove a producer tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
producers (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('producer', producers, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditSimilarArtist(object):
|
||||||
|
""" Mixin for Plex objects that can have similar artists. """
|
||||||
|
|
||||||
|
def addSimilarArtist(self, artists):
|
||||||
|
""" Add a similar artist tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
artists (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('similar', artists)
|
||||||
|
|
||||||
|
def removeSimilarArtist(self, artists):
|
||||||
|
""" Remove a similar artist tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
artists (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('similar', artists, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditStyle(object):
|
||||||
|
""" Mixin for Plex objects that can have styles. """
|
||||||
|
|
||||||
|
def addStyle(self, styles):
|
||||||
|
""" Add a style tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
styles (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('style', styles)
|
||||||
|
|
||||||
|
def removeStyle(self, styles):
|
||||||
|
""" Remove a style tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
styles (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('style', styles, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditTag(object):
|
||||||
|
""" Mixin for Plex objects that can have tags. """
|
||||||
|
|
||||||
|
def addTag(self, tags):
|
||||||
|
""" Add a tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
tags (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('tag', tags)
|
||||||
|
|
||||||
|
def removeTag(self, tags):
|
||||||
|
""" Remove a tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
tags (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('tag', tags, remove=True)
|
||||||
|
|
||||||
|
|
||||||
|
class EditWriter(object):
|
||||||
|
""" Mixin for Plex objects that can have writers. """
|
||||||
|
|
||||||
|
def addWriter(self, writers):
|
||||||
|
""" Add a writer tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
writers (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('writer', writers)
|
||||||
|
|
||||||
|
def removeWriter(self, writers):
|
||||||
|
""" Remove a writer tag(s).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
writers (list): List of strings.
|
||||||
|
"""
|
||||||
|
self._edit_tags('writer', writers, remove=True)
|
|
@ -4,6 +4,7 @@ from urllib.parse import quote_plus
|
||||||
from plexapi import media, utils, video
|
from plexapi import media, utils, video
|
||||||
from plexapi.base import Playable, PlexPartialObject
|
from plexapi.base import Playable, PlexPartialObject
|
||||||
from plexapi.exceptions import BadRequest
|
from plexapi.exceptions import BadRequest
|
||||||
|
from plexapi.mixin import EditTag
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
|
@ -136,7 +137,7 @@ class Photoalbum(PlexPartialObject):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Photo(PlexPartialObject, Playable):
|
class Photo(PlexPartialObject, Playable, EditTag):
|
||||||
""" Represents a single Photo.
|
""" Represents a single Photo.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
|
@ -5,6 +5,7 @@ from urllib.parse import quote_plus, urlencode
|
||||||
from plexapi import library, media, settings, utils
|
from plexapi import library, media, settings, utils
|
||||||
from plexapi.base import Playable, PlexPartialObject
|
from plexapi.base import Playable, PlexPartialObject
|
||||||
from plexapi.exceptions import BadRequest, NotFound
|
from plexapi.exceptions import BadRequest, NotFound
|
||||||
|
from plexapi.mixin import EditCollection, EditCountry, EditDirector, EditGenre, EditLabel, EditProducer, EditWriter
|
||||||
|
|
||||||
|
|
||||||
class Video(PlexPartialObject):
|
class Video(PlexPartialObject):
|
||||||
|
@ -259,7 +260,7 @@ class Video(PlexPartialObject):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Movie(Playable, Video):
|
class Movie(Playable, Video, EditCollection, EditCountry, EditDirector, EditGenre, EditLabel, EditProducer, EditWriter):
|
||||||
""" Represents a single Movie.
|
""" Represents a single Movie.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
@ -383,7 +384,7 @@ class Movie(Playable, Video):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Show(Video):
|
class Show(Video, EditCollection, EditGenre, EditLabel):
|
||||||
""" Represents a single Show (including all seasons and episodes).
|
""" Represents a single Show (including all seasons and episodes).
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
@ -707,7 +708,7 @@ class Season(Video):
|
||||||
|
|
||||||
|
|
||||||
@utils.registerPlexObject
|
@utils.registerPlexObject
|
||||||
class Episode(Playable, Video):
|
class Episode(Playable, Video, EditDirector, EditWriter):
|
||||||
""" Represents a single Shows Episode.
|
""" Represents a single Shows Episode.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
|
Loading…
Reference in a new issue