diff --git a/CHANGES.md b/CHANGES.md
index 42bbee24..71696100 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -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)
diff --git a/gui/slick/interfaces/default/inc_addShowOptions.tmpl b/gui/slick/interfaces/default/inc_addShowOptions.tmpl
index 90e027a5..9a2e7b4c 100644
--- a/gui/slick/interfaces/default/inc_addShowOptions.tmpl
+++ b/gui/slick/interfaces/default/inc_addShowOptions.tmpl
@@ -31,15 +31,15 @@
From season 1 forward, set
- From latest going back, set
-
-
+
+
episodes as wanted (10 ... 0, and where -1 is whole latest season)
diff --git a/gui/slick/js/addShowOptions.js b/gui/slick/js/addShowOptions.js
index 6b684e8b..a11b91e0 100644
--- a/gui/slick/js/addShowOptions.js
+++ b/gui/slick/js/addShowOptions.js
@@ -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);
});
diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py
index 27bce6bd..24e40256 100644
--- a/sickbeard/show_queue.py
+++ b/sickbeard/show_queue.py
@@ -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'=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
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index d1294d6a..77ac0473 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -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,