Extra is type "mdf" including movie_extra support
This commit is contained in:
@@ -3,12 +3,12 @@ from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent, fireEvent, fireEventAsync
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.helpers.request import jsonified
|
||||
from couchpotato.core.helpers.variable import getExt
|
||||
from couchpotato.core.helpers.variable import getExt, mergeDicts
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.core.settings.model import Library
|
||||
from couchpotato.environment import Env
|
||||
import os.path
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import traceback
|
||||
@@ -190,19 +190,30 @@ class Renamer(Plugin):
|
||||
|
||||
# Check for extra subtitle files
|
||||
if file_type is 'subtitle':
|
||||
|
||||
def test(s):
|
||||
return current_file[:-len(replacements['ext'])] in s
|
||||
|
||||
for subtitle_extra in set(filter(test, group['files']['subtitle_extra'])):
|
||||
replacements['ext'] = getExt(subtitle_extra)
|
||||
|
||||
final_folder_name = self.doReplace(folder_name, replacements)
|
||||
final_file_name = self.doReplace(file_name, replacements)
|
||||
rename_files[subtitle_extra] = os.path.join(destination, final_folder_name, final_file_name)
|
||||
rename_extras = self.getRenameExtras(
|
||||
extra_type = 'subtitle_extra',
|
||||
replacements = replacements,
|
||||
folder_name = folder_name,
|
||||
file_name = file_name,
|
||||
destination = destination,
|
||||
group = group,
|
||||
current_file = current_file
|
||||
)
|
||||
rename_files = mergeDicts(rename_files, rename_extras)
|
||||
|
||||
# Filename without cd etc
|
||||
if file_type is 'movie':
|
||||
rename_extras = self.getRenameExtras(
|
||||
extra_type = 'movie_extra',
|
||||
replacements = replacements,
|
||||
folder_name = folder_name,
|
||||
file_name = file_name,
|
||||
destination = destination,
|
||||
group = group,
|
||||
current_file = current_file
|
||||
)
|
||||
rename_files = mergeDicts(rename_files, rename_extras)
|
||||
|
||||
group['destination_dir'] = os.path.join(destination, final_folder_name)
|
||||
|
||||
if multiple:
|
||||
@@ -309,6 +320,22 @@ class Renamer(Plugin):
|
||||
|
||||
self.renaming_started = False
|
||||
|
||||
def getRenameExtras(self, extra_type = '', replacements = {}, folder_name = '', file_name = '', destination = '', group = {}, current_file = ''):
|
||||
|
||||
rename_files = {}
|
||||
|
||||
def test(s):
|
||||
return current_file[:-len(replacements['ext'])] in s
|
||||
|
||||
for extra in set(filter(test, group['files'][extra_type])):
|
||||
replacements['ext'] = getExt(extra)
|
||||
|
||||
final_folder_name = self.doReplace(folder_name, replacements)
|
||||
final_file_name = self.doReplace(file_name, replacements)
|
||||
rename_files[extra] = os.path.join(destination, final_folder_name, final_file_name)
|
||||
|
||||
return rename_files
|
||||
|
||||
def moveFile(self, old, dest):
|
||||
try:
|
||||
shutil.move(old, dest)
|
||||
|
||||
@@ -29,7 +29,8 @@ class Scanner(Plugin):
|
||||
ignored_in_path = ['_unpack', '_failed_', '_unknown_', '_exists_', '.appledouble', '.appledb', '.appledesktop', os.path.sep + '._', '.ds_store', 'cp.cpnfo'] #unpacking, smb-crap, hidden files
|
||||
ignore_names = ['extract', 'extracting', 'extracted', 'movie', 'movies', 'film', 'films', 'download', 'downloads', 'video_ts', 'audio_ts', 'bdmv', 'certificate']
|
||||
extensions = {
|
||||
'movie': ['mkv', 'wmv', 'avi', 'mpg', 'mpeg', 'mp4', 'm2ts', 'iso', 'img'],
|
||||
'movie': ['mkv', 'wmv', 'avi', 'mpg', 'mpeg', 'mp4', 'm2ts', 'iso', 'img', 'mdf'],
|
||||
'movie_extra': ['mds'],
|
||||
'dvd': ['vts_*', 'vob'],
|
||||
'nfo': ['nfo', 'txt', 'tag'],
|
||||
'subtitle': ['sub', 'srt', 'ssa', 'ass'],
|
||||
@@ -42,6 +43,7 @@ class Scanner(Plugin):
|
||||
'trailer': ('video', 'trailer'),
|
||||
'nfo': ('nfo', 'nfo'),
|
||||
'movie': ('video', 'movie'),
|
||||
'movie': ('movie', 'movie_extra'),
|
||||
'backdrop': ('image', 'backdrop'),
|
||||
'leftover': ('leftover', 'leftover'),
|
||||
}
|
||||
@@ -267,6 +269,7 @@ class Scanner(Plugin):
|
||||
# Group extra (and easy) files first
|
||||
# images = self.getImages(group['unsorted_files'])
|
||||
group['files'] = {
|
||||
'movie_extra': self.getMovieExtras(group['unsorted_files']),
|
||||
'subtitle': self.getSubtitles(group['unsorted_files']),
|
||||
'subtitle_extra': self.getSubtitlesExtras(group['unsorted_files']),
|
||||
'nfo': self.getNfo(group['unsorted_files']),
|
||||
@@ -470,6 +473,9 @@ class Scanner(Plugin):
|
||||
|
||||
return set(filter(test, files))
|
||||
|
||||
def getMovieExtras(self, files):
|
||||
return set(filter(lambda s: getExt(s.lower()) in self.extensions['movie_extra'], files))
|
||||
|
||||
def getDVDFiles(self, files):
|
||||
def test(s):
|
||||
return self.isDVDFile(s)
|
||||
|
||||
Reference in New Issue
Block a user