Commit 088d5f3d authored by echel0n's avatar echel0n
Browse files

Added general settings option to specify a comma delimited list of allowed...

Added general settings option to specify a comma delimited list of allowed video file extensions to be checked against existing files when performing show updates/refreshes
parent 1b9fd1c8
# Changelog
- * 39f81c5 - 2018-09-05: Release v9.3.69
- * 82e88af - 2018-09-06: Added general settings option to specify a comma delimited list of allowed video file extensions to be checked against existing files when performing show updates/refreshes
- * e93f949 - 2018-09-05: Release v9.3.69
- * 3f84dd7 - 2018-09-05: Added main database function to sync tv episodes to index
- * 51f6fb2 - 2018-09-04: Release v9.3.68
- * 78d23e1 - 2018-09-04: Added 'tv_episodes_by_indexerid' database index. Added database test case. Fixed TV episode database upsert code. Misc variable name cleanup.
......
......@@ -30,10 +30,6 @@ try:
except:
from collections import UserDict
video_exts = ['3g2', '3gp', '3gp2', 'asf', 'avi', 'divx', 'flv', 'm4v', 'mk2',
'mka', 'mkv', 'mov', 'mp4', 'mp4a', 'mpeg', 'mpg', 'ogg', 'ogm',
'ogv', 'qt', 'ra', 'ram', 'rm', 'ts', 'wav', 'webm', 'wma', 'wmv']
### CPU Presets for sleep timers
cpu_presets = {
'HIGH': 0.05,
......@@ -43,8 +39,7 @@ cpu_presets = {
countryList = {'Australia': 'AU',
'Canada': 'CA',
'USA': 'US'
}
'USA': 'US'}
dateFormat = '%Y-%m-%d'
dateTimeFormat = '%Y-%m-%d %H:%M:%S'
......
......@@ -429,6 +429,7 @@ class Config(object):
self.calendar_unprotected = False
self.calendar_icons = False
self.no_restart = False
self.allowed_video_file_exts = []
self.thetvdb_apitoken = ""
self.trakt_api_key = '5c65f55e11d48c35385d9e8670615763a605fad28374c8ae553a7b7a50651ddd'
self.trakt_api_secret = 'b53e32045ac122a445ef163e6d859403301ffe9b17fb8321d428531b69022a82'
......@@ -796,6 +797,13 @@ class Config(object):
'git_password': '',
'ep_default_deleted_status': 6,
'no_restart': False,
'allowed_video_file_exts': [
'avi', 'mkv', 'mpg', 'mpeg', 'wmv',
'ogm', 'mp4', 'iso', 'img', 'divx',
'm2ts', 'm4v', 'ts', 'flv', 'f4v',
'mov', 'rmvb', 'vob', 'dvr-ms', 'wtv',
'ogv', '3gp', 'webm', 'tp'
],
'require_words': '',
'naming_strip_year': False,
'proxy_indexers': True,
......@@ -1299,6 +1307,22 @@ class Config(object):
return my_val
################################################################################
# check_setting_list #
################################################################################
def check_setting_list(self, section, key, def_val=None, silent=True):
def_val = def_val if def_val is not None else self.defaults[section][key]
try:
my_val = list(literal_eval(self.config_obj.get(section, {section: key}).get(key, def_val)))
except StandardError:
my_val = def_val
if not silent:
print(key + " -> " + repr(my_val))
return my_val
################################################################################
# check_setting_dict #
################################################################################
......@@ -1477,6 +1501,7 @@ class Config(object):
self.calendar_unprotected = self.check_setting_bool('General', 'calendar_unprotected')
self.calendar_icons = self.check_setting_bool('General', 'calendar_icons')
self.no_restart = self.check_setting_bool('General', 'no_restart')
self.allowed_video_file_exts = self.check_setting_list('General', 'allowed_video_file_exts')
self.extra_scripts = [x.strip() for x in self.check_setting_str('General', 'extra_scripts').split('|') if
x.strip()]
self.use_listview = self.check_setting_bool('General', 'use_listview')
......@@ -1971,6 +1996,7 @@ class Config(object):
'calendar_unprotected': int(self.calendar_unprotected),
'calendar_icons': int(self.calendar_icons),
'no_restart': int(self.no_restart),
'allowed_video_file_exts': self.allowed_video_file_exts,
'display_all_seasons': int(self.display_all_seasons),
'random_user_agent': int(self.random_user_agent),
'processor_follow_symlinks': int(self.processor_follow_symlinks),
......
......@@ -50,14 +50,6 @@ import sickrage
from sickrage.core.common import Quality, SKIPPED, WANTED, FAILED, UNAIRED
from sickrage.core.exceptions import MultipleShowObjectsException
mediaExtensions = [
'avi', 'mkv', 'mpg', 'mpeg', 'wmv',
'ogm', 'mp4', 'iso', 'img', 'divx',
'm2ts', 'm4v', 'ts', 'flv', 'f4v',
'mov', 'rmvb', 'vob', 'dvr-ms', 'wtv',
'ogv', '3gp', 'webm', 'tp'
]
def safe_getattr(object, name, default=None):
try:
......@@ -152,7 +144,7 @@ def remove_extension(name):
if name and "." in name:
base_name, sep, extension = name.rpartition('.')
if base_name and extension.lower() in ['nzb', 'torrent'] + mediaExtensions:
if base_name and extension.lower() in ['nzb', 'torrent'] + sickrage.app.config.allowed_video_file_exts:
name = base_name
return name
......@@ -317,7 +309,7 @@ def is_media_file(filename):
if re.search('extras?$', sepFile[0], re.I):
return False
return sepFile[-1].lower() in mediaExtensions
return sepFile[-1].lower() in sickrage.app.config.allowed_video_file_exts
def is_rar_file(filename):
......
......@@ -129,8 +129,7 @@ class PostProcessor(object):
"""
if not existing_file:
self._log("There is no existing file so there's no worries about replacing it",
sickrage.app.log.DEBUG)
self._log("There is no existing file so there's no worries about replacing it", sickrage.app.log.DEBUG)
return PostProcessor.DOESNT_EXIST
# if the new file exists, return the appropriate code depending on the size
......@@ -142,13 +141,11 @@ class PostProcessor(object):
return PostProcessor.EXISTS_LARGER
elif os.path.getsize(existing_file) == os.path.getsize(self.file_path):
self._log("File " + existing_file + " is the same size as " + self.file_path,
sickrage.app.log.DEBUG)
self._log("File " + existing_file + " is the same size as " + self.file_path, sickrage.app.log.DEBUG)
return PostProcessor.EXISTS_SAME
else:
self._log("File " + existing_file + " is smaller than " + self.file_path,
sickrage.app.log.DEBUG)
self._log("File " + existing_file + " is smaller than " + self.file_path, sickrage.app.log.DEBUG)
return PostProcessor.EXISTS_SMALLER
else:
......@@ -444,7 +441,8 @@ class PostProcessor(object):
hardlinkFile(cur_file_path, new_file_path)
chmodAsParent(new_file_path)
except (IOError, OSError) as e:
self._log("Unable to hardlink file {} to {}: {}".format(cur_file_path, new_file_path, e), sickrage.app.log.ERROR)
self._log("Unable to hardlink file {} to {}: {}".format(cur_file_path, new_file_path, e),
sickrage.app.log.ERROR)
raise
self._combined_file_operation(file_path, new_path, new_base_name, associated_files, action=_int_hard_link,
......@@ -1026,7 +1024,7 @@ class PostProcessor(object):
if not isFileLocked(self.file_path, False):
if not verify_freespace(self.file_path, ep_obj.show.location, [ep_obj] + ep_obj.relatedEps):
self._log("Not enough space to continue PostProcessing, exiting", sickrage.app.log.WARNING)
#return False
# return False
raise NoFreeSpaceException
else:
self._log("Unable to determine needed filespace as the source file is locked for access")
......
......@@ -646,7 +646,7 @@ class TVShow(object):
sickrage.app.log.debug(str(self.indexerid) + ": Creating episode from " + mediaFile)
try:
curEpisode = self.makeEpFromFile(os.path.join(self.location, mediaFile))
curEpisode = self.make_ep_from_file(os.path.join(self.location, mediaFile))
except (ShowNotFoundException, EpisodeNotFoundException) as e:
sickrage.app.log.warning("Episode " + mediaFile + " returned an exception: {}".format(e))
except EpisodeDeletedException:
......@@ -778,25 +778,25 @@ class TVShow(object):
return fanart_result or poster_result or banner_result or season_posters_result or season_banners_result or season_all_poster_result or season_all_banner_result
# make a TVEpisode object from a media file
def makeEpFromFile(self, file):
if not os.path.isfile(file):
sickrage.app.log.info(str(self.indexerid) + ": That isn't even a real file dude... " + file)
def make_ep_from_file(self, filename):
if not os.path.isfile(filename):
sickrage.app.log.info(str(self.indexerid) + ": That isn't even a real file dude... " + filename)
return None
sickrage.app.log.debug(str(self.indexerid) + ": Creating episode object from " + file)
sickrage.app.log.debug(str(self.indexerid) + ": Creating episode object from " + filename)
try:
parse_result = NameParser(showObj=self).parse(file, skip_scene_detection=True)
parse_result = NameParser(showObj=self).parse(filename, skip_scene_detection=True)
except InvalidNameException:
sickrage.app.log.debug("Unable to parse the filename " + file + " into a valid episode")
sickrage.app.log.debug("Unable to parse the filename " + filename + " into a valid episode")
return None
except InvalidShowException:
sickrage.app.log.debug("Unable to parse the filename " + file + " into a valid show")
sickrage.app.log.debug("Unable to parse the filename " + filename + " into a valid show")
return None
if not len(parse_result.episode_numbers):
sickrage.app.log.info("parse_result: " + str(parse_result))
sickrage.app.log.warning("No episode number found in " + file + ", ignoring it")
sickrage.app.log.warning("No episode number found in " + filename + ", ignoring it")
return None
# for now lets assume that any episode in the show dir belongs to that show
......@@ -807,7 +807,7 @@ class TVShow(object):
episode = int(curEpNum)
sickrage.app.log.debug(
"%s: %s parsed to %s S%02dE%02d" % (self.indexerid, file, self.name, season or 0, episode or 0))
"%s: %s parsed to %s S%02dE%02d" % (self.indexerid, filename, self.name, season or 0, episode or 0))
checkQualityAgain = False
same_file = False
......@@ -815,7 +815,7 @@ class TVShow(object):
curEp = self.getEpisode(season, episode)
if not curEp:
try:
curEp = self.getEpisode(season, episode, file)
curEp = self.getEpisode(season, episode, filename)
except EpisodeNotFoundException:
sickrage.app.log.error(
str(self.indexerid) + ": Unable to figure out what this file is, skipping")
......@@ -823,15 +823,15 @@ class TVShow(object):
else:
# if there is a new file associated with this ep then re-check the quality
if curEp.location and os.path.normpath(curEp.location) != os.path.normpath(file):
sickrage.app.log.debug(
"The old episode had a different file associated with it, I will re-check the quality based on the new filename " + file)
if curEp.location and os.path.normpath(curEp.location) != os.path.normpath(filename):
sickrage.app.log.debug("The old episode had a different file associated with it, I will re-check "
"the quality based on the new filename " + filename)
checkQualityAgain = True
with curEp.lock:
# if the sizes are the same then it's probably the same file
old_size = curEp.file_size
curEp.location = file
curEp.location = filename
same_file = old_size and curEp.file_size == old_size
curEp.checkForMetaFiles()
......@@ -849,7 +849,7 @@ class TVShow(object):
# if they replace a file on me I'll make some attempt at re-checking the quality unless I know it's the same file
if checkQualityAgain and not same_file:
newQuality = Quality.nameQuality(file, self.is_anime)
newQuality = Quality.nameQuality(filename, self.is_anime)
sickrage.app.log.debug("Since this file has been renamed")
with curEp.lock:
......@@ -857,9 +857,9 @@ class TVShow(object):
# check for status/quality changes as long as it's a new file
elif not same_file and is_media_file(
file) and curEp.status not in Quality.DOWNLOADED + Quality.ARCHIVED + [IGNORED]:
filename) and curEp.status not in Quality.DOWNLOADED + Quality.ARCHIVED + [IGNORED]:
oldStatus, oldQuality = Quality.splitCompositeStatus(curEp.status)
newQuality = Quality.nameQuality(file, self.is_anime)
newQuality = Quality.nameQuality(filename, self.is_anime)
newStatus = None
......@@ -889,7 +889,7 @@ class TVShow(object):
sickrage.app.log.debug(
"STATUS: we have an associated file, so setting the status from " + str(
curEp.status) + " to DOWNLOADED/" + str(
Quality.statusFromName(file, anime=self.is_anime)))
Quality.statusFromName(filename, anime=self.is_anime)))
curEp.status = Quality.compositeStatus(newStatus, newQuality)
with curEp.lock:
......
......@@ -3712,7 +3712,7 @@ class ConfigGeneral(Config):
fuzzy_dating=None, trim_zero=None, date_preset=None, date_preset_na=None, time_preset=None,
indexer_timeout=None, download_url=None, rootDir=None, theme_name=None, default_page=None,
git_reset=None, git_username=None, git_password=None, git_autoissues=None, gui_language=None,
display_all_seasons=None, showupdate_stale=None, notify_on_login=None,
display_all_seasons=None, showupdate_stale=None, notify_on_login=None, allowed_video_file_exts=None,
enable_api_providers_cache=None, enable_upnp=None, web_external_port=None, **kwargs):
results = []
......@@ -3774,6 +3774,8 @@ class ConfigGeneral(Config):
sickrage.app.config.fuzzy_dating = checkbox_to_value(fuzzy_dating)
sickrage.app.config.trim_zero = checkbox_to_value(trim_zero)
sickrage.app.config.allowed_video_file_exts = [x.lower() for x in allowed_video_file_exts.split(',')]
# sickrage.app.config.change_web_external_port(web_external_port)
if date_preset:
......
......@@ -322,6 +322,7 @@
<%include file="../includes/root_dirs.mako"/>
</div>
</div>
<div class="form-row">
<div class="col-md-12">
<input type="submit" class="btn config_submitter" value="${_('Save Changes')}"/>
......@@ -1199,6 +1200,26 @@
</div>
</div>
<div class="form-row form-group">
<div class="col-lg-3 col-md-4 col-sm-5">
<label class="component-title">${_('Allowed video file extensions')}</label>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 component-desc">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-file"></span>
</span>
</div>
<input name="allowed_video_file_exts" id="allowed_video_file_exts"
value="${','.join(sickrage.app.config.allowed_video_file_exts)}"
placeholder="${_('ex: avi,mp4,mkv')}"
title="comma separated list of video file extensions you want to allow, do not include dots"
class="form-control"/>
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-12">
<input type="submit" class="btn config_submitter" value="${_('Save Changes')}"/>
......
......@@ -58,7 +58,7 @@ class RarbgProvider(TorrentProvider):
try:
response = self.session.get(self.urls['api'], params=login_params, random_ua=True).json()
except Exception:
except Exception as e:
sickrage.app.log.warning("Unable to connect to provider")
return False
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment