Skip to content

Commit 9d364e4

Browse files
committed
init chapters.
1 parent faa8f42 commit 9d364e4

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

plexapi/media.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,27 @@ class Writer(MediaTag):
468468
FILTER = 'writer'
469469

470470

471+
@utils.registerPlexObject
472+
class Chapter(PlexObject):
473+
""" Represents a single Writer media tag.
474+
475+
Attributes:
476+
TAG (str): 'Chapter'
477+
"""
478+
TAG = 'Chapter'
479+
480+
481+
def _loadData(self, data):
482+
self._data = data
483+
self.id = cast(int, data.attrib.get('id', 0))
484+
self.filter = data.attrib.get('filter') # I couldn't filter on it anyways
485+
self.tag = data.attrib.get('tag')
486+
self.title = self.tag
487+
self.index = cast(int, data.attrib.get('index'))
488+
self.start = cast(int, data.attrib.get('startTimeOffset'))
489+
self.end = cast(int, data.attrib.get('endTimeOffset'))
490+
491+
471492
@utils.registerPlexObject
472493
class Field(PlexObject):
473494
""" Represents a single Field.

plexapi/video.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,18 @@ class Movie(Video, Playable):
111111
producers (List<:class:`~plexapi.media.Producer`>): List of producers objects.
112112
roles (List<:class:`~plexapi.media.Role`>): List of role objects.
113113
writers (List<:class:`~plexapi.media.Writer`>): List of writers objects.
114+
chapters (List<:class:`~plexapi.media.Chapter`>): List of Chapter objects.
114115
"""
115116
TAG = 'Video'
116117
TYPE = 'movie'
118+
_include = '?checkFiles=1&includeExtras=1&includeRelated=1&includeRelatedCount=5&includeOnDeck=1&includeChapters=1&includePopularLeaves=1&includeConcerts=1&includePreferences=1'
117119

118120
def _loadData(self, data):
119121
""" Load attribute values from Plex XML response. """
120122
Video._loadData(self, data)
121123
Playable._loadData(self, data)
124+
125+
self.key = data.attrib.get('key') + self._include
122126
self.art = data.attrib.get('art')
123127
self.audienceRating = utils.cast(float, data.attrib.get('audienceRating'))
124128
self.audienceRatingImage = data.attrib.get('audienceRatingImage')
@@ -147,6 +151,7 @@ def _loadData(self, data):
147151
self.roles = self.findItems(data, media.Role)
148152
self.writers = self.findItems(data, media.Writer)
149153
self.labels = self.findItems(data, media.Label)
154+
self.chapters = self.findItems(data, media.Chapter)
150155

151156
@property
152157
def actors(self):

0 commit comments

Comments
 (0)