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

Disabled sceneConvert renamer for now till we add it in optionally.

This commit is contained in:
echel0n 2014-04-27 04:46:21 -07:00
parent 41293b1155
commit 831e9a537e

View File

@ -297,7 +297,7 @@ class TVShow(object):
# find all media files in the show folder and create episodes for as many as possible # find all media files in the show folder and create episodes for as many as possible
def loadEpisodesFromDir(self): def loadEpisodesFromDir(self, sceneConvert=False):
if not ek.ek(os.path.isdir, self._location): if not ek.ek(os.path.isdir, self._location):
logger.log(str(self.indexerid) + u": Show dir doesn't exist, not loading episodes from disk") logger.log(str(self.indexerid) + u": Show dir doesn't exist, not loading episodes from disk")
@ -310,49 +310,47 @@ class TVShow(object):
# create TVEpisodes from each media file (if possible) # create TVEpisodes from each media file (if possible)
for mediaFile in mediaFiles: for mediaFile in mediaFiles:
sceneConvert = False
parse_result = None parse_result = None
curEpisode = None curEpisode = None
i = 0
try: if sceneConvert:
while i < 2: try:
i+=1 i = 0
while i < 2:
i+=1
np = NameParser(False)
parse_result = np.parse(mediaFile, True if i > 1 else False)
if helpers.validateShow(self, parse_result.season_number, parse_result.episode_numbers[0]):
ep = TVEpisode(self, parse_result.season_number, parse_result.episode_numbers[0])
proper_path = ep.proper_path()
proper_absolute_path = ek.ek(os.path.join, self._location, proper_path)
src_path = ek.ek(os.path.dirname, mediaFile)
dest_path = ek.ek(os.path.dirname, proper_absolute_path)
orig_extension = mediaFile.rpartition('.')[-1]
new_base_name = ek.ek(os.path.basename, proper_path)
np = NameParser(False) new_file_name = new_base_name + '.' + orig_extension
parse_result = np.parse(mediaFile, sceneConvert) old_file_name = ek.ek(os.path.basename, mediaFile)
if helpers.validateShow(self, parse_result.season_number, parse_result.episode_numbers[0]): new_mediaFile = os.path.join(dest_path, new_file_name)
ep = TVEpisode(self, parse_result.season_number, parse_result.episode_numbers[0]) if old_file_name == new_file_name or os.path.exists(new_mediaFile):break
proper_path = ep.proper_path()
proper_absolute_path = ek.ek(os.path.join, self._location, proper_path)
src_path = ek.ek(os.path.dirname, mediaFile)
dest_path = ek.ek(os.path.dirname, proper_absolute_path)
orig_extension = mediaFile.rpartition('.')[-1]
new_base_name = ek.ek(os.path.basename, proper_path)
new_file_name = new_base_name + '.' + orig_extension if os.path.exists(os.path.join(src_path, old_file_name)):
old_file_name = ek.ek(os.path.basename, mediaFile) old_mediaFile = os.path.join(src_path, old_file_name)
new_mediaFile = os.path.join(dest_path, new_file_name) elif os.path.exists(os.path.join(dest_path, old_file_name)):
if old_file_name == new_file_name or os.path.exists(new_mediaFile):break old_mediaFile = os.path.join(dest_path, old_file_name)
else:break
if os.path.exists(os.path.join(src_path, old_file_name)): logger.log(u"Scene Converting file %s to %s" % (old_file_name, new_file_name), logger.MESSAGE)
old_mediaFile = os.path.join(src_path, old_file_name) if not os.path.exists(dest_path):
elif os.path.exists(os.path.join(dest_path, old_file_name)): shutil.move(src_path, dest_path)
old_mediaFile = os.path.join(dest_path, old_file_name) shutil.move(old_mediaFile, new_mediaFile)
else:break mediaFile = new_mediaFile
logger.log(u"Scene Converting file %s to %s" % (old_file_name, new_file_name), logger.MESSAGE) # converted
if not os.path.exists(dest_path): break
shutil.move(src_path, dest_path)
shutil.move(old_mediaFile, new_mediaFile)
mediaFile = new_mediaFile
# converted except Exception:
break continue
sceneConvert = True
except Exception:
continue
logger.log(str(self.indexerid) + u": Creating episode from " + mediaFile, logger.DEBUG) logger.log(str(self.indexerid) + u": Creating episode from " + mediaFile, logger.DEBUG)
try: try:
@ -371,6 +369,7 @@ class TVShow(object):
ep_file_name = ek.ek(os.path.splitext, ep_file_name)[0] ep_file_name = ek.ek(os.path.splitext, ep_file_name)[0]
try: try:
parse_result = None
np = NameParser(False) np = NameParser(False)
parse_result = np.parse(ep_file_name) parse_result = np.parse(ep_file_name)
except InvalidNameException: except InvalidNameException: