Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sql_l = []
for current_ep in episodes:
logger.log(u'{0}: {1} parsed to {2} {3}'.format
(self.indexerid, filepath, self.name, episode_num(season, current_ep)), logger.DEBUG)
check_quality_again = False
same_file = False
cur_ep = self.get_episode(season, current_ep)
if not cur_ep:
try:
cur_ep = self.get_episode(season, current_ep, filepath)
if not cur_ep:
raise EpisodeNotFoundException
except EpisodeNotFoundException:
logger.log(u'{0}: Unable to figure out what this file is, skipping {1}'.format
(self.indexerid, filepath), logger.ERROR)
continue
else:
# if there is a new file associated with this ep then re-check the quality
if not cur_ep.location or ek(os.path.normpath, cur_ep.location) != ek(os.path.normpath, filepath):
logger.log(
u'{0}: The old episode had a different file associated with it, '
u're-checking the quality using the new filename {1}'.format(self.indexerid, filepath),
logger.DEBUG)
check_quality_again = True
with cur_ep.lock:
old_size = cur_ep.file_size
cur_ep.location = filepath
try:
self.__load_from_nfo(self.location)
except NoNFOException:
logger.log(u'{id}: There was an error loading the NFO for episode {ep}'.format
(id=self.show.indexerid, ep=episode_num(season, episode)), logger.ERROR)
# if we tried loading it from NFO and didn't find the NFO, try the Indexers
if not self.hasnfo:
try:
result = self.load_from_indexer(season, episode)
except EpisodeDeletedException:
result = False
# if we failed SQL *and* NFO, Indexers then fail
if not result:
raise EpisodeNotFoundException(
u"Couldn't find episode {ep}".format(ep=episode_num(season, episode)))