Skip to content

Best Fit Quality #987

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 2 commits 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ desktop.ini
ehthumbs.db
Thumbs.db
.directory
*~
*~
7 changes: 7 additions & 0 deletions data/interfaces/default/config_search.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
<span class="component-desc">Replace original download with "Proper/Repack" if nuked?</span>
</label>
</div>
<div class="field-pair">
<input type="checkbox" name="best_fit_quality" id="best_fit_quality" #if $sickbeard.BEST_FIT_QUALITY == True then "checked=\"checked\"" else ""# />
<label class="clearfix" for="best_fit_quality">
<span class="component-title">Best Fit Quality</span>
<span class="component-desc">Attempt to guess the quality in the case a perfect match cannot be found</span>
</label>
</div>

<div class="field-pair">
<label class="nocheck clearfix">
Expand Down
9 changes: 6 additions & 3 deletions sickbeard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
NZB_DIR = None
USENET_RETENTION = None
DOWNLOAD_PROPERS = None
BEST_FIT_QUALITY = None

SEARCH_FREQUENCY = None
BACKLOG_SEARCH_FREQUENCY = 21
Expand Down Expand Up @@ -347,7 +348,7 @@ def initialize(consoleLogging=True):
with INIT_LOCK:

global ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, USE_API, API_KEY, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, \
USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, BEST_FIT_QUALITY, \
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_HOST, \
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, currentSearchScheduler, backlogSearchScheduler, \
USE_XBMC, XBMC_ALWAYS_ON, XBMC_NOTIFY_ONSNATCH, XBMC_NOTIFY_ONDOWNLOAD, XBMC_UPDATE_FULL, XBMC_UPDATE_ONLYFIRST, \
Expand Down Expand Up @@ -478,15 +479,16 @@ def initialize(consoleLogging=True):
NZB_METHOD = 'blackhole'

DOWNLOAD_PROPERS = bool(check_setting_int(CFG, 'General', 'download_propers', 1))
BEST_FIT_QUALITY = bool(check_setting_int(CFG, 'General', 'best_fit_quality', 0))
USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', 500)
SEARCH_FREQUENCY = check_setting_int(CFG, 'General', 'search_frequency', DEFAULT_SEARCH_FREQUENCY)
if SEARCH_FREQUENCY < MIN_SEARCH_FREQUENCY:
SEARCH_FREQUENCY = MIN_SEARCH_FREQUENCY

POSTPROCESS_FREQUENCY = check_setting_int(CFG, 'General', 'postprocess_frequency', DEFAULT_POSTPROCESS_FREQUENCY)
if POSTPROCESS_FREQUENCY < MIN_POSTPROCESS_FREQUENCY:
POSTPROCESS_FREQUENCY = MIN_POSTPROCESS_FREQUENCY

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)
Expand Down Expand Up @@ -1044,6 +1046,7 @@ def save_config():
new_config['General']['search_frequency'] = int(SEARCH_FREQUENCY)
new_config['General']['postprocess_frequency'] = int(POSTPROCESS_FREQUENCY)
new_config['General']['download_propers'] = int(DOWNLOAD_PROPERS)
new_config['General']['best_fit_quality'] = int(BEST_FIT_QUALITY)
new_config['General']['quality_default'] = int(QUALITY_DEFAULT)
new_config['General']['status_default'] = int(STATUS_DEFAULT)
new_config['General']['flatten_folders_default'] = int(FLATTEN_FOLDERS_DEFAULT)
Expand Down
31 changes: 31 additions & 0 deletions sickbeard/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import platform
import re

import sickbeard
from sickbeard import version

USER_AGENT = 'Sick Beard/alpha2-' + version.SICKBEARD_VERSION.replace(' ', '-') + ' (' + platform.system() + ' ' + platform.release() + ')'
Expand Down Expand Up @@ -165,8 +166,38 @@ def nameQuality(name):
return Quality.HDBLURAY
elif checkName(["1080p", "bluray|hddvd", "x264"], all):
return Quality.FULLHDBLURAY
elif sickbeard.BEST_FIT_QUALITY :
return Quality.attemptFitQuality(name)
else:
return Quality.UNKNOWN
@staticmethod
def attemptFitQuality(name):
# perform a hierarchical search
# -> Resolution
# -> Source
# -> Encoding

bestQuality = Quality.UNKNOWN
if re.search("1080", name, re.I) :
bestQuality = Quality.FULLHDTV
if re.search("bluray|hddvd", name, re.I) :
bestQuality = Quality.FULLHDBLURAY
elif re.search("web", name, re.I) :
bestQuality = Quality.FULLHDWEBDL
elif re.search("720", name, re.I) :
bestQuality = Quality.HDTV
if re.search("bluray|hddvd", name, re.I) :
bestQuality = Quality.HDBLURAY
elif re.search("web", name, re.I) :
bestQuality = Quality.HDWEBDL
elif re.search("mpeg-?2", name, re.I) :
bestQuality = Quality.RAWHDTV
elif re.search("(pdtv|hdtv|dsr|tvrip)", name, re.I ) :
bestQuality = Quality.SDTV
if re.search("(dvdrip|bdrip)", name, re.I) :
bestQuality = Quality.SDDVD

return bestQuality

@staticmethod
def assumeQuality(name):
Expand Down
3 changes: 2 additions & 1 deletion sickbeard/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,13 @@ def index(self):
@cherrypy.expose
def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None,
sab_apikey=None, sab_category=None, sab_host=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_host=None,
torrent_dir=None, nzb_method=None, usenet_retention=None, search_frequency=None, download_propers=None, ignore_words=None):
torrent_dir=None, nzb_method=None, usenet_retention=None, search_frequency=None, download_propers=None, best_fit_quality=None, ignore_words=None):

results = []

# Episode Search
sickbeard.DOWNLOAD_PROPERS = config.checkbox_to_value(download_propers)
sickbeard.BEST_FIT_QUALITY = config.checkbox_to_value(best_fit_quality)

config.change_SEARCH_FREQUENCY(search_frequency)
sickbeard.USENET_RETENTION = config.to_int(usenet_retention, default=500)
Expand Down