Skip to content

Simple filenames #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/interfaces/default/config_postProcessing.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@
</label>
</div>

<div class="field-pair">
<input type="checkbox" name="use_ascii_filenames" id="use_ascii_filenames" #if $sickbeard.USE_ASCII_FILENAMES == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="use_ascii_filenames">
<span class="component-title">Use simple filenames</span>
<span class="component-desc">Replace unicode characters with their ASCII equivalent from episodes filename.</span>
</label>
</div>

<div class="field-pair">
<input type="checkbox" name="process_automatically" id="process_automatically" #if $sickbeard.PROCESS_AUTOMATICALLY == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="process_automatically">
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Cheetah>=2.1.0
Unidecode>=0.04.18
5 changes: 4 additions & 1 deletion sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
ADD_SHOWS_WO_DIR = None
CREATE_MISSING_SHOW_DIRS = None
RENAME_EPISODES = False
USE_ASCII_FILENAMES = False
PROCESS_AUTOMATICALLY = False
KEEP_PROCESSED_DIR = False
MOVE_ASSOCIATED_FILES = False
Expand Down Expand Up @@ -372,7 +373,7 @@ def initialize(consoleLogging=True):
KEEP_PROCESSED_DIR, TV_DOWNLOAD_DIR, TVDB_BASE_URL, MIN_SEARCH_FREQUENCY, \
showQueueScheduler, searchQueueScheduler, ROOT_DIRS, CACHE_DIR, ACTUAL_CACHE_DIR, TVDB_API_PARMS, \
NAMING_PATTERN, NAMING_MULTI_EP, NAMING_FORCE_FOLDERS, NAMING_ABD_PATTERN, NAMING_CUSTOM_ABD, \
RENAME_EPISODES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \
RENAME_EPISODES, USE_ASCII_FILENAMES, properFinderScheduler, PROVIDER_ORDER, autoPostProcesserScheduler, \
WOMBLE, OMGWTFNZBS, OMGWTFNZBS_USERNAME, OMGWTFNZBS_APIKEY, providerList, newznabProviderList, \
EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, \
USE_BOXCAR2, BOXCAR2_ACCESS_TOKEN, BOXCAR2_NOTIFY_ONDOWNLOAD, BOXCAR2_NOTIFY_ONSNATCH, BOXCAR2_SOUND, \
Expand Down Expand Up @@ -490,6 +491,7 @@ def initialize(consoleLogging=True):
TV_DOWNLOAD_DIR = check_setting_str(CFG, 'General', 'tv_download_dir', '')
PROCESS_AUTOMATICALLY = check_setting_int(CFG, 'General', 'process_automatically', 0)
RENAME_EPISODES = check_setting_int(CFG, 'General', 'rename_episodes', 1)
USE_ASCII_FILENAMES = check_setting_int(CFG, 'General', 'use_ascii_filenames', 0)
KEEP_PROCESSED_DIR = check_setting_int(CFG, 'General', 'keep_processed_dir', 1)
MOVE_ASSOCIATED_FILES = check_setting_int(CFG, 'General', 'move_associated_files', 0)
FILTER_ASSOCIATED_FILES = check_setting_str(CFG, 'General', 'filter_associated_files', '')
Expand Down Expand Up @@ -1072,6 +1074,7 @@ def save_config():
new_config['General']['filter_associated_files'] = FILTER_ASSOCIATED_FILES
new_config['General']['process_automatically'] = int(PROCESS_AUTOMATICALLY)
new_config['General']['rename_episodes'] = int(RENAME_EPISODES)
new_config['General']['use_ascii_filenames'] = int(USE_ASCII_FILENAMES)
new_config['General']['create_missing_show_dirs'] = int(CREATE_MISSING_SHOW_DIRS)
new_config['General']['add_shows_wo_dir'] = int(ADD_SHOWS_WO_DIR)

Expand Down
4 changes: 3 additions & 1 deletion sickbeard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import zlib
from lib import MultipartPostHandler
from httplib import BadStatusLine
from unidecode import unidecode

try:
import json
Expand All @@ -49,6 +50,7 @@
except ImportError:
import elementtree.ElementTree as etree

import sickbeard
from sickbeard.exceptions import MultipleShowObjectsException, ex
from sickbeard import logger
from sickbeard.common import USER_AGENT, mediaExtensions
Expand Down Expand Up @@ -170,7 +172,7 @@ def sanitizeFileName(name):
# remove leading/trailing periods and spaces
name = name.strip(' .')

return name
return name if not sickbeard.USE_ASCII_FILENAMES else unidecode(name)

def getURL(url, validate=False, cookies = cookielib.CookieJar(), password_mgr=None, throw_exc=False):
"""
Expand Down
2 changes: 1 addition & 1 deletion sickbeard/postProcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def process(self):
# figure out the base name of the resulting episode file
if sickbeard.RENAME_EPISODES:
orig_extension = self.file_name.rpartition('.')[-1]
new_base_name = ek.ek(os.path.basename, proper_path)
new_base_name = helpers.sanitizeFileName(ek.ek(os.path.basename, proper_path))
new_file_name = new_base_name + '.' + orig_extension

else:
Expand Down
3 changes: 2 additions & 1 deletion sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def index(self):
@cherrypy.expose
def savePostProcessing(self, naming_pattern=None, naming_multi_ep=None,
xbmc_data=None, xbmc_12plus_data=None, mediabrowser_data=None, sony_ps3_data=None, wdtv_data=None, tivo_data=None, mede8er_data=None,
keep_processed_dir=None, process_automatically=None, rename_episodes=None,
keep_processed_dir=None, process_automatically=None, rename_episodes=None, use_ascii_filenames=None,
move_associated_files=None, filter_associated_files=None, tv_download_dir=None, naming_custom_abd=None, naming_abd_pattern=None):

results = []
Expand All @@ -851,6 +851,7 @@ def savePostProcessing(self, naming_pattern=None, naming_multi_ep=None,
sickbeard.MOVE_ASSOCIATED_FILES = config.checkbox_to_value(move_associated_files)
sickbeard.FILTER_ASSOCIATED_FILES = filter_associated_files
sickbeard.RENAME_EPISODES = config.checkbox_to_value(rename_episodes)
sickbeard.USE_ASCII_FILENAMES = config.checkbox_to_value(use_ascii_filenames)

sickbeard.PROCESS_AUTOMATICALLY = config.checkbox_to_value(process_automatically)

Expand Down