Cache issue fixes.

Naming Pattern issues fixed.
Regex patterns cleaned up.
Misc bug fixes.
This commit is contained in:
echel0n 2014-04-29 07:44:13 -07:00
parent 87b752b4e5
commit dbe7e019f6
5 changed files with 85 additions and 113 deletions

View file

@ -118,4 +118,5 @@ class ConvertIndexerToInteger(ConvertSceneNamesToIndexerID):
class RemoveKeysFromXemNumbering(ConvertIndexerToInteger):
def execute(self):
self.connection.action("ALTER TABLE xem_numbering DROP UNIQUE (indexer, indexer_id, season, episode)")
self.connection.action("ALTER TABLE xem_numbering DROP PRIMARY KEY")
self.connection.action("ALTER TABLE xem_numbering DROP PRIMARY KEY")

View file

@ -190,49 +190,12 @@ sports_regexs = [
('sports_event',
# Show.Name.123.Event.Nov.23rd.2010.Source.Quality.Etc-Group
'''
^(?P<series_name>.*?)\W
(?P<parts>\d{1,3})\W
(?P<event>.*?)\W
(?P<air_day>\d{1,2})(\w{2})\W
^((?P<series_name>.+?)[. _-]+)?
((?P<air_day>\d{1,2})+)[. _-]+
(?P<air_month>\w{3,})\W
(?P<air_year>\d{4})\W
(?P<extra_info>.*?)\W
(?P<release_group>.*?)$
'''),
('sports_event_without_parts',
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
'''
^(?P<series_name>.*?)\W
(?P<event>.*?)\W
(?P<air_day>\d{1,2})(\w{2})\W
(?P<air_month>\w{3,})\W
(?P<air_year>\d{4})\W
(?P<extra_info>.*?)\W
(?P<release_group>.*?)$
'''),
('sports_parts_without_event',
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
'''
^(?P<series_name>.*?)\W
(?P<parts>\d{1,3})\W
(?P<air_day>\d{1,2})(\w{2})\W
(?P<air_month>\w{3,})\W
(?P<air_year>\d{4})\W
(?P<extra_info>.*?)\W
(?P<release_group>.*?)$
'''),
('sports_date_only',
# Show.Name.Event.Nov.23rd.2010.Source.Quality.Etc-Group
'''
^(?P<series_name>.*?)\W
(?P<air_day>\d{1,2})(\w{2})\W
(?P<air_month>\w{3,})\W
(?P<air_year>\d{4})\W
(?P<extra_info>.*?)\W
(?P<release_group>.*?)$
(?P<air_year>\d{4})
[. _-]*((?P<extra_info>.+?)
((?<![. _-])(?<!WEB)
-(?P<release_group>[^- ]+))?)?$
'''),
]

View file

@ -137,7 +137,7 @@ def validate_name(pattern, multi=None, file_only=False, abd=False, sports=False)
regexMode = 0
if sports:
regexMode = 1
regexMode = 2
parser = NameParser(True, regexMode)

View file

@ -1910,74 +1910,70 @@ class TVEpisode(object):
else:
show_name = self.show.name
normal = {
'%SN': show_name,
'%S.N': dot(show_name),
'%S_N': us(show_name),
'%EN': ep_name,
'%E.N': dot(ep_name),
'%E_N': us(ep_name),
'%QN': Quality.qualityStrings[epQual],
'%Q.N': dot(Quality.qualityStrings[epQual]),
'%Q_N': us(Quality.qualityStrings[epQual]),
'%S': str(self.season),
'%0S': '%02d' % self.season,
'%E': str(self.episode),
'%0E': '%02d' % self.episode,
'%XMS': str(self.scene_season),
'%0XMS': '%02d' % self.scene_season,
'%XME': str(self.scene_episode),
'%0XME': '%02d' % self.scene_episode,
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': self.airdate.strftime('%d %b %Y') if self.show.sports else str(self.airdate).replace('-', ' '),
'%A.D': self.airdate.strftime('%d.%b.%Y') if self.show.sports else str(self.airdate).replace('-', '.'),
'%A_D': us(self.airdate.strftime('%d-%b-%Y')) if self.show.sports else us(str(self.airdate)),
'%A-D': self.airdate.strftime('%d-%b-%Y') if self.show.sports else str(self.airdate),
'%Y': str(self.airdate.year),
'%M': self.airdate.strftime('%b') if self.show.sports else str(self.airdate.month),
'%D': str(self.airdate.day),
'%0M': '%02d' % self.airdate.month,
'%0D': '%02d' % self.airdate.day,
'%RT': "PROPER" if self.is_proper else "",
}
sports = {
'%SN': show_name,
'%S.N': dot(show_name),
'%S_N': us(show_name),
'%EN': ep_name,
'%E.N': dot(ep_name),
'%E_N': us(ep_name),
'%QN': Quality.qualityStrings[epQual],
'%Q.N': dot(Quality.qualityStrings[epQual]),
'%Q_N': us(Quality.qualityStrings[epQual]),
'%S': str(self.season),
'%0S': '%02d' % self.season,
'%E': str(self.episode),
'%0E': '%02d' % self.episode,
'%XMS': str(self.scene_season),
'%0XMS': '%02d' % self.scene_season,
'%XME': str(self.scene_episode),
'%0XME': '%02d' % self.scene_episode,
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': self.airdate.strftime('%d %b %Y'),
'%A.D': self.airdate.strftime('%d.%b.%Y'),
'%A_D': us(self.airdate.strftime('%d-%b-%Y')),
'%A-D': self.airdate.strftime('%d-%b-%Y'),
'%Y': str(self.airdate.year),
'%M': self.airdate.strftime('%b'),
'%D': str(self.airdate.day),
'%0M': '%02d' % self.airdate.month,
'%0D': '%02d' % self.airdate.day,
'%RT': "PROPER" if self.is_proper else "",
}
if self.show.sports:
return sports
return normal
return {
'%SN': show_name,
'%S.N': dot(show_name),
'%S_N': us(show_name),
'%EN': ep_name,
'%E.N': dot(ep_name),
'%E_N': us(ep_name),
'%QN': Quality.qualityStrings[epQual],
'%Q.N': dot(Quality.qualityStrings[epQual]),
'%Q_N': us(Quality.qualityStrings[epQual]),
'%S': str(self.season),
'%0S': '%02d' % self.season,
'%E': str(self.episode),
'%0E': '%02d' % self.episode,
'%XMS': str(self.scene_season),
'%0XMS': '%02d' % self.scene_season,
'%XME': str(self.scene_episode),
'%0XME': '%02d' % self.scene_episode,
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': self.airdate.strftime('%d %b %Y'),
'%A.D': self.airdate.strftime('%d.%b.%Y'),
'%A_D': us(self.airdate.strftime('%d-%b-%Y')),
'%A-D': self.airdate.strftime('%d-%b-%Y'),
'%Y': str(self.airdate.year),
'%M': self.airdate.strftime('%b'),
'%D': str(self.airdate.day),
'%0M': '%02d' % self.airdate.month,
'%0D': '%02d' % self.airdate.day,
'%RT': "PROPER" if self.is_proper else "",
}
else:
return {
'%SN': show_name,
'%S.N': dot(show_name),
'%S_N': us(show_name),
'%EN': ep_name,
'%E.N': dot(ep_name),
'%E_N': us(ep_name),
'%QN': Quality.qualityStrings[epQual],
'%Q.N': dot(Quality.qualityStrings[epQual]),
'%Q_N': us(Quality.qualityStrings[epQual]),
'%S': str(self.season),
'%0S': '%02d' % self.season,
'%E': str(self.episode),
'%0E': '%02d' % self.episode,
'%XMS': str(self.scene_season),
'%0XMS': '%02d' % self.scene_season,
'%XME': str(self.scene_episode),
'%0XME': '%02d' % self.scene_episode,
'%RN': release_name(self.release_name),
'%RG': release_group(self.release_name),
'%AD': str(self.airdate).replace('-', ' '),
'%A.D': str(self.airdate).replace('-', '.'),
'%A_D': us(str(self.airdate)),
'%A-D': str(self.airdate),
'%Y': str(self.airdate.year),
'%M': str(self.airdate.month),
'%D': str(self.airdate.day),
'%0M': '%02d' % self.airdate.month,
'%0D': '%02d' % self.airdate.day,
'%RT': "PROPER" if self.is_proper else "",
}
def _format_string(self, pattern, replace_map):
"""

View file

@ -56,6 +56,18 @@ class CacheDBConnection(db.DBConnection):
if str(e) != "table lastUpdate already exists":
raise
# Delete any entries missing a Indexer ID
try:
sqlResults = self.connection.execute(
"SELECT * FROM [" + providerName + "] WHERE indexerid is NULL or 0")
for cur_orphan in sqlResults:
logger.log(u"Missing IndexerID detected! name: " + str(cur_orphan["name"]), logger.DEBUG)
logger.log(u"Deleting orphaned cache entry with name: " + str(cur_orphan["name"]))
self.connection.action("DELETE FROM [" + providerName + "] WHERE name = ?", [cur_orphan["name"]])
except sqlite3.OperationalError, e:
if str(e) != "table [" + providerName + "] cleanup failed":
raise
class TVCache():
def __init__(self, provider):
@ -232,7 +244,7 @@ class TVCache():
break
# if we didn't find a Indexer ID return None
if not indexer_id:
if indexer_id is None:
return None
# if the show isn't in out database then return None