|
|
@ -203,56 +203,15 @@ class ShiftedSeasonController():
|
|
|
|
s.close()
|
|
|
|
s.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def matchFilename(self, filename : str) -> dict:
|
|
|
|
def shiftSeason(self, showId, season, episode):
|
|
|
|
# """Returns dict {'match': <a regex match obj>, 'pattern': <ffx pattern obj>} or empty dict of no pattern was found"""
|
|
|
|
|
|
|
|
#
|
|
|
|
shiftedSeason: ShiftedSeason
|
|
|
|
# try:
|
|
|
|
for shiftedSeason in self.getShiftedSeasonSiblings(showId):
|
|
|
|
# s = self.Session()
|
|
|
|
|
|
|
|
# q = s.query(Pattern)
|
|
|
|
if (season == shiftedSeason.getOriginalSeason()
|
|
|
|
#
|
|
|
|
and (shiftedSeason.getFirstEpisode() == -1 or episode >= shiftedSeason.getFirstEpisode())
|
|
|
|
# matchResult = {}
|
|
|
|
and (shiftedSeason.getLastEpisode() == -1 or episode <= shiftedSeason.getLastEpisode())):
|
|
|
|
#
|
|
|
|
|
|
|
|
# for pattern in q.all():
|
|
|
|
return season + shiftedSeason.getSeasonOffset(), episode + shiftedSeason.getEpisodeOffset()
|
|
|
|
# patternMatch = re.search(str(pattern.pattern), str(filename))
|
|
|
|
|
|
|
|
# if patternMatch is not None:
|
|
|
|
return season, episode
|
|
|
|
# matchResult['match'] = patternMatch
|
|
|
|
|
|
|
|
# matchResult['pattern'] = pattern
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# return matchResult
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# except Exception as ex:
|
|
|
|
|
|
|
|
# raise click.ClickException(f"PatternController.matchFilename(): {repr(ex)}")
|
|
|
|
|
|
|
|
# finally:
|
|
|
|
|
|
|
|
# s.close()
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# # def getMediaDescriptor(self, context, patternId):
|
|
|
|
|
|
|
|
# #
|
|
|
|
|
|
|
|
# # try:
|
|
|
|
|
|
|
|
# # s = self.Session()
|
|
|
|
|
|
|
|
# # q = s.query(Pattern).filter(Pattern.id == int(patternId))
|
|
|
|
|
|
|
|
# #
|
|
|
|
|
|
|
|
# # if q.count():
|
|
|
|
|
|
|
|
# # return q.first().getMediaDescriptor(context)
|
|
|
|
|
|
|
|
# # else:
|
|
|
|
|
|
|
|
# # return None
|
|
|
|
|
|
|
|
# #
|
|
|
|
|
|
|
|
# # except Exception as ex:
|
|
|
|
|
|
|
|
# # raise click.ClickException(f"PatternController.getMediaDescriptor(): {repr(ex)}")
|
|
|
|
|
|
|
|
# # finally:
|
|
|
|
|
|
|
|
# # s.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shift(self, season, episode):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if season == self.original_season and episode >= self.first_episode and episode <= self.last_episode:
|
|
|
|
|
|
|
|
return season + self.season_offset, episode + self.episode_offset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return season, episode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unshift(self, season, episode):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if season == self.original_season and episode >= self.first_episode and episode <= self.last_episode:
|
|
|
|
|
|
|
|
return season + self.season_offset, episode + self.episode_offset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return season, episode
|
|
|
|
|
|
|
|