Commit f9de00fd authored by echel0n's avatar echel0n

Added deleete method to TVShow and TVEpisode object classes to remove themselves from database.

parent 8c2dd986
......@@ -295,6 +295,10 @@ class TVEpisode(object):
def save(self):
self.db_session.commit()
def delete(self):
self.db_session.delete(self._data)
self.save()
def load(self):
sickrage.app.log.debug("{}: Populating info for episode S{:02d}E{:02d}".format(self.showid, self.season, self.episode))
self.populate_episode(self.season, self.episode)
......@@ -679,8 +683,7 @@ class TVEpisode(object):
# delete myself from the DB
sickrage.app.log.debug("Deleting myself from the database")
self.db_session.delete(self)
self.save()
self.delete()
raise EpisodeDeletedException()
......
......@@ -478,6 +478,10 @@ class TVShow(object):
def save(self):
self.db_session.commit()
def delete(self):
self.db_session.delete(self._data)
self.save()
def load_from_indexer(self, cache=True, tvapi=None):
if self.indexer is not INDEXER_TVRAGE:
sickrage.app.log.debug(
......
......@@ -626,12 +626,16 @@ class GenericMetadata(object):
return None
is_image_thumb = '_thumb' in image_type
image_types = {
'{}'.format(image_type): {
'indexer': lambda: t.images(show_obj.indexer_id, key_type=image_type.replace('_thumb', ''))[which][('filename', 'thumbnail')[is_image_thumb]],
'fanart': lambda: self._retrieve_show_images_from_fanart(show_obj, image_type.replace('_thumb', ''), is_image_thumb)
try:
image_types = {
'{}'.format(image_type): {
'indexer': lambda: t.images(show_obj.indexer_id, key_type=image_type.replace('_thumb', ''))[which][('filename', 'thumbnail')[is_image_thumb]],
'fanart': lambda: self._retrieve_show_images_from_fanart(show_obj, image_type.replace('_thumb', ''), is_image_thumb)
}
}
}
except Exception as e:
return None
for fname in ['indexer', 'fanart']:
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment