delete should be part of the media not the media part

This commit is contained in:
Hellowlol 2017-09-30 23:16:40 +02:00
parent e2f90ea81d
commit 828b41e0ec

View file

@ -52,6 +52,15 @@ class Media(PlexObject):
self.width = cast(int, data.attrib.get('width'))
self.parts = self.findItems(data, MediaPart)
def delete(self):
part = self._initpath + '/media/%s' % self.id
try:
return self._server.query(part, method=self._server._session.delete)
except BadRequest:
log.error("Failed to delete %s. This could be because you havn't allowed "
"items to be deleted" % part)
raise
@utils.registerPlexObject
class MediaPart(PlexObject):
@ -85,16 +94,6 @@ class MediaPart(PlexObject):
self.size = cast(int, data.attrib.get('size'))
self.streams = self._buildStreams(data)
def delete(self):
log.debug('Deleting %s', self.file)
part = self._initpath + '/media/%s' % self.id
try:
return self._server.query(part, method=self._server._session.delete)
except BadRequest:
log.error("Failed to delete %s. This could be because you havn't allowed "
"items to be deleted" % part)
raise
def _buildStreams(self, data):
streams = []
for elem in data: