mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-08 11:03:38 +00:00
Misc fixes and code cleanups.
This commit is contained in:
parent
a9f142184a
commit
08d8beffa4
6 changed files with 59 additions and 51 deletions
|
@ -10,11 +10,11 @@
|
||||||
#set $myDB = $db.DBConnection()
|
#set $myDB = $db.DBConnection()
|
||||||
#set $today = str($datetime.date.today().toordinal())
|
#set $today = str($datetime.date.today().toordinal())
|
||||||
#set $numShows = len($sickbeard.showList)
|
#set $numShows = len($sickbeard.showList)
|
||||||
#set $numGoodShows = len([x for x in $sickbeard.showList if x.paused == 0 and x.status != "Ended"])
|
#set $numGoodShows = len([x for x in $sickbeard.showList if x.paused == 0 and "Ended" not in x.status])
|
||||||
#set $numDLEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE status IN ("+",".join([str(x) for x in $Quality.DOWNLOADED + [$ARCHIVED]])+") AND season != 0 and episode != 0 AND airdate <= "+$today+"")[0][0]
|
#set $numDLEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE status IN ("+",".join([str(x) for x in $Quality.DOWNLOADED + [$ARCHIVED]])+") AND season != 0 and episode != 0 AND airdate <= "+$today+"")[0][0]
|
||||||
#set $numEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE season != 0 and episode != 0 AND (airdate != 1 OR status IN ("+",".join([str(x) for x in ($Quality.DOWNLOADED + $Quality.SNATCHED + $Quality.SNATCHED_PROPER) + [$ARCHIVED]])+")) AND airdate <= "+$today+" AND status != "+str($IGNORED)+"")[0][0]
|
#set $numEpisodes = $myDB.select("SELECT COUNT(*) FROM tv_episodes WHERE season != 0 and episode != 0 AND (airdate != 1 OR status IN ("+",".join([str(x) for x in ($Quality.DOWNLOADED + $Quality.SNATCHED + $Quality.SNATCHED_PROPER) + [$ARCHIVED]])+")) AND airdate <= "+$today+" AND status != "+str($IGNORED)+"")[0][0]
|
||||||
<b>$numShows shows</b> ($numGoodShows active) | <b>$numDLEpisodes/$numEpisodes</b> episodes downloaded |
|
<b>$numShows shows</b> ($numGoodShows active) | <b>$numDLEpisodes/$numEpisodes</b> episodes downloaded |
|
||||||
<b>Daily Search</b>: <%=str(sickbeard.dailySearchScheduler.timeLeft()).split('.')[0]%> |
|
<b>Search</b>: <%=str(sickbeard.dailySearchScheduler.timeLeft()).split('.')[0]%> |
|
||||||
<b>Backlog</b>: $sbdatetime.sbdatetime.sbfdate($sickbeard.backlogSearchScheduler.nextRun())
|
<b>Backlog</b>: $sbdatetime.sbdatetime.sbfdate($sickbeard.backlogSearchScheduler.nextRun())
|
||||||
</div>
|
</div>
|
||||||
<ul style="float:right;">
|
<ul style="float:right;">
|
||||||
|
|
|
@ -29,7 +29,7 @@ class rTorrentAPI(GenericClient):
|
||||||
super(rTorrentAPI, self).__init__('rTorrent', host, username, password)
|
super(rTorrentAPI, self).__init__('rTorrent', host, username, password)
|
||||||
|
|
||||||
def _get_auth(self):
|
def _get_auth(self):
|
||||||
auth = None
|
self.auth = None
|
||||||
|
|
||||||
if self.auth is not None:
|
if self.auth is not None:
|
||||||
return self.auth
|
return self.auth
|
||||||
|
|
|
@ -50,7 +50,7 @@ class DBConnection:
|
||||||
def __init__(self, filename="sickbeard.db", suffix=None, row_type=None):
|
def __init__(self, filename="sickbeard.db", suffix=None, row_type=None):
|
||||||
|
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.connection = sqlite3.connect(dbFilename(filename), 20)
|
self.connection = sqlite3.connect(dbFilename(filename, suffix), 20)
|
||||||
if row_type == "dict":
|
if row_type == "dict":
|
||||||
self.connection.row_factory = self._dict_factory
|
self.connection.row_factory = self._dict_factory
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -99,8 +99,7 @@ def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, fallback_
|
||||||
(so the return values will always be set)
|
(so the return values will always be set)
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param season: int
|
@param absolute_number: int
|
||||||
@param episode: int
|
|
||||||
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
|
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
|
||||||
@return: (int, int) a tuple with (season, episode)
|
@return: (int, int) a tuple with (season, episode)
|
||||||
"""
|
"""
|
||||||
|
@ -258,9 +257,8 @@ def find_xem_absolute_numbering(indexer_id, indexer, absolute_number):
|
||||||
Refreshes/Loads as needed.
|
Refreshes/Loads as needed.
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param season: int
|
@param absolute_number: int
|
||||||
@param episode: int
|
@return: int
|
||||||
@return: (int, int) a tuple of scene_season, scene_episode, or None if there is no special mapping.
|
|
||||||
"""
|
"""
|
||||||
if indexer_id is None or absolute_number is None:
|
if indexer_id is None or absolute_number is None:
|
||||||
return absolute_number
|
return absolute_number
|
||||||
|
@ -313,9 +311,8 @@ def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNum
|
||||||
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
|
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
|
||||||
|
|
||||||
@param indexer_id: int
|
@param indexer_id: int
|
||||||
@param sceneSeason: int
|
@param sceneAbsoluteNumber: int
|
||||||
@param sceneEpisode: int
|
@return: int
|
||||||
@return: (int, int) a tuple of (season, episode)
|
|
||||||
"""
|
"""
|
||||||
if indexer_id is None or sceneAbsoluteNumber is None:
|
if indexer_id is None or sceneAbsoluteNumber is None:
|
||||||
return sceneAbsoluteNumber
|
return sceneAbsoluteNumber
|
||||||
|
|
|
@ -28,6 +28,7 @@ import datetime
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from Cheetah.Template import Template
|
from Cheetah.Template import Template
|
||||||
|
from cherrypy.lib.static import serve_fileobj
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import cherrypy.lib
|
import cherrypy.lib
|
||||||
import cherrypy.lib.cptools
|
import cherrypy.lib.cptools
|
||||||
|
@ -78,12 +79,15 @@ except ImportError:
|
||||||
from sickbeard import browser
|
from sickbeard import browser
|
||||||
from lib import adba
|
from lib import adba
|
||||||
|
|
||||||
|
|
||||||
def _handle_reverse_proxy():
|
def _handle_reverse_proxy():
|
||||||
if sickbeard.HANDLE_REVERSE_PROXY:
|
if sickbeard.HANDLE_REVERSE_PROXY:
|
||||||
cherrypy.lib.cptools.proxy()
|
cherrypy.lib.cptools.proxy()
|
||||||
|
|
||||||
|
|
||||||
cherrypy.tools.handle_reverse_proxy = cherrypy.Tool('before_handler', _handle_reverse_proxy)
|
cherrypy.tools.handle_reverse_proxy = cherrypy.Tool('before_handler', _handle_reverse_proxy)
|
||||||
|
|
||||||
|
|
||||||
class PageTemplate(Template):
|
class PageTemplate(Template):
|
||||||
def __init__(self, *args, **KWs):
|
def __init__(self, *args, **KWs):
|
||||||
KWs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/",
|
KWs['file'] = os.path.join(sickbeard.PROG_DIR, "gui/" + sickbeard.GUI_NAME + "/interfaces/default/",
|
||||||
|
@ -638,7 +642,8 @@ class Manage:
|
||||||
return _munge(t)
|
return _munge(t)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def massEditSubmit(self, paused=None, anime=None, scene=None, flatten_folders=None, quality_preset=False, subtitles=None,
|
def massEditSubmit(self, paused=None, anime=None, scene=None, flatten_folders=None, quality_preset=False,
|
||||||
|
subtitles=None,
|
||||||
anyQualities=[], bestQualities=[], toEdit=None, *args, **kwargs):
|
anyQualities=[], bestQualities=[], toEdit=None, *args, **kwargs):
|
||||||
|
|
||||||
dir_map = {}
|
dir_map = {}
|
||||||
|
@ -1596,7 +1601,8 @@ class ConfigProviders:
|
||||||
curProvider, curEnabled = curProviderStr.split(':')
|
curProvider, curEnabled = curProviderStr.split(':')
|
||||||
curEnabled = config.to_int(curEnabled)
|
curEnabled = config.to_int(curEnabled)
|
||||||
|
|
||||||
curProvObj = [x for x in sickbeard.providers.sortedProviderList() if x.getID() == curProvider and hasattr(x, 'enabled')]
|
curProvObj = [x for x in sickbeard.providers.sortedProviderList() if
|
||||||
|
x.getID() == curProvider and hasattr(x, 'enabled')]
|
||||||
if curProvObj:
|
if curProvObj:
|
||||||
curProvObj[0].enabled = bool(curEnabled)
|
curProvObj[0].enabled = bool(curEnabled)
|
||||||
|
|
||||||
|
@ -2025,8 +2031,8 @@ class ConfigSubtitles:
|
||||||
|
|
||||||
redirect("/config/subtitles/")
|
redirect("/config/subtitles/")
|
||||||
|
|
||||||
class ConfigAnime:
|
|
||||||
|
|
||||||
|
class ConfigAnime:
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self):
|
def index(self):
|
||||||
|
|
||||||
|
@ -2035,7 +2041,8 @@ class ConfigAnime:
|
||||||
return _munge(t)
|
return _munge(t)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None, split_home=None):
|
def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None,
|
||||||
|
split_home=None):
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
|
@ -2072,6 +2079,7 @@ class ConfigAnime:
|
||||||
|
|
||||||
redirect("/config/anime/")
|
redirect("/config/anime/")
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self):
|
def index(self):
|
||||||
|
@ -2094,6 +2102,7 @@ class Config:
|
||||||
|
|
||||||
anime = ConfigAnime()
|
anime = ConfigAnime()
|
||||||
|
|
||||||
|
|
||||||
def haveXBMC():
|
def haveXBMC():
|
||||||
return sickbeard.USE_XBMC and sickbeard.XBMC_UPDATE_LIBRARY
|
return sickbeard.USE_XBMC and sickbeard.XBMC_UPDATE_LIBRARY
|
||||||
|
|
||||||
|
@ -2213,8 +2222,7 @@ class NewHomeAddShows:
|
||||||
|
|
||||||
map(final_results.extend,
|
map(final_results.extend,
|
||||||
([[sickbeard.indexerApi(id).name, id, sickbeard.indexerApi(id).config["show_url"], int(show['id']),
|
([[sickbeard.indexerApi(id).name, id, sickbeard.indexerApi(id).config["show_url"], int(show['id']),
|
||||||
show['seriesname'], show['firstaired']] for show in shows] for id, shows in
|
show['seriesname'], show['firstaired']] for show in shows] for id, shows in results.items()))
|
||||||
results.items()))
|
|
||||||
|
|
||||||
lang_id = sickbeard.indexerApi().config['langabbv_to_id'][lang]
|
lang_id = sickbeard.indexerApi().config['langabbv_to_id'][lang]
|
||||||
return json.dumps({'results': final_results, 'langid': lang_id})
|
return json.dumps({'results': final_results, 'langid': lang_id})
|
||||||
|
@ -2454,7 +2462,8 @@ class NewHomeAddShows:
|
||||||
|
|
||||||
# add the show
|
# add the show
|
||||||
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality,
|
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality,
|
||||||
flatten_folders, subtitles, indexerLang, anime, scene) # @UndefinedVariable
|
flatten_folders, subtitles, indexerLang, anime,
|
||||||
|
scene) # @UndefinedVariable
|
||||||
ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
|
ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
|
||||||
|
|
||||||
return finishAddShow()
|
return finishAddShow()
|
||||||
|
@ -2639,7 +2648,6 @@ class Home:
|
||||||
def index(self):
|
def index(self):
|
||||||
|
|
||||||
t = PageTemplate(file="home.tmpl")
|
t = PageTemplate(file="home.tmpl")
|
||||||
|
|
||||||
if sickbeard.ANIME_SPLIT_HOME:
|
if sickbeard.ANIME_SPLIT_HOME:
|
||||||
shows = []
|
shows = []
|
||||||
anime = []
|
anime = []
|
||||||
|
@ -3088,7 +3096,8 @@ class Home:
|
||||||
t.sortedShowLists = [["Shows", sorted(shows, lambda x, y: cmp(titler(x.name), titler(y.name)))],
|
t.sortedShowLists = [["Shows", sorted(shows, lambda x, y: cmp(titler(x.name), titler(y.name)))],
|
||||||
["Anime", sorted(anime, lambda x, y: cmp(titler(x.name), titler(y.name)))]]
|
["Anime", sorted(anime, lambda x, y: cmp(titler(x.name), titler(y.name)))]]
|
||||||
else:
|
else:
|
||||||
t.sortedShowLists = [["Shows",sorted(sickbeard.showList, lambda x, y: cmp(titler(x.name), titler(y.name)))]]
|
t.sortedShowLists = [
|
||||||
|
["Shows", sorted(sickbeard.showList, lambda x, y: cmp(titler(x.name), titler(y.name)))]]
|
||||||
|
|
||||||
t.bwl = BlackAndWhiteList(showObj.indexerid)
|
t.bwl = BlackAndWhiteList(showObj.indexerid)
|
||||||
|
|
||||||
|
@ -3760,7 +3769,8 @@ class Home:
|
||||||
return json.dumps({'result': status, 'subtitles': ','.join([x for x in ep_obj.subtitles])})
|
return json.dumps({'result': status, 'subtitles': ','.join([x for x in ep_obj.subtitles])})
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def setSceneNumbering(self, show, indexer, forSeason=None, forEpisode=None, forAbsolute=None, sceneSeason=None, sceneEpisode=None, sceneAbsolute=None):
|
def setSceneNumbering(self, show, indexer, forSeason=None, forEpisode=None, forAbsolute=None, sceneSeason=None,
|
||||||
|
sceneEpisode=None, sceneAbsolute=None):
|
||||||
|
|
||||||
# sanitize:
|
# sanitize:
|
||||||
if forSeason in ['null', '']: forSeason = None
|
if forSeason in ['null', '']: forSeason = None
|
||||||
|
@ -3814,7 +3824,8 @@ class Home:
|
||||||
if sceneSeason is not None: sceneSeason = int(sceneSeason)
|
if sceneSeason is not None: sceneSeason = int(sceneSeason)
|
||||||
if sceneEpisode is not None: sceneEpisode = int(sceneEpisode)
|
if sceneEpisode is not None: sceneEpisode = int(sceneEpisode)
|
||||||
|
|
||||||
set_scene_numbering(show, indexer, season=forSeason, episode=forEpisode, sceneSeason=sceneSeason, sceneEpisode=sceneEpisode)
|
set_scene_numbering(show, indexer, season=forSeason, episode=forEpisode, sceneSeason=sceneSeason,
|
||||||
|
sceneEpisode=sceneEpisode)
|
||||||
|
|
||||||
if showObj.is_anime:
|
if showObj.is_anime:
|
||||||
sn = get_scene_absolute_numbering(show, indexer, forAbsolute)
|
sn = get_scene_absolute_numbering(show, indexer, forAbsolute)
|
||||||
|
|
Loading…
Reference in a new issue