From 14201c71f3b6c7ad71dddeeeaa59fe22347d8023 Mon Sep 17 00:00:00 2001 From: echel0n Date: Fri, 6 Jun 2014 15:16:15 -0700 Subject: [PATCH] Fixes issues with scene numbering being set to 0x0 after snatch is performed. Fixes issues with KAT Provider sphinx error on searches. --- sickbeard/providers/kat.py | 4 +--- sickbeard/tv.py | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/sickbeard/providers/kat.py b/sickbeard/providers/kat.py index 187b0058..bbf78164 100644 --- a/sickbeard/providers/kat.py +++ b/sickbeard/providers/kat.py @@ -210,9 +210,7 @@ class KATProvider(generic.TorrentProvider): sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season, 'episodenumber': ep_obj.scene_episode} + '|' + \ sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep_obj.scene_season, - 'episodenumber': ep_obj.scene_episode} + '|' + \ - sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep_obj.scene_season, - 'episodenumber': ep_obj.scene_episode} + ' %s category:tv' % add_string + 'episodenumber': ep_obj.scene_episode} + '|' + ' %s category:tv' % add_string search_string['Episode'].append(re.sub('\s+', ' ', ep_string)) return [search_string] diff --git a/sickbeard/tv.py b/sickbeard/tv.py index ebaa416a..a7f31ead 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -1837,14 +1837,36 @@ class TVEpisode(object): logger.log(str(self.show.indexerid) + u": Not creating SQL queue - record is not dirty", logger.DEBUG) return - # use a custom update/insert method to get the data into the DB - return [ - "INSERT OR REPLACE INTO tv_episodes (episode_id, indexerid, indexer, name, description, subtitles, subtitles_searchcount, subtitles_lastsearch, airdate, hasnfo, hastbn, status, location, file_size, release_name, is_proper, showid, season, episode, absolute_number) VALUES " - "((SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", - [self.show.indexerid, self.season, self.episode, self.indexerid, self.indexer, self.name, self.description, - ",".join([sub for sub in self.subtitles]), self.subtitles_searchcount, self.subtitles_lastsearch, - self.airdate.toordinal(), self.hasnfo, self.hastbn, self.status, self.location, self.file_size, - self.release_name, self.is_proper, self.show.indexerid, self.season, self.episode, self.absolute_number]] + myDB = db.DBConnection() + + rows = myDB.select( + 'SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?', + [self.show.indexerid, self.season, self.episode]) + + epID = None + if rows: + epID = int(rows[0]['episode_id']) + + if epID: + # use a custom update method to get the data into the DB for existing records. + return [ + "UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, subtitles = ?, " + "subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, " + "location = ?, file_size = ?, release_name = ?, is_proper = ?, showid = ?, season = ?, episode = ?, " + "absolute_number = ? WHERE episode_id = ?", + [self.indexerid, self.indexer, self.name, self.description, ",".join([sub for sub in self.subtitles]), + self.subtitles_searchcount, self.subtitles_lastsearch, self.airdate.toordinal(), self.hasnfo, self.hastbn, + self.status, self.location, self.file_size,self.release_name, self.is_proper, self.show.indexerid, + self.season, self.episode, self.absolute_number, epID]] + else: + # use a custom insert method to get the data into the DB. + return [ + "INSERT OR IGNORE INTO tv_episodes (episode_id, indexerid, indexer, name, description, subtitles, subtitles_searchcount, subtitles_lastsearch, airdate, hasnfo, hastbn, status, location, file_size, release_name, is_proper, showid, season, episode, absolute_number) VALUES " + "((SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);", + [self.show.indexerid, self.season, self.episode, self.indexerid, self.indexer, self.name, self.description, + ",".join([sub for sub in self.subtitles]), self.subtitles_searchcount, self.subtitles_lastsearch, + self.airdate.toordinal(), self.hasnfo, self.hastbn, self.status, self.location, self.file_size, + self.release_name, self.is_proper, self.show.indexerid, self.season, self.episode, self.absolute_number]] def saveToDB(self, forceSave=False): """