Commit 3f84dd71 authored by echel0n's avatar echel0n
Browse files

Added main database function to sync tv episodes to index

parent 26e066bb
# Changelog
- * 14eb31c - 2018-09-04: Release v9.3.68
- * d13de20 - 2018-09-05: Added main database function to sync tv episodes to index
- * 51f6fb2 - 2018-09-04: Release v9.3.68
- * 78d23e1 - 2018-09-04: Added 'tv_episodes_by_indexerid' database index. Added database test case. Fixed TV episode database upsert code. Misc variable name cleanup.
- * c11dace - 2018-09-01: Release v9.3.67
- * 1430717 - 2018-09-01: Fixed issue #255 - total episode count incorrect. Improved memory usage from database calls. Misc code cleanup.
......
......@@ -264,7 +264,7 @@ class Core(object):
db.upgrade()
# compact main database
if not self.developer and self.config.last_db_compact < time.time() - 604800: # 7 days
if self.config.last_db_compact < time.time() - 604800: # 7 days
self.main_db.compact()
self.config.last_db_compact = int(time.time())
......
......@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import os
import sickrage
from sickrage.core import helpers
from sickrage.core.databases import srDatabase
from sickrage.core.databases.main.index import MainTVShowsIndex, MainTVEpisodesIndex, MainIMDBInfoIndex, \
MainXEMRefreshIndex, MainSceneNumberingIndex, MainIndexerMappingIndex, MainHistoryIndex, \
......@@ -103,6 +104,7 @@ class MainDB(srDatabase):
self.fix_dupe_shows()
self.fix_dupe_episodes()
self.fix_orphaned_episodes()
self.sync_tv_episodes_by_indexerid()
def fix_show_none_types(self):
checked = []
......@@ -177,3 +179,12 @@ class MainDB(srDatabase):
if not self.get('tv_shows', ep['showid']):
sickrage.app.log.info("Deleting orphan episode with id: {}".format(ep["indexerid"]))
self.delete(ep)
def sync_tv_episodes_by_indexerid(self):
show = None
for episode in self.all('tv_episodes'):
if not show or int(episode["showid"]) != show.indexerid:
show = helpers.findCertainShow(int(episode["showid"]))
if show:
show.getEpisode(int(episode['season']), int(episode['episode'])).saveToDB()
Supports Markdown
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