1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 19:42:20 -05:00

Added thread locking for queues.

Fixed imdbinfo issues.
This commit is contained in:
echel0n 2014-06-07 11:36:26 -07:00
parent cfcc35ebcc
commit 2c0f3a3dc3
3 changed files with 67 additions and 49 deletions

View File

@ -61,7 +61,7 @@ class GenericQueue(object):
# only start a new task if one isn't already going # only start a new task if one isn't already going
if self.thread == None or self.thread.isAlive() == False: 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 the thread is dead then the current item should be finished
if self.currentItem != None: if self.currentItem != None:
self.currentItem.finish() self.currentItem.finish()
@ -85,7 +85,6 @@ class GenericQueue(object):
else: else:
return y.priority-x.priority return y.priority-x.priority
with self.lock:
self.queue.sort(cmp=sorter) self.queue.sort(cmp=sorter)
queueItem = self.queue[0] queueItem = self.queue[0]

View File

@ -892,11 +892,21 @@ class TVShow(object):
imdb_info[key] = imdbTv.get(key.replace('_', ' ')) imdb_info[key] = imdbTv.get(key.replace('_', ' '))
# Filter only the value # Filter only the value
imdb_info['runtimes'] = re.search('\d+', imdb_info['runtimes']).group(0) or self.runtime if imdb_info['runtimes']:
imdb_info['akas'] = '|'.join(imdb_info['akas']) or '' 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 # 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 # Get only the production country certificate if any
if imdb_info['certificates'] and imdb_info['countries']: if imdb_info['certificates'] and imdb_info['countries']:
@ -912,7 +922,11 @@ class TVShow(object):
else: else:
imdb_info['certificates'] = '' 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() imdb_info['last_update'] = datetime.date.today().toordinal()
# Rename dict keys without spaces for DB upsert # Rename dict keys without spaces for DB upsert
@ -1499,14 +1513,20 @@ class TVEpisode(object):
self.indexer = int(sqlResults[0]["indexer"]) self.indexer = int(sqlResults[0]["indexer"])
# does one now a better way to test for NULL in the db field ? # does one now a better way to test for NULL in the db field ?
if sqlResults[0]["scene_season"]: try:
self.scene_season = int(sqlResults[0]["scene_season"] or 0) self.scene_season = int(sqlResults[0]["scene_season"])
except:
self.scene_season = 0
if sqlResults[0]["scene_episode"]: try:
self.scene_episode = int(sqlResults[0]["scene_episode"] or 0) self.scene_episode = int(sqlResults[0]["scene_episode"])
except:
self.scene_episode = 0
if sqlResults[0]["scene_absolute_number"]: try:
self.scene_absolute_number = int(sqlResults[0]["scene_absolute_number"] or 0) self.scene_absolute_number = int(sqlResults[0]["scene_absolute_number"])
except:
self.scene_absolute_number = 0
if sqlResults[0]["release_name"] is not None: if sqlResults[0]["release_name"] is not None:
self.release_name = sqlResults[0]["release_name"] self.release_name = sqlResults[0]["release_name"]
@ -2355,8 +2375,7 @@ class TVEpisode(object):
for curEp in [self] + self.relatedEps: for curEp in [self] + self.relatedEps:
curEp.checkForMetaFiles() curEp.checkForMetaFiles()
# save any changes to the database # save any changes to the databas
sql_l = [] sql_l = []
with self.lock: with self.lock:
sql_l.append(self.get_sql()) sql_l.append(self.get_sql())