Skip to content

Commit 0e407ce

Browse files
committed
adds Collection
1 parent 00eb79b commit 0e407ce

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.9
1+
1.3.0

arrapi/objs/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ def _parse(self, data: Any = None, attrs: Optional[Union[str, list]] = None, val
113113
return default
114114
elif value_type == "date":
115115
return datetime.strptime(value[:-1].split(".")[0], "%Y-%m-%dT%H:%M:%S")
116+
elif value_type == "collection":
117+
return arrapi.objs.simple.Collection(self._arr, value)
116118
elif value_type == "image":
117119
return arrapi.objs.simple.Image(self._arr, value)
118120
elif value_type == "season":

arrapi/objs/reload.py

+1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ def _load(self, data):
286286
self.added = self._parse(attrs="added", value_type="date")
287287
self.rating_votes = self._parse(attrs=["rating", "votes"], value_type="int")
288288
self.rating_value = self._parse(attrs=["rating", "value"], value_type="float")
289+
self.collection = self._parse(attrs="collection", value_type="collection")
289290
self.id = self._parse(attrs="id", value_type="int", default_is_none=True)
290291
if self._raw.v3:
291292
self.originalTitle = self._parse(attrs="originalTitle")

arrapi/objs/simple.py

+19
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ def _load(self, data):
88
super()._load(data)
99

1010

11+
class Collection(SimpleObj):
12+
""" Represents a single Collection.
13+
14+
Attributes:
15+
name (str): Name of the Collection.
16+
tmdbId (int): TMDb Collection ID of the Collection.
17+
"""
18+
19+
def _load(self, data):
20+
super()._load(data)
21+
self.name = self._parse(attrs="name")
22+
self.tmdbId = self._parse(attrs="tmdbId", value_type="int")
23+
self._finish(self.name)
24+
25+
def get_url(self):
26+
""" URL of the Collection on TMDb"""
27+
return f"https://www.themoviedb.org/collection/{self.tmdbId}"
28+
29+
1130
class Image(SimpleObj):
1231
""" Represents a single Image.
1332

docs/objs.rst

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ Command
7575
:members:
7676

7777

78+
Collection
79+
--------------------
80+
81+
.. autoclass:: arrapi.objs.simple.Collection
82+
:members:
83+
84+
7885
Remote Path Mapping
7986
--------------------
8087

0 commit comments

Comments
 (0)