mirror of
https://github.com/pkkid/python-plexapi
synced 2025-02-16 21:08:27 +00:00
Clean up SplitMerge mixin
This commit is contained in:
parent
f13d0bfe3b
commit
3e1e2434a7
4 changed files with 17 additions and 12 deletions
|
@ -4,7 +4,7 @@ from urllib.parse import quote_plus
|
|||
from plexapi import library, media, utils
|
||||
from plexapi.base import Playable, PlexPartialObject
|
||||
from plexapi.exceptions import BadRequest
|
||||
from plexapi.mixins import SplitMergeAble
|
||||
from plexapi.mixins import SplitMerge
|
||||
|
||||
|
||||
class Audio(PlexPartialObject):
|
||||
|
@ -124,7 +124,7 @@ class Audio(PlexPartialObject):
|
|||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Artist(Audio, SplitMergeAble):
|
||||
class Artist(Audio, SplitMerge):
|
||||
""" Represents a single Artist.
|
||||
|
||||
Attributes:
|
||||
|
|
|
@ -113,7 +113,7 @@ class PlexObject(object):
|
|||
def _isChildOf(self, **kwargs):
|
||||
""" Returns True if this object is a child of the given attributes.
|
||||
This will search the parent objects all the way to the top.
|
||||
|
||||
|
||||
Parameters:
|
||||
**kwargs (dict): The attributes and values to search for in the parent objects.
|
||||
See all possible `**kwargs*` in :func:`~plexapi.base.PlexObject.fetchItem`.
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class SplitMergeAble:
|
||||
""" Mixin for something that that we can split and merge."""
|
||||
class SplitMerge(object):
|
||||
""" Mixin for Plex objects that can be split and merged."""
|
||||
|
||||
def split(self):
|
||||
"""Split a duplicate."""
|
||||
""" Split duplicated Plex object into separate objects. """
|
||||
key = '/library/metadata/%s/split' % self.ratingKey
|
||||
return self._server.query(key, method=self._server._session.put)
|
||||
|
||||
def merge(self, ratingKeys):
|
||||
"""Merge duplicate items."""
|
||||
""" Merge other Plex objects into the current object.
|
||||
|
||||
Parameters:
|
||||
ratingKeys (list): A list of rating keys to merge.
|
||||
"""
|
||||
if not isinstance(ratingKeys, list):
|
||||
ratingKeys = str(ratingKeys).split(",")
|
||||
ratingKeys = str(ratingKeys).split(',')
|
||||
|
||||
key = '%s/merge?ids=%s' % (self.key, ','.join(ratingKeys))
|
||||
key = '%s/merge?ids=%s' % (self.key, ','.join([str(r) for r in ratingKeys]))
|
||||
return self._server.query(key, method=self._server._session.put)
|
||||
|
|
|
@ -5,7 +5,7 @@ from urllib.parse import quote_plus, urlencode
|
|||
from plexapi import library, media, settings, utils
|
||||
from plexapi.base import Playable, PlexPartialObject
|
||||
from plexapi.exceptions import BadRequest, NotFound
|
||||
from plexapi.mixins import SplitMergeAble
|
||||
from plexapi.mixins import SplitMerge
|
||||
|
||||
|
||||
class Video(PlexPartialObject):
|
||||
|
@ -260,7 +260,7 @@ class Video(PlexPartialObject):
|
|||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Movie(Playable, Video, SplitMergeAble):
|
||||
class Movie(Playable, Video, SplitMerge):
|
||||
""" Represents a single Movie.
|
||||
|
||||
Attributes:
|
||||
|
@ -384,7 +384,7 @@ class Movie(Playable, Video, SplitMergeAble):
|
|||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Show(Video, SplitMergeAble):
|
||||
class Show(Video, SplitMerge):
|
||||
""" Represents a single Show (including all seasons and episodes).
|
||||
|
||||
Attributes:
|
||||
|
|
Loading…
Add table
Reference in a new issue