Private GIT

Skip to content
Snippets Groups Projects
Commit 4b833db3 authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

DB Sanity check to fix tvrage ID's

parent ca2f12fb
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,48 @@ class MainSanityCheck(db.DBSanityCheck):
self.fix_invalid_airdates()
self.fix_subtitles_codes()
self.fix_show_nfo_lang()
self.convert_tvrage_to_tvdb()
def convert_tvrage_to_tvdb(self):
logger.log(u'Checking for shows with tvrage id\'s, since tvrage is gone')
from sickbeard.indexers.indexer_config import INDEXER_TVRAGE
from sickbeard.indexers.indexer_config import INDEXER_TVDB
sqlResults = self.connection.select(
"SELECT indexer_id, show_name FROM tv_shows WHERE indexer = %i" % INDEXER_TVRAGE)
if sqlResults:
logger.log(u'Found %i shows with TVRage ID\', FIXING!' % len(sqlResults), logger.WARNING)
for tvrage_show in sqlResults:
mapping = self.connection.select(
"SELECT indexer_id FROM indexer_mapping WHERE mindexer_id=%i AND mindexer=%i AND indexer=%i" %
(tvrage_show['indexer_id'], INDEXER_TVRAGE, INDEXER_TVDB)
)
if len(mapping) != 1:
logger.log(
u'Error mapping show from tvrage to tvdb for %s, found %i results. This show will no longer update!' %
(tvrage_show['show_name'], len(mapping)), logger.WARNING
)
continue
logger.log('Mapping %s to tvdb id %i' % tvrage_show['show_name'], mapping[0]['indexer_id'])
self.connection.action(
"UPDATE tv_shows SET indexer=%i, indexer_id=%i WHERE indexer_id=%i" %
(INDEXER_TVDB, mapping[0]['indexer_id'], tvrage_show['indexer_id'])
)
logger.log(u'Relinking episodes to show')
self.connection.action(
"UPDATE tv_episodes SET indexer=%i, showid=%i, indexerid=0 WHERE showid=%i" %
(INDEXER_TVDB, mapping[0]['indexer_id'], tvrage_show['indexer_id'])
)
logger.log('Please perform a full update on %s' % tvrage_show['show_name'], logger.WARNING)
def fix_duplicate_shows(self, column='indexer_id'):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment