2
2
from urllib .parse import quote , quote_plus , unquote , urlencode
3
3
4
4
from plexapi import X_PLEX_CONTAINER_SIZE , log , utils
5
- from plexapi .base import PlexObject
5
+ from plexapi .base import PlexObject , PlexPartialObject
6
6
from plexapi .exceptions import BadRequest , NotFound
7
7
from plexapi .media import MediaTag
8
8
from plexapi .settings import Setting
@@ -657,6 +657,11 @@ def _cleanSearchSort(self, sort):
657
657
raise BadRequest ('Unknown sort dir: %s' % sdir )
658
658
return '%s:%s' % (lookup [scol ], sdir )
659
659
660
+ def _locations (self ):
661
+ """ Returns a list of :class:`~plexapi.library.Location` objects
662
+ """
663
+ return self .findItems (self ._data , etag = 'Location' )
664
+
660
665
def sync (self , policy , mediaSettings , client = None , clientId = None , title = None , sort = None , libtype = None ,
661
666
** kwargs ):
662
667
""" Add current library section as sync item for specified device.
@@ -1054,6 +1059,23 @@ def _loadData(self, data):
1054
1059
self .title = data .attrib .get ('title' )
1055
1060
self .type = data .attrib .get ('type' )
1056
1061
1062
+ @utils .registerPlexObject
1063
+ class Location (PlexObject ):
1064
+ """ Represents a single library Location.
1065
+
1066
+ Attributes:
1067
+ TAG (str): 'Location'
1068
+ id (int): Location path ID.
1069
+ path (str): Path used for library..
1070
+ """
1071
+ TAG = 'Location'
1072
+
1073
+ def _loadData (self , data ):
1074
+ """ Load attribute values from Plex XML response. """
1075
+ self ._data = data
1076
+ self .id = utils .cast (int , data .attrib .get ('id' ))
1077
+ self .path = data .attrib .get ('path' )
1078
+
1057
1079
1058
1080
@utils .registerPlexObject
1059
1081
class Hub (PlexObject ):
@@ -1084,7 +1106,38 @@ def __len__(self):
1084
1106
1085
1107
1086
1108
@utils .registerPlexObject
1087
- class Collections (PlexObject ):
1109
+ class Collections (PlexPartialObject ):
1110
+ """ Represents a single Collection.
1111
+
1112
+ Attributes:
1113
+ TAG (str): 'Directory'
1114
+ TYPE (str): 'collection'
1115
+
1116
+ ratingKey (int): Unique key identifying this item.
1117
+ addedAt (datetime): Datetime this item was added to the library.
1118
+ childCount (int): Count of child object(s)
1119
+ collectionMode (str): How the items in the collection are displayed.
1120
+ collectionSort (str): How to sort the items in the collection.
1121
+ contentRating (str) Content rating (PG-13; NR; TV-G).
1122
+ fields (list): List of :class:`~plexapi.media.Field`.
1123
+ guid (str): Plex GUID (collection://XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXX).
1124
+ index (int): Unknown
1125
+ key (str): API URL (/library/metadata/<ratingkey>).
1126
+ labels (List<:class:`~plexapi.media.Label`>): List of field objects.
1127
+ librarySectionID (int): :class:`~plexapi.library.LibrarySection` ID.
1128
+ librarySectionKey (str): API URL (/library/sections/<sectionkey>).
1129
+ librarySectionTitle (str): Section Title
1130
+ maxYear (int): Year
1131
+ minYear (int): Year
1132
+ subtype (str): Media type
1133
+ summary (str): Summary of the collection
1134
+ thumb (str): URL to thumbnail image.
1135
+ title (str): Collection Title
1136
+ titleSort (str): Title to use when sorting (defaults to title).
1137
+ type (str): Hardcoded 'collection'
1138
+ updatedAt (datatime): Datetime this item was updated.
1139
+
1140
+ """
1088
1141
1089
1142
TAG = 'Directory'
1090
1143
TYPE = 'collection'
@@ -1093,20 +1146,29 @@ class Collections(PlexObject):
1093
1146
def _loadData (self , data ):
1094
1147
self .ratingKey = utils .cast (int , data .attrib .get ('ratingKey' ))
1095
1148
self ._details_key = "/library/metadata/%s%s" % (self .ratingKey , self ._include )
1149
+ self .addedAt = utils .toDatetime (data .attrib .get ('addedAt' ))
1150
+ self .art = data .attrib .get ('art' )
1151
+ self .childCount = utils .cast (int , data .attrib .get ('childCount' ))
1152
+ self .collectionMode = data .attrib .get ('collectionMode' )
1153
+ self .collectionSort = data .attrib .get ('collectionSort' )
1154
+ self .contentRating = data .attrib .get ('contentRating' )
1155
+ self .fields = self .findItems (data , etag = 'Field' )
1156
+ self .guid = data .attrib .get ('guid' )
1157
+ self .index = utils .cast (int , data .attrib .get ('index' ))
1096
1158
self .key = data .attrib .get ('key' )
1097
- self .type = data .attrib .get ('type' )
1098
- self .title = data .attrib .get ('title' )
1159
+ self .labels = self .findItems (data , etag = 'Label' )
1160
+ self .librarySectionID = data .attrib .get ('librarySectionID' )
1161
+ self .librarySectionKey = data .attrib .get ('librarySectionKey' )
1162
+ self .librarySectionTitle = data .attrib .get ('librarySectionTitle' )
1163
+ self .maxYear = utils .cast (int , data .attrib .get ('maxYear' ))
1164
+ self .minYear = utils .cast (int , data .attrib .get ('minYear' ))
1099
1165
self .subtype = data .attrib .get ('subtype' )
1100
1166
self .summary = data .attrib .get ('summary' )
1101
- self .index = utils .cast (int , data .attrib .get ('index' ))
1102
1167
self .thumb = data .attrib .get ('thumb' )
1103
- self .addedAt = utils .toDatetime (data .attrib .get ('addedAt' ))
1168
+ self .title = data .attrib .get ('title' )
1169
+ self .titleSort = data .attrib .get ('titleSort' )
1170
+ self .type = data .attrib .get ('type' )
1104
1171
self .updatedAt = utils .toDatetime (data .attrib .get ('updatedAt' ))
1105
- self .childCount = utils .cast (int , data .attrib .get ('childCount' ))
1106
- self .minYear = utils .cast (int , data .attrib .get ('minYear' ))
1107
- self .maxYear = utils .cast (int , data .attrib .get ('maxYear' ))
1108
- self .collectionMode = data .attrib .get ('collectionMode' )
1109
- self .collectionSort = data .attrib .get ('collectionSort' )
1110
1172
1111
1173
@property
1112
1174
def children (self ):
0 commit comments