mirror of
https://github.com/moparisthebest/SickRage
synced 2024-11-04 08:25:04 -05:00
Scene exceptions for anidb and xem now update once a day, thanks zoggy for pointing that out :)
This commit is contained in:
parent
99d129bd41
commit
cfafc0a39f
@ -81,3 +81,11 @@ class AddSceneExceptionsCustom(AddSceneExceptionsSeasons):
|
||||
|
||||
def execute(self):
|
||||
self.addColumn("scene_exceptions", "custom", "NUMERIC", 0)
|
||||
|
||||
class AddSceneExceptionsRefresh(AddSceneExceptionsCustom):
|
||||
def test(self):
|
||||
return self.hasTable("scene_exceptions_refresh")
|
||||
|
||||
def execute(self):
|
||||
self.connection.action(
|
||||
"CREATE TABLE scene_exceptions_refresh (list TEXT, last_refreshed INTEGER)")
|
@ -17,7 +17,7 @@
|
||||
# along with SickRage. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
import sickbeard
|
||||
|
||||
from lib import adba
|
||||
@ -26,6 +26,9 @@ from sickbeard import name_cache
|
||||
from sickbeard import logger
|
||||
from sickbeard import db
|
||||
|
||||
MAX_XEM_AGE_SECS = 86400 # 1 day
|
||||
MAX_ANIDB_AGE_SECS = 86400 # 1 day
|
||||
|
||||
exceptionCache = {}
|
||||
exceptionSeasonCache = {}
|
||||
exceptionIndexerCache = {}
|
||||
@ -228,7 +231,22 @@ def update_scene_exceptions(indexer_id, scene_exceptions):
|
||||
name_cache.clearCache()
|
||||
|
||||
def _retrieve_anidb_mainnames():
|
||||
global MAX_ANIDB_AGE_SECS
|
||||
|
||||
success = False
|
||||
|
||||
anidb_mainNames = {}
|
||||
|
||||
cacheDB = db.DBConnection('cache.db')
|
||||
|
||||
rows = cacheDB.select("SELECT last_refreshed FROM scene_exceptions_refresh WHERE list = ?",
|
||||
['anidb'])
|
||||
if rows:
|
||||
refresh = time.time() > (int(rows[0]['last_refreshed']) + MAX_ANIDB_AGE_SECS)
|
||||
else:
|
||||
refresh = True
|
||||
|
||||
if refresh:
|
||||
for show in sickbeard.showList:
|
||||
if show.is_anime and show.indexer == 1:
|
||||
try:
|
||||
@ -236,15 +254,33 @@ def _retrieve_anidb_mainnames():
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
success = True
|
||||
|
||||
if anime.name and anime.name != show.name:
|
||||
anidb_mainNames[show.indexerid] = [{anime.name: -1}]
|
||||
|
||||
if success:
|
||||
cacheDB.action("INSERT OR REPLACE INTO scene_exceptions_refresh (list, last_refreshed) VALUES (?,?)",
|
||||
['anidb', time.time()])
|
||||
|
||||
return anidb_mainNames
|
||||
|
||||
|
||||
def _xem_excpetions_fetcher(indexer):
|
||||
global MAX_XEM_AGE_SECS
|
||||
|
||||
exception_dict = {}
|
||||
|
||||
cacheDB = db.DBConnection('cache.db')
|
||||
|
||||
rows = cacheDB.select("SELECT last_refreshed FROM scene_exceptions_refresh WHERE list = ?",
|
||||
['xem'])
|
||||
if rows:
|
||||
refresh = time.time() > (int(rows[0]['last_refreshed']) + MAX_XEM_AGE_SECS)
|
||||
else:
|
||||
refresh = True
|
||||
|
||||
if refresh:
|
||||
url = "http://thexem.de/map/allNames?origin=%s&seasonNumbers=1" % sickbeard.indexerApi(indexer).config['xem_origin']
|
||||
|
||||
url_data = helpers.getURL(url, json=True)
|
||||
@ -255,6 +291,9 @@ def _xem_excpetions_fetcher(indexer):
|
||||
if url_data['result'] == 'failure':
|
||||
return exception_dict
|
||||
|
||||
cacheDB.action("INSERT OR REPLACE INTO scene_exceptions_refresh (list, last_refreshed) VALUES (?,?)",
|
||||
['xem', time.time()])
|
||||
|
||||
for indexerid, names in url_data['data'].items():
|
||||
exception_dict[int(indexerid)] = names
|
||||
|
||||
|
@ -41,7 +41,6 @@ from lib import requests
|
||||
|
||||
MAX_XEM_AGE_SECS = 86400 # 1 day
|
||||
|
||||
|
||||
def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=True):
|
||||
"""
|
||||
Returns a tuple, (season, episode), with the scene numbering (if there is one),
|
||||
|
Loading…
Reference in New Issue
Block a user