Skip to content

Commit

Permalink
adds Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Dec 16, 2021
1 parent 00eb79b commit 0e407ce
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.9
1.3.0
2 changes: 2 additions & 0 deletions arrapi/objs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def _parse(self, data: Any = None, attrs: Optional[Union[str, list]] = None, val
return default
elif value_type == "date":
return datetime.strptime(value[:-1].split(".")[0], "%Y-%m-%dT%H:%M:%S")
elif value_type == "collection":
return arrapi.objs.simple.Collection(self._arr, value)
elif value_type == "image":
return arrapi.objs.simple.Image(self._arr, value)
elif value_type == "season":
Expand Down
1 change: 1 addition & 0 deletions arrapi/objs/reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def _load(self, data):
self.added = self._parse(attrs="added", value_type="date")
self.rating_votes = self._parse(attrs=["rating", "votes"], value_type="int")
self.rating_value = self._parse(attrs=["rating", "value"], value_type="float")
self.collection = self._parse(attrs="collection", value_type="collection")
self.id = self._parse(attrs="id", value_type="int", default_is_none=True)
if self._raw.v3:
self.originalTitle = self._parse(attrs="originalTitle")
Expand Down
19 changes: 19 additions & 0 deletions arrapi/objs/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ def _load(self, data):
super()._load(data)


class Collection(SimpleObj):
""" Represents a single Collection.
Attributes:
name (str): Name of the Collection.
tmdbId (int): TMDb Collection ID of the Collection.
"""

def _load(self, data):
super()._load(data)
self.name = self._parse(attrs="name")
self.tmdbId = self._parse(attrs="tmdbId", value_type="int")
self._finish(self.name)

def get_url(self):
""" URL of the Collection on TMDb"""
return f"https://www.themoviedb.org/collection/{self.tmdbId}"


class Image(SimpleObj):
""" Represents a single Image.
Expand Down
7 changes: 7 additions & 0 deletions docs/objs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ Command
:members:


Collection
--------------------

.. autoclass:: arrapi.objs.simple.Collection
:members:


Remote Path Mapping
--------------------

Expand Down

0 comments on commit 0e407ce

Please sign in to comment.