mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Merge pull request #275 from JackDandy/feature/FixSetWantedOnAdd
Fix to correctly use wanted_begin and wanted_latest when adding shows.
This commit is contained in:
commit
dfa28d31fb
5 changed files with 44 additions and 32 deletions
|
@ -51,7 +51,7 @@
|
|||
* Fix being able to actually turn IMDb off when it has been turned on
|
||||
* Remove IMDb option from General Settings
|
||||
* Change IMDb option to enable by default now the slow operation has been eliminated from process flows
|
||||
|
||||
* Fix to correctly use wanted_begin and wanted_latest when adding shows
|
||||
|
||||
### 0.7.2 (2015-03-10 17:05:00 UTC)
|
||||
|
||||
|
|
|
@ -31,15 +31,15 @@
|
|||
<div class="field-pair alt">
|
||||
<span class="component-title">From season 1 forward, set</span>
|
||||
<span class="component-desc">
|
||||
<label for="wanted-begin" style="padding-bottom:10px">
|
||||
<input type="number" name="wanted-begin" id="wanted-begin" value="$sickbeard.WANTED_BEGIN_DEFAULT" class="form-control input-sm input75">
|
||||
<label for="wanted_begin" style="padding-bottom:10px">
|
||||
<input type="number" name="wanted_begin" id="wanted_begin" value="$sickbeard.WANTED_BEGIN_DEFAULT" class="form-control input-sm input75">
|
||||
<span>episodes as wanted (10 ... 0, and where -1 is whole first season)</span>
|
||||
</label>
|
||||
</span>
|
||||
<span class="component-title">From latest going back, set</span>
|
||||
<span class="component-desc">
|
||||
<label for="wanted-latest">
|
||||
<input type="number" name="wanted-latest" id="wanted-latest" value="$sickbeard.WANTED_LATEST_DEFAULT" class="form-control input-sm input75">
|
||||
<label for="wanted_latest">
|
||||
<input type="number" name="wanted_latest" id="wanted_latest" value="$sickbeard.WANTED_LATEST_DEFAULT" class="form-control input-sm input75">
|
||||
<span>episodes as wanted (10 ... 0, and where -1 is whole latest season)</span>
|
||||
</label>
|
||||
</span>
|
||||
|
|
|
@ -14,8 +14,8 @@ $(document).ready(function(){
|
|||
default_status: $('#statusSelect').val(),
|
||||
any_qualities: anyQualArray.join(','),
|
||||
best_qualities: bestQualArray.join(','),
|
||||
default_wanted_begin: $('#wanted-begin').val(),
|
||||
default_wanted_latest: $('#wanted-latest').val(),
|
||||
default_wanted_begin: $('#wanted_begin').val(),
|
||||
default_wanted_latest: $('#wanted_latest').val(),
|
||||
default_flatten_folders: $('#flatten_folders').prop('checked'),
|
||||
default_scene: $('#scene').prop('checked'),
|
||||
default_subtitles: $('#subtitles').prop('checked'),
|
||||
|
@ -31,7 +31,7 @@ $(document).ready(function(){
|
|||
$(this).attr('disabled', true);
|
||||
});
|
||||
|
||||
$('#statusSelect, #qualityPreset, #anyQualities, #bestQualities, #wanted-begin, #wanted-latest,'
|
||||
$('#statusSelect, #qualityPreset, #anyQualities, #bestQualities, #wanted_begin, #wanted_latest,'
|
||||
+ ' #flatten_folders, #scene, #subtitles, #anime').change(function() {
|
||||
$('#saveDefaultsButton').attr('disabled', false);
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ import traceback
|
|||
|
||||
import sickbeard
|
||||
|
||||
from sickbeard.common import SKIPPED, WANTED
|
||||
from sickbeard.common import SKIPPED, WANTED, UNAIRED
|
||||
from sickbeard.tv import TVShow
|
||||
from sickbeard import exceptions, logger, ui, db
|
||||
from sickbeard import generic_queue
|
||||
|
@ -133,10 +133,10 @@ class ShowQueue(generic_queue.GenericQueue):
|
|||
|
||||
def addShow(self, indexer, indexer_id, showDir, default_status=None, quality=None, flatten_folders=None,
|
||||
lang="en", subtitles=None, anime=None, scene=None, paused=None, blacklist=None, whitelist=None,
|
||||
default_wanted_begin=None, default_wanted_latest=None):
|
||||
wanted_begin=None, wanted_latest=None):
|
||||
queueItemObj = QueueItemAdd(indexer, indexer_id, showDir, default_status, quality, flatten_folders, lang,
|
||||
subtitles, anime, scene, paused, blacklist, whitelist,
|
||||
default_wanted_begin, default_wanted_latest)
|
||||
wanted_begin, wanted_latest)
|
||||
|
||||
self.add_item(queueItemObj)
|
||||
|
||||
|
@ -370,33 +370,47 @@ class QueueItemAdd(ShowQueueItem):
|
|||
logger.log(traceback.format_exc(), logger.DEBUG)
|
||||
|
||||
# if they gave a custom status then change all the eps to it
|
||||
my_db = db.DBConnection()
|
||||
if self.default_status != SKIPPED:
|
||||
logger.log(u"Setting all episodes to the specified default status: " + str(self.default_status))
|
||||
myDB = db.DBConnection()
|
||||
myDB.action("UPDATE tv_episodes SET status = ? WHERE status = ? AND showid = ? AND season != 0",
|
||||
my_db.action("UPDATE tv_episodes SET status = ? WHERE status = ? AND showid = ? AND season != 0",
|
||||
[self.default_status, SKIPPED, self.show.indexerid])
|
||||
|
||||
# if they gave a number to start or number to end as wanted, then change those eps to it
|
||||
def get_wanted_sql(wanted_max, sql_vars):
|
||||
def get_wanted(db_obj, wanted_max, latest):
|
||||
actual = 0
|
||||
if wanted_max:
|
||||
my_db = db.DBConnection()
|
||||
sql = "UPDATE `tv_episodes` SET status=%s" % WANTED\
|
||||
+ " WHERE indexerid IN "\
|
||||
+ "(SELECT t1.indexerid FROM `tv_episodes` t1 JOIN "\
|
||||
+ "(SELECT %s(season),showid,season FROM `tv_episodes` WHERE '%s'=showid" % (sql_vars[0], self.show.indexerid)\
|
||||
+ " AND '0'<season ORDER BY season,episode) AS t2 ON t2.showid=t1.showid AND t2.season = t1.season"\
|
||||
+ " ORDER BY episode %s%s)" % (sql_vars[1], (' LIMIT %s' % wanted_max, '')[-1 == wanted_max])\
|
||||
+ ' AND status NOT IN (%s)' % ','.join([str(x) for x in sickbeard.common.Quality.DOWNLOADED + [sickbeard.common.UNAIRED]])
|
||||
my_db.action(sql)
|
||||
result = my_db.select("SELECT changes() as last FROM `tv_episodes`")
|
||||
select_id = 'FROM [tv_episodes] t5 JOIN (SELECT t3.indexerid, t3.status, t3.season*1000000+t3.episode AS t3_se, t2.start_season FROM [tv_episodes] t3'\
|
||||
+ ' JOIN (SELECT t1.showid, M%s(t1.season) AS start_season' % ('IN', 'AX')[latest]\
|
||||
+ ', MAX(t1.airdate) AS airdate, t1.episode, t1.season*1000000+t1.episode AS se FROM [tv_episodes] t1'\
|
||||
+ ' WHERE %s=t1.showid' % self.show.indexerid\
|
||||
+ ' AND 0<t1.season AND t1.status NOT IN (%s)) AS t2' % UNAIRED\
|
||||
+ ' ON t2.showid=t3.showid AND 0<t3.season AND t2.se>=t3_se ORDER BY t3_se %sSC' % ('A', 'DE')[latest]\
|
||||
+ ' %s) as t4' % (' LIMIT %s' % wanted_max, '')[-1 == wanted_max]\
|
||||
+ ' ON t4.indexerid=t5.indexerid'\
|
||||
+ '%s' % ('', ' AND t4.start_season=t5.season')[-1 == wanted_max]\
|
||||
+ ' AND t4.status NOT IN (%s)' % ','.join([str(x) for x in sickbeard.common.Quality.DOWNLOADED + [WANTED]])
|
||||
select = 'SELECT t5.indexerid as indexerid, t5.season as season, t5.episode as episode, t5.status as status ' + select_id
|
||||
update = 'UPDATE [tv_episodes] SET status=%s WHERE indexerid IN (SELECT t5.indexerid %s)' % (WANTED, select_id)
|
||||
|
||||
wanted_updates = db_obj.select(select)
|
||||
db_obj.action(update)
|
||||
result = db_obj.select("SELECT changes() as last FROM [tv_episodes]")
|
||||
for cur_result in result:
|
||||
actual = cur_result['last']
|
||||
break
|
||||
|
||||
action_log = 'didn\'t find any episodes that need to be set wanted'
|
||||
if actual:
|
||||
action_log = ('updated %s %s episodes > %s'
|
||||
% ((((('%s of %s' % (actual, wanted_max)), ('%s of max %s limited' % (actual, wanted_max)))[10 == wanted_max]), ('max %s available' % actual))[-1 == wanted_max],
|
||||
('first season', 'latest')[latest],
|
||||
','.join([('S%02dE%02d=%d' % (a['season'], a['episode'], a['status'])) for a in wanted_updates])))
|
||||
logger.log('Get wanted ' + action_log)
|
||||
return actual
|
||||
|
||||
items_wanted = get_wanted_sql(self.default_wanted_begin, ['MIN', 'ASC'])
|
||||
items_wanted += get_wanted_sql(self.default_wanted_latest, ['MAX', 'DESC'])
|
||||
items_wanted = get_wanted(my_db, self.default_wanted_begin, latest=False)
|
||||
items_wanted += get_wanted(my_db, self.default_wanted_latest, latest=True)
|
||||
|
||||
msg = ' the specified show into ' + self.showDir
|
||||
# if started with WANTED eps then run the backlog
|
||||
|
|
|
@ -2254,7 +2254,7 @@ class NewHomeAddShows(Home):
|
|||
def addNewShow(self, whichSeries=None, indexerLang='en', rootDir=None, defaultStatus=None,
|
||||
anyQualities=None, bestQualities=None, flatten_folders=None, subtitles=None,
|
||||
fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None,
|
||||
scene=None, blacklist=None, whitelist=None, default_wanted_begin=None, default_wanted_latest=None):
|
||||
scene=None, blacklist=None, whitelist=None, wanted_begin=None, wanted_latest=None):
|
||||
"""
|
||||
Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are
|
||||
provided then it forwards back to newShow, if not it goes to /home.
|
||||
|
@ -2353,14 +2353,14 @@ class NewHomeAddShows(Home):
|
|||
bestQualities = [bestQualities]
|
||||
newQuality = Quality.combineQualities(map(int, anyQualities), map(int, bestQualities))
|
||||
|
||||
default_wanted_begin = config.minimax(default_wanted_begin, 0, -1, 10)
|
||||
default_wanted_latest = config.minimax(default_wanted_latest, 0, -1, 10)
|
||||
wanted_begin = config.minimax(wanted_begin, 0, -1, 10)
|
||||
wanted_latest = config.minimax(wanted_latest, 0, -1, 10)
|
||||
|
||||
# add the show
|
||||
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), newQuality,
|
||||
flatten_folders, indexerLang, subtitles, anime,
|
||||
scene, None, blacklist, whitelist,
|
||||
default_wanted_begin, default_wanted_latest) # @UndefinedVariable
|
||||
wanted_begin, wanted_latest) # @UndefinedVariable
|
||||
# ui.notifications.message('Show added', 'Adding the specified show into ' + show_dir)
|
||||
|
||||
return finishAddShow()
|
||||
|
@ -2428,8 +2428,6 @@ class NewHomeAddShows(Home):
|
|||
# add the show
|
||||
sickbeard.showQueueScheduler.action.addShow(indexer, indexer_id, show_dir,
|
||||
default_status=sickbeard.STATUS_DEFAULT,
|
||||
default_wanted_begin=sickbeard.WANTED_BEGIN_DEFAULT,
|
||||
default_wanted_latest=sickbeard.WANTED_LATEST_DEFAULT,
|
||||
quality=sickbeard.QUALITY_DEFAULT,
|
||||
flatten_folders=sickbeard.FLATTEN_FOLDERS_DEFAULT,
|
||||
subtitles=sickbeard.SUBTITLES_DEFAULT,
|
||||
|
|
Loading…
Reference in a new issue