|
2 | 2 | from urllib.parse import quote, quote_plus, unquote, urlencode |
3 | 3 |
|
4 | 4 | from plexapi import X_PLEX_CONTAINER_SIZE, log, media, utils |
5 | | -from plexapi.base import OPERATORS, PlexObject, PlexPartialObject |
| 5 | +from plexapi.base import OPERATORS, PlexObject |
6 | 6 | from plexapi.exceptions import BadRequest, NotFound |
7 | | -from plexapi.mixins import ArtMixin, PosterMixin |
8 | | -from plexapi.mixins import LabelMixin |
9 | 7 | from plexapi.settings import Setting |
10 | 8 | from plexapi.utils import deprecated |
11 | 9 |
|
@@ -1527,168 +1525,6 @@ def _loadData(self, data): |
1527 | 1525 | self.title = data.attrib.get('title') |
1528 | 1526 |
|
1529 | 1527 |
|
1530 | | -@utils.registerPlexObject |
1531 | | -class Collections(PlexPartialObject, ArtMixin, PosterMixin, LabelMixin): |
1532 | | - """ Represents a single Collection. |
1533 | | -
|
1534 | | - Attributes: |
1535 | | - TAG (str): 'Directory' |
1536 | | - TYPE (str): 'collection' |
1537 | | - addedAt (datetime): Datetime the collection was added to the library. |
1538 | | - art (str): URL to artwork image (/library/metadata/<ratingKey>/art/<artid>). |
1539 | | - artBlurHash (str): BlurHash string for artwork image. |
1540 | | - childCount (int): Number of items in the collection. |
1541 | | - collectionMode (str): How the items in the collection are displayed. |
1542 | | - collectionSort (str): How to sort the items in the collection. |
1543 | | - contentRating (str) Content rating (PG-13; NR; TV-G). |
1544 | | - fields (List<:class:`~plexapi.media.Field`>): List of field objects. |
1545 | | - guid (str): Plex GUID for the collection (collection://XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX). |
1546 | | - index (int): Plex index number for the collection. |
1547 | | - key (str): API URL (/library/metadata/<ratingkey>). |
1548 | | - labels (List<:class:`~plexapi.media.Label`>): List of label objects. |
1549 | | - librarySectionID (int): :class:`~plexapi.library.LibrarySection` ID. |
1550 | | - librarySectionKey (str): :class:`~plexapi.library.LibrarySection` key. |
1551 | | - librarySectionTitle (str): :class:`~plexapi.library.LibrarySection` title. |
1552 | | - maxYear (int): Maximum year for the items in the collection. |
1553 | | - minYear (int): Minimum year for the items in the collection. |
1554 | | - ratingKey (int): Unique key identifying the collection. |
1555 | | - subtype (str): Media type of the items in the collection (movie, show, artist, or album). |
1556 | | - summary (str): Summary of the collection. |
1557 | | - thumb (str): URL to thumbnail image (/library/metadata/<ratingKey>/thumb/<thumbid>). |
1558 | | - thumbBlurHash (str): BlurHash string for thumbnail image. |
1559 | | - title (str): Name of the collection. |
1560 | | - titleSort (str): Title to use when sorting (defaults to title). |
1561 | | - type (str): 'collection' |
1562 | | - updatedAt (datatime): Datetime the collection was updated. |
1563 | | - """ |
1564 | | - |
1565 | | - TAG = 'Directory' |
1566 | | - TYPE = 'collection' |
1567 | | - |
1568 | | - def _loadData(self, data): |
1569 | | - self.addedAt = utils.toDatetime(data.attrib.get('addedAt')) |
1570 | | - self.art = data.attrib.get('art') |
1571 | | - self.artBlurHash = data.attrib.get('artBlurHash') |
1572 | | - self.childCount = utils.cast(int, data.attrib.get('childCount')) |
1573 | | - self.collectionMode = data.attrib.get('collectionMode') |
1574 | | - self.collectionSort = data.attrib.get('collectionSort') |
1575 | | - self.contentRating = data.attrib.get('contentRating') |
1576 | | - self.fields = self.findItems(data, media.Field) |
1577 | | - self.guid = data.attrib.get('guid') |
1578 | | - self.index = utils.cast(int, data.attrib.get('index')) |
1579 | | - self.key = data.attrib.get('key', '').replace('/children', '') # FIX_BUG_50 |
1580 | | - self.labels = self.findItems(data, media.Label) |
1581 | | - self.librarySectionID = data.attrib.get('librarySectionID') |
1582 | | - self.librarySectionKey = data.attrib.get('librarySectionKey') |
1583 | | - self.librarySectionTitle = data.attrib.get('librarySectionTitle') |
1584 | | - self.maxYear = utils.cast(int, data.attrib.get('maxYear')) |
1585 | | - self.minYear = utils.cast(int, data.attrib.get('minYear')) |
1586 | | - self.ratingKey = utils.cast(int, data.attrib.get('ratingKey')) |
1587 | | - self.subtype = data.attrib.get('subtype') |
1588 | | - self.summary = data.attrib.get('summary') |
1589 | | - self.thumb = data.attrib.get('thumb') |
1590 | | - self.thumbBlurHash = data.attrib.get('thumbBlurHash') |
1591 | | - self.title = data.attrib.get('title') |
1592 | | - self.titleSort = data.attrib.get('titleSort', self.title) |
1593 | | - self.type = data.attrib.get('type') |
1594 | | - self.updatedAt = utils.toDatetime(data.attrib.get('updatedAt')) |
1595 | | - |
1596 | | - @property |
1597 | | - @deprecated('use "items" instead', stacklevel=3) |
1598 | | - def children(self): |
1599 | | - return self.items() |
1600 | | - |
1601 | | - @property |
1602 | | - def thumbUrl(self): |
1603 | | - """ Return the thumbnail url for the collection.""" |
1604 | | - return self._server.url(self.thumb, includeToken=True) if self.thumb else None |
1605 | | - |
1606 | | - @property |
1607 | | - def artUrl(self): |
1608 | | - """ Return the art url for the collection.""" |
1609 | | - return self._server.url(self.art, includeToken=True) if self.art else None |
1610 | | - |
1611 | | - def item(self, title): |
1612 | | - """ Returns the item in the collection that matches the specified title. |
1613 | | -
|
1614 | | - Parameters: |
1615 | | - title (str): Title of the item to return. |
1616 | | - """ |
1617 | | - key = '/library/metadata/%s/children' % self.ratingKey |
1618 | | - return self.fetchItem(key, title__iexact=title) |
1619 | | - |
1620 | | - def items(self): |
1621 | | - """ Returns a list of all items in the collection. """ |
1622 | | - key = '/library/metadata/%s/children' % self.ratingKey |
1623 | | - return self.fetchItems(key) |
1624 | | - |
1625 | | - def get(self, title): |
1626 | | - """ Alias to :func:`~plexapi.library.Collection.item`. """ |
1627 | | - return self.item(title) |
1628 | | - |
1629 | | - def __len__(self): |
1630 | | - return self.childCount |
1631 | | - |
1632 | | - def _preferences(self): |
1633 | | - """ Returns a list of :class:`~plexapi.settings.Preferences` objects. """ |
1634 | | - items = [] |
1635 | | - data = self._server.query(self._details_key) |
1636 | | - for item in data.iter('Setting'): |
1637 | | - items.append(Setting(data=item, server=self._server)) |
1638 | | - |
1639 | | - return items |
1640 | | - |
1641 | | - def delete(self): |
1642 | | - part = '/library/metadata/%s' % self.ratingKey |
1643 | | - return self._server.query(part, method=self._server._session.delete) |
1644 | | - |
1645 | | - def modeUpdate(self, mode=None): |
1646 | | - """ Update Collection Mode |
1647 | | -
|
1648 | | - Parameters: |
1649 | | - mode: default (Library default) |
1650 | | - hide (Hide Collection) |
1651 | | - hideItems (Hide Items in this Collection) |
1652 | | - showItems (Show this Collection and its Items) |
1653 | | - Example: |
1654 | | -
|
1655 | | - collection = 'plexapi.library.Collections' |
1656 | | - collection.updateMode(mode="hide") |
1657 | | - """ |
1658 | | - mode_dict = {'default': '-1', |
1659 | | - 'hide': '0', |
1660 | | - 'hideItems': '1', |
1661 | | - 'showItems': '2'} |
1662 | | - key = mode_dict.get(mode) |
1663 | | - if key is None: |
1664 | | - raise BadRequest('Unknown collection mode : %s. Options %s' % (mode, list(mode_dict))) |
1665 | | - part = '/library/metadata/%s/prefs?collectionMode=%s' % (self.ratingKey, key) |
1666 | | - return self._server.query(part, method=self._server._session.put) |
1667 | | - |
1668 | | - def sortUpdate(self, sort=None): |
1669 | | - """ Update Collection Sorting |
1670 | | -
|
1671 | | - Parameters: |
1672 | | - sort: realease (Order Collection by realease dates) |
1673 | | - alpha (Order Collection Alphabetically) |
1674 | | -
|
1675 | | - Example: |
1676 | | -
|
1677 | | - colleciton = 'plexapi.library.Collections' |
1678 | | - collection.updateSort(mode="alpha") |
1679 | | - """ |
1680 | | - sort_dict = {'release': '0', |
1681 | | - 'alpha': '1'} |
1682 | | - key = sort_dict.get(sort) |
1683 | | - if key is None: |
1684 | | - raise BadRequest('Unknown sort dir: %s. Options: %s' % (sort, list(sort_dict))) |
1685 | | - part = '/library/metadata/%s/prefs?collectionSort=%s' % (self.ratingKey, key) |
1686 | | - return self._server.query(part, method=self._server._session.put) |
1687 | | - |
1688 | | - # def edit(self, **kwargs): |
1689 | | - # TODO |
1690 | | - |
1691 | | - |
1692 | 1528 | @utils.registerPlexObject |
1693 | 1529 | class Path(PlexObject): |
1694 | 1530 | """ Represents a single directory Path. |
|
0 commit comments