Skip to content

Commit

Permalink
Merge pull request #39 from pymedusa/pref-words
Browse files Browse the repository at this point in the history
Pref words
  • Loading branch information
labrys committed Feb 27, 2016
2 parents f42fd0a + eaa08ac commit 7ce37f3
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 25 deletions.
27 changes: 26 additions & 1 deletion gui/slick/views/config_search.mako
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,31 @@
</label>
</div>
<div class="field-pair">
<label>
<span class="component-title">Preferred words</span>
<span class="component-desc">
<input type="text" name="prefered_words" value="${sickbeard.PREFERED_WORDS}" class="form-control input-sm input350" autocapitalize="off" />
<div class="clear-left">results with one or more word from this list will be chosen over others<br>
separate words with a comma, e.g. "word1,word2,word3"
</div>
</span>
</label>
</div>
<div class="field-pair">
<label>
<span class="component-title">Undesired words</span>
<span class="component-desc">
<input type="text" name="undesired_words" value="${sickbeard.UNDESIRED_WORDS}" class="form-control input-sm input350" autocapitalize="off" />
<div class="clear-left">results withouth words from this list will be prefered<br>
separate words with a comma, e.g. "word1,word2,word3"
</div>
</span>
</label>
</div>
<div class="field-pair">
<label>
<span class="component-title">Trackers list</span>
Expand Down Expand Up @@ -645,4 +670,4 @@
</form>
</div>
</div>
</%block>
</%block>
26 changes: 18 additions & 8 deletions sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
GIT_PATH = None
DEVELOPER = False

NEWS_URL = 'https://api.pymedusa.com/news.md'
NEWS_URL = 'https://raw.githubusercontent.com/pymedusa/sickrage.github.io/master/sickrage-news/news.md'
NEWS_LAST_READ = None
NEWS_LATEST = None
NEWS_UNREAD = 0
Expand Down Expand Up @@ -351,6 +351,7 @@
PLEX_CLIENT_HOST = None
PLEX_SERVER_USERNAME = None
PLEX_SERVER_PASSWORD = None
PLEX_SERVER_NO_AUTH = False

USE_PLEX_CLIENT = False
PLEX_CLIENT_USERNAME = None
Expand Down Expand Up @@ -553,6 +554,10 @@

IGNORE_WORDS = "german,french,core2hd,dutch,swedish,reenc,MrLss"

PREFERED_WORDS = ""

UNDESIRED_WORDS = ""

TRACKERS_LIST = "udp://coppersurfer.tk:6969/announce,udp://open.demonii.com:1337,"
TRACKERS_LIST += "udp://exodus.desync.com:6969,udp://9.rarbg.me:2710/announce,"
TRACKERS_LIST += "udp://glotorrents.pw:6969/announce,udp://tracker.openbittorrent.com:80/announce,"
Expand Down Expand Up @@ -600,7 +605,7 @@ def initialize(consoleLogging=True): # pylint: disable=too-many-locals, too-man
USE_KODI, KODI_ALWAYS_ON, KODI_NOTIFY_ONSNATCH, KODI_NOTIFY_ONDOWNLOAD, KODI_NOTIFY_ONSUBTITLEDOWNLOAD, KODI_UPDATE_FULL, KODI_UPDATE_ONLYFIRST, \
KODI_UPDATE_LIBRARY, KODI_HOST, KODI_USERNAME, KODI_PASSWORD, BACKLOG_FREQUENCY, \
USE_TRAKT, TRAKT_USERNAME, TRAKT_ACCESS_TOKEN, TRAKT_REFRESH_TOKEN, TRAKT_REMOVE_WATCHLIST, TRAKT_SYNC_WATCHLIST, TRAKT_REMOVE_SHOW_FROM_SICKRAGE, TRAKT_METHOD_ADD, TRAKT_START_PAUSED, traktCheckerScheduler, TRAKT_USE_RECOMMENDED, TRAKT_SYNC, TRAKT_SYNC_REMOVE, TRAKT_DEFAULT_INDEXER, TRAKT_REMOVE_SERIESLIST, TRAKT_TIMEOUT, TRAKT_BLACKLIST_NAME, \
USE_PLEX_SERVER, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, USE_PLEX_CLIENT, PLEX_CLIENT_USERNAME, PLEX_CLIENT_PASSWORD, \
USE_PLEX_SERVER, PLEX_SERVER_NO_AUTH, PLEX_NOTIFY_ONSNATCH, PLEX_NOTIFY_ONDOWNLOAD, PLEX_NOTIFY_ONSUBTITLEDOWNLOAD, PLEX_UPDATE_LIBRARY, USE_PLEX_CLIENT, PLEX_CLIENT_USERNAME, PLEX_CLIENT_PASSWORD, \
PLEX_SERVER_HOST, PLEX_SERVER_TOKEN, PLEX_CLIENT_HOST, PLEX_SERVER_USERNAME, PLEX_SERVER_PASSWORD, PLEX_SERVER_HTTPS, MIN_BACKLOG_FREQUENCY, SKIP_REMOVED_FILES, ALLOWED_EXTENSIONS, \
USE_EMBY, EMBY_HOST, EMBY_APIKEY, \
showUpdateScheduler, __INITIALIZED__, INDEXER_DEFAULT_LANGUAGE, EP_DEFAULT_DELETED_STATUS, LAUNCH_BROWSER, TRASH_REMOVE_SHOW, TRASH_ROTATE_LOGS, SORT_ARTICLE, \
Expand Down Expand Up @@ -629,7 +634,7 @@ def initialize(consoleLogging=True): # pylint: disable=too-many-locals, too-man
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, SYNC_FILES, POSTPONE_IF_SYNC_FILES, POSTPONE_IF_NO_SUBS, dailySearchScheduler, NFO_RENAME, \
GUI_NAME, HOME_LAYOUT, HISTORY_LAYOUT, DISPLAY_SHOW_SPECIALS, COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, COMING_EPS_MISSED_RANGE, FUZZY_DATING, TRIM_ZERO, DATE_PRESET, TIME_PRESET, TIME_PRESET_W_SECONDS, THEME_NAME, \
POSTER_SORTBY, POSTER_SORTDIR, HISTORY_LIMIT, CREATE_MISSING_SHOW_DIRS, ADD_SHOWS_WO_DIR, \
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, TRACKERS_LIST, IGNORED_SUBS_LIST, REQUIRE_WORDS, CALENDAR_UNPROTECTED, CALENDAR_ICONS, NO_RESTART, \
METADATA_WDTV, METADATA_TIVO, METADATA_MEDE8ER, IGNORE_WORDS, PREFERED_WORDS, UNDESIRED_WORDS, TRACKERS_LIST, IGNORED_SUBS_LIST, REQUIRE_WORDS, CALENDAR_UNPROTECTED, CALENDAR_ICONS, NO_RESTART, \
USE_SUBTITLES, SUBTITLES_LANGUAGES, SUBTITLES_DIR, SUBTITLES_SERVICES_LIST, SUBTITLES_SERVICES_ENABLED, SUBTITLES_HISTORY, SUBTITLES_FINDER_FREQUENCY, SUBTITLES_MULTI, SUBTITLES_DOWNLOAD_IN_PP, SUBTITLES_KEEP_ONLY_WANTED, EMBEDDED_SUBTITLES_ALL, SUBTITLES_EXTRA_SCRIPTS, SUBTITLES_PERFECT_MATCH, subtitlesFinderScheduler, \
SUBTITLES_HEARING_IMPAIRED, ADDIC7ED_USER, ADDIC7ED_PASS, LEGENDASTV_USER, LEGENDASTV_PASS, OPENSUBTITLES_USER, OPENSUBTITLES_PASS, \
USE_FAILED_DOWNLOADS, DELETE_FAILED, ANON_REDIRECT, LOCALHOST_IP, DEBUG, DBDEBUG, DEFAULT_PAGE, PROXY_SETTING, PROXY_INDEXERS, \
Expand Down Expand Up @@ -1023,6 +1028,7 @@ def path_leaf(path):
PLEX_CLIENT_USERNAME = check_setting_str(CFG, 'Plex', 'plex_client_username', '', censor_log=True)
PLEX_CLIENT_PASSWORD = check_setting_str(CFG, 'Plex', 'plex_client_password', '', censor_log=True)
PLEX_SERVER_HTTPS = bool(check_setting_int(CFG, 'Plex', 'plex_server_https', 0))
PLEX_SERVER_NO_AUTH = bool(check_setting_int(CFG, 'Plex', 'plex_server_no_auth', 0))

USE_EMBY = bool(check_setting_int(CFG, 'Emby', 'use_emby', 0))
EMBY_HOST = check_setting_str(CFG, 'Emby', 'emby_host', '')
Expand Down Expand Up @@ -1203,6 +1209,8 @@ def path_leaf(path):
GIT_PATH = check_setting_str(CFG, 'General', 'git_path', '')

IGNORE_WORDS = check_setting_str(CFG, 'General', 'ignore_words', IGNORE_WORDS)
PREFERED_WORDS = check_setting_str(CFG, 'General', 'prefered_words', PREFERED_WORDS)
UNDESIRED_WORDS = check_setting_str(CFG, 'General', 'undesired_words', UNDESIRED_WORDS)
TRACKERS_LIST = check_setting_str(CFG, 'General', 'trackers_list', TRACKERS_LIST)
REQUIRE_WORDS = check_setting_str(CFG, 'General', 'require_words', REQUIRE_WORDS)
IGNORED_SUBS_LIST = check_setting_str(CFG, 'General', 'ignored_subs_list', IGNORED_SUBS_LIST)
Expand Down Expand Up @@ -1465,12 +1473,11 @@ def path_leaf(path):
run_delay=update_interval)

# processors
update_interval = datetime.timedelta(minutes=AUTOPOSTPROCESSER_FREQUENCY)
autoPostProcesserScheduler = scheduler.Scheduler(auto_postprocessor.PostProcessor(),
cycleTime=update_interval,
cycleTime=datetime.timedelta(
minutes=AUTOPOSTPROCESSER_FREQUENCY),
threadName="POSTPROCESSER",
silent=not PROCESS_AUTOMATICALLY,
run_delay=update_interval)
silent=not PROCESS_AUTOMATICALLY)

traktCheckerScheduler = scheduler.Scheduler(traktChecker.TraktChecker(),
cycleTime=datetime.timedelta(hours=1),
Expand Down Expand Up @@ -1749,6 +1756,8 @@ def save_config(): # pylint: disable=too-many-statements, too-many-branches
new_config['General']['extra_scripts'] = '|'.join(EXTRA_SCRIPTS)
new_config['General']['git_path'] = GIT_PATH
new_config['General']['ignore_words'] = IGNORE_WORDS
new_config['General']['prefered_words'] = PREFERED_WORDS
new_config['General']['undesired_words'] = UNDESIRED_WORDS
new_config['General']['trackers_list'] = TRACKERS_LIST
new_config['General']['require_words'] = REQUIRE_WORDS
new_config['General']['ignored_subs_list'] = IGNORED_SUBS_LIST
Expand Down Expand Up @@ -1935,6 +1944,7 @@ def save_config(): # pylint: disable=too-many-statements, too-many-branches
new_config['Plex']['plex_client_host'] = PLEX_CLIENT_HOST
new_config['Plex']['plex_server_username'] = PLEX_SERVER_USERNAME
new_config['Plex']['plex_server_password'] = helpers.encrypt(PLEX_SERVER_PASSWORD, ENCRYPTION_VERSION)
new_config['Plex']['plex_server_no_auth'] = int(PLEX_SERVER_NO_AUTH)

new_config['Plex']['use_plex_client'] = int(USE_PLEX_CLIENT)
new_config['Plex']['plex_client_username'] = PLEX_CLIENT_USERNAME
Expand Down Expand Up @@ -2177,4 +2187,4 @@ def launchBrowser(protocol='http', startPort=None, web_root='/'):
try:
webbrowser.open(browserURL, 1, 1)
except Exception:
logger.log(u"Unable to launch a browser", logger.ERROR)
logger.log(u"Unable to launch a browser", logger.ERROR)
9 changes: 8 additions & 1 deletion sickbeard/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,21 +113,28 @@ def remove_non_release_groups(name):
r'\[eztv\]$': 'searchre',
r'\[ettv\]$': 'searchre',
r'\[cttv\]$': 'searchre',
r'\.\[vtv\]$': 'searchre',
r'\[vtv\]$': 'searchre',
r'\[EtHD\]$': 'searchre',
r'\[GloDLS\]$': 'searchre',
r'\[silv4\]$': 'searchre',
r'\[Seedbox\]$': 'searchre',
r'\[PublicHD\]$': 'searchre',
r'-\=\{SPARROW\}\=-$': 'searchre',
r'\=\{SPARR$': 'searchre',
r'\.\[720P\]\[HEVC\]$': 'searchre',
r'\[AndroidTwoU\]$': 'searchre',
r'\[brassetv]\]$': 'searchre',
r'\[brassetv\]]$': 'searchre',
r'\[Talamasca32\]]$': 'searchre',
r'\(musicbolt\.com\)$': 'searchre',
r'\.\[BT\]$': 'searchre',
r' \[1044\]$': 'searchre',
r'\.RiPSaLoT$': 'searchre',
r'\.GiuseppeTnT$': 'searchre',
r'\.Renc$': 'searchre',
r'\.gz$': 'searchre',
r'\.English$': 'searchre',
r'\.German$': 'searchre',
r'(?<![57])\.1$': 'searchre',
r'-NZBGEEK$': 'searchre',
r'-Siklopentan$': 'searchre',
Expand Down
14 changes: 13 additions & 1 deletion sickbeard/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ def pickBestResult(results, show): # pylint: disable=too-many-branches
cur_result.provider.name):
logger.log(cur_result.name + u" has previously failed, rejecting it")
continue
prefered_words = ''
if sickbeard.PREFERED_WORDS:
prefered_words = sickbeard.PREFERED_WORDS.lower().split(',')
undesired_words = ''
if sickbeard.UNDESIRED_WORDS:
undesired_words = sickbeard.UNDESIRED_WORDS.lower().split(',')

if not bestResult:
bestResult = cur_result
Expand All @@ -254,6 +260,9 @@ def pickBestResult(results, show): # pylint: disable=too-many-branches
elif cur_result.quality in anyQualities and bestResult.quality not in bestQualities and bestResult.quality < cur_result.quality:
bestResult = cur_result
elif bestResult.quality == cur_result.quality:
if any(ext in cur_result.name.lower() for ext in prefered_words):
logger.log(u"Preferring " + cur_result.name + " (preferred words)")
bestResult = cur_result
if "proper" in cur_result.name.lower() or "real" in cur_result.name.lower() or "repack" in cur_result.name.lower():
logger.log(u"Preferring " + cur_result.name + " (repack/proper/real over nuked)")
bestResult = cur_result
Expand All @@ -263,6 +272,9 @@ def pickBestResult(results, show): # pylint: disable=too-many-branches
elif "xvid" in bestResult.name.lower() and "x264" in cur_result.name.lower():
logger.log(u"Preferring " + cur_result.name + " (x264 over xvid)")
bestResult = cur_result
if any(ext in bestResult.name.lower() and ext not in cur_result.name.lower() for ext in undesired_words):
logger.log(u"Dont want this release " + cur_result.name + " (contains undesired word(s))")
bestResult = cur_result

if bestResult:
logger.log(u"Picked " + bestResult.name + " as the best", logger.DEBUG)
Expand Down Expand Up @@ -744,4 +756,4 @@ def searchProviders(show, episodes, manualSearch=False, downCurQuality=False):

# Remove provider from thread name before return results
threading.currentThread().name = origThreadName
return finalResults
return finalResults
24 changes: 10 additions & 14 deletions sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,8 @@
from tornado.web import RequestHandler, HTTPError, authenticated
from tornado.gen import coroutine
from tornado.ioloop import IOLoop

from concurrent.futures import ThreadPoolExecutor
from tornado.process import cpu_count

from tornado.concurrent import run_on_executor

from concurrent.futures import ThreadPoolExecutor
from mako.runtime import UNDEFINED

mako_lookup = None
Expand Down Expand Up @@ -259,7 +255,7 @@ def __init__(self, *args, **kwargs):
super(WebHandler, self).__init__(*args, **kwargs)
self.io_loop = IOLoop.current()

executor = ThreadPoolExecutor(cpu_count())
executor = ThreadPoolExecutor(50)

@authenticated
@coroutine
Expand Down Expand Up @@ -2238,7 +2234,7 @@ def __init__(self, *args, **kwargs):

def index(self):
try:
changes = helpers.getURL('https://api.pymedusa.com/changelog.md', session=requests.Session(), returns='text')
changes = helpers.getURL('https://raw.githubusercontent.com/pymedusa/sickrage.github.io/master/sickrage-news/CHANGES.md', session=requests.Session(), returns='text')
except Exception:
logger.log(u'Could not load changes from repo, giving a link!', logger.DEBUG)
changes = 'Could not load changes from the repo. [Click here for CHANGES.md](https://raw.githubusercontent.com/pymedusa/sickrage.github.io/master/sickrage-news/CHANGES.md)'
Expand Down Expand Up @@ -4061,7 +4057,7 @@ def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_usernam
torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None,
torrent_label=None, torrent_label_anime=None, torrent_path=None, torrent_verify_cert=None,
torrent_seed_time=None, torrent_paused=None, torrent_high_bandwidth=None,
torrent_rpcurl=None, torrent_auth_type=None, ignore_words=None, trackers_list=None, require_words=None, ignored_subs_list=None):
torrent_rpcurl=None, torrent_auth_type=None, ignore_words=None, prefered_words=None, undesired_words=None, trackers_list=None, require_words=None, ignored_subs_list=None):

results = []

Expand All @@ -4084,6 +4080,8 @@ def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_usernam
sickbeard.USENET_RETENTION = try_int(usenet_retention, 500)

sickbeard.IGNORE_WORDS = ignore_words if ignore_words else ""
sickbeard.PREFERED_WORDS = prefered_words if prefered_words else ""
sickbeard.UNDESIRED_WORDS = undesired_words if undesired_words else ""
sickbeard.TRACKERS_LIST = trackers_list if trackers_list else ""
sickbeard.REQUIRE_WORDS = require_words if require_words else ""
sickbeard.IGNORED_SUBS_LIST = ignored_subs_list if ignored_subs_list else ""
Expand Down Expand Up @@ -5229,7 +5227,7 @@ def clearerrors(self, level=logger.ERROR):

return self.redirect("/errorlogs/viewlog/")

def viewlog(self, minLevel=logger.INFO, logFilter="<NONE>", logSearch=None, maxLines=1000):
def viewlog(self, minLevel=logger.INFO, logFilter="<NONE>", logSearch=None, maxLines=500):

def Get_Data(Levelmin, data_in, lines_in, regex, Filter, Search, mlines):

Expand All @@ -5245,6 +5243,8 @@ def Get_Data(Levelmin, data_in, lines_in, regex, Filter, Search, mlines):
if match:
level = match.group(7)
logName = match.group(8)
if not sickbeard.DEBUG and (level == 'DEBUG' or level == 'DB'):
continue
if level not in logger.LOGGING_LEVELS:
lastLine = False
continue
Expand Down Expand Up @@ -5287,10 +5287,6 @@ def Get_Data(Levelmin, data_in, lines_in, regex, Filter, Search, mlines):
'SEARCHQUEUE-MANUAL': u'Search Queue (Manual)',
'SEARCHQUEUE-RETRY': u'Search Queue (Retry/Failed)',
'SEARCHQUEUE-RSS': u'Search Queue (RSS)',
'SHOWQUEUE-FORCE-UPDATE': u'Search Queue (Forced Update)',
'SHOWQUEUE-UPDATE': u'Search Queue (Update)',
'SHOWQUEUE-REFRESH': u'Search Queue (Refresh)',
'SHOWQUEUE-FORCE-REFRESH': u'Search Queue (Forced Refresh)',
'FINDPROPERS': u'Find Propers',
'POSTPROCESSER': u'Postprocesser',
'FINDSUBTITLES': u'Find Subtitles',
Expand Down Expand Up @@ -5330,4 +5326,4 @@ def submit_errors(self):
submitter_notification = ui.notifications.error if issue_id is None else ui.notifications.message
submitter_notification(submitter_result)

return self.redirect("/errorlogs/")
return self.redirect("/errorlogs/")

0 comments on commit 7ce37f3

Please sign in to comment.