diff --git a/sickbeard/generic_queue.py b/sickbeard/generic_queue.py
index 8be859cf..c6c437da 100644
--- a/sickbeard/generic_queue.py
+++ b/sickbeard/generic_queue.py
@@ -61,48 +61,47 @@ class GenericQueue(object):
# only start a new task if one isn't already going
if self.thread == None or self.thread.isAlive() == False:
+ with self.lock:
+ # if the thread is dead then the current item should be finished
+ if self.currentItem != None:
+ self.currentItem.finish()
+ self.currentItem = None
- # if the thread is dead then the current item should be finished
- if self.currentItem != None:
- self.currentItem.finish()
- self.currentItem = None
+ # if there's something in the queue then run it in a thread and take it out of the queue
+ if len(self.queue) > 0:
- # if there's something in the queue then run it in a thread and take it out of the queue
- if len(self.queue) > 0:
+ # sort by priority
+ def sorter(x,y):
+ """
+ Sorts by priority descending then time ascending
+ """
+ if x.priority == y.priority:
+ if y.added == x.added:
+ return 0
+ elif y.added < x.added:
+ return 1
+ elif y.added > x.added:
+ return -1
+ else:
+ return y.priority-x.priority
- # sort by priority
- def sorter(x,y):
- """
- Sorts by priority descending then time ascending
- """
- if x.priority == y.priority:
- if y.added == x.added:
- return 0
- elif y.added < x.added:
- return 1
- elif y.added > x.added:
- return -1
- else:
- return y.priority-x.priority
-
- with self.lock:
self.queue.sort(cmp=sorter)
-
- queueItem = self.queue[0]
- if queueItem.priority < self.min_priority:
- return
+ queueItem = self.queue[0]
- # launch the queue item in a thread
- # TODO: improve thread name
- threadName = self.queue_name + '-' + queueItem.get_thread_name()
- self.thread = threading.Thread(None, queueItem.execute, threadName)
- self.thread.start()
+ if queueItem.priority < self.min_priority:
+ return
- self.currentItem = queueItem
+ # launch the queue item in a thread
+ # TODO: improve thread name
+ threadName = self.queue_name + '-' + queueItem.get_thread_name()
+ self.thread = threading.Thread(None, queueItem.execute, threadName)
+ self.thread.start()
- # take it out of the queue
- del self.queue[0]
+ self.currentItem = queueItem
+
+ # take it out of the queue
+ del self.queue[0]
class QueueItem:
def __init__(self, name, action_id = 0):
diff --git a/sickbeard/tv.py b/sickbeard/tv.py
index 1de61c67..d83bd894 100644
--- a/sickbeard/tv.py
+++ b/sickbeard/tv.py
@@ -892,11 +892,21 @@ class TVShow(object):
imdb_info[key] = imdbTv.get(key.replace('_', ' '))
# Filter only the value
- imdb_info['runtimes'] = re.search('\d+', imdb_info['runtimes']).group(0) or self.runtime
- imdb_info['akas'] = '|'.join(imdb_info['akas']) or ''
+ if imdb_info['runtimes']:
+ imdb_info['runtimes'] = re.search('\d+', imdb_info['runtimes']).group(0)
+ else:
+ imdb_info['runtimes'] = self.runtime
+
+ if imdb_info['akas']:
+ imdb_info['akas'] = '|'.join(imdb_info['akas'])
+ else:
+ imdb_info['akas'] = ''
# Join all genres in a string
- imdb_info['genres'] = '|'.join(imdb_info['genres']) or ''
+ if imdb_info['genres']:
+ imdb_info['genres'] = '|'.join(imdb_info['genres'])
+ else:
+ imdb_info['genres'] = ''
# Get only the production country certificate if any
if imdb_info['certificates'] and imdb_info['countries']:
@@ -912,7 +922,11 @@ class TVShow(object):
else:
imdb_info['certificates'] = ''
- imdb_info['country_codes'] = '|'.join(imdb_info['country_codes']) or ''
+ if imdb_info['country_codes']:
+ imdb_info['country_codes'] = '|'.join(imdb_info['country_codes'])
+ else:
+ imdb_info['country_codes'] = ''
+
imdb_info['last_update'] = datetime.date.today().toordinal()
# Rename dict keys without spaces for DB upsert
@@ -1499,14 +1513,20 @@ class TVEpisode(object):
self.indexer = int(sqlResults[0]["indexer"])
# does one now a better way to test for NULL in the db field ?
- if sqlResults[0]["scene_season"]:
- self.scene_season = int(sqlResults[0]["scene_season"] or 0)
+ try:
+ self.scene_season = int(sqlResults[0]["scene_season"])
+ except:
+ self.scene_season = 0
- if sqlResults[0]["scene_episode"]:
- self.scene_episode = int(sqlResults[0]["scene_episode"] or 0)
+ try:
+ self.scene_episode = int(sqlResults[0]["scene_episode"])
+ except:
+ self.scene_episode = 0
- if sqlResults[0]["scene_absolute_number"]:
- self.scene_absolute_number = int(sqlResults[0]["scene_absolute_number"] or 0)
+ try:
+ self.scene_absolute_number = int(sqlResults[0]["scene_absolute_number"])
+ except:
+ self.scene_absolute_number = 0
if sqlResults[0]["release_name"] is not None:
self.release_name = sqlResults[0]["release_name"]
@@ -2355,8 +2375,7 @@ class TVEpisode(object):
for curEp in [self] + self.relatedEps:
curEp.checkForMetaFiles()
- # save any changes to the database
-
+ # save any changes to the databas
sql_l = []
with self.lock:
sql_l.append(self.get_sql())
diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py
index 65794393..53b1e395 100644
--- a/sickbeard/webserve.py
+++ b/sickbeard/webserve.py
@@ -3577,9 +3577,9 @@ class Home:
# mass add to database
sql_l.append(epObj.get_sql())
- if sql_l:
- myDB = db.DBConnection()
- myDB.mass_action(sql_l)
+ if sql_l:
+ myDB = db.DBConnection()
+ myDB.mass_action(sql_l)
if int(status) == WANTED:
msg = "Backlog was automatically started for the following seasons of " + showObj.name + ":
"