Skip to content

Commit

Permalink
made quality strings user configurable in config.ini, gui does not re…
Browse files Browse the repository at this point in the history
…flect this option
  • Loading branch information
jconnop committed Jan 26, 2011
1 parent b5f5cd0 commit c28b5c9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 9 deletions.
33 changes: 32 additions & 1 deletion sickbeard/__init__.py
Expand Up @@ -191,6 +191,15 @@
TWITTER_PASSWORD = None
TWITTER_PREFIX = None

QUALITY_NONE = None
QUALITY_UNKNOWN = None
QUALITY_SDTV = None
QUALITY_SDDVD = None
QUALITY_HDTV = None
QUALITY_HDWEBDL = None
QUALITY_HDBLURAY = None
QUALITY_FULLHDBLURAY = None

COMING_EPS_LAYOUT = None
COMING_EPS_DISPLAY_PAUSED = None
COMING_EPS_SORT = None
Expand Down Expand Up @@ -309,7 +318,9 @@ def initialize(consoleLogging=True):
NAMING_DATES, EXTRA_SCRIPTS, USE_TWITTER, TWITTER_USERNAME, TWITTER_PASSWORD, TWITTER_PREFIX, \
USE_BANNER, USE_LISTVIEW, METADATA_XBMC, METADATA_MEDIABROWSER, METADATA_PS3, metadata_provider_dict, \
NEWZBIN, NEWZBIN_USERNAME, NEWZBIN_PASSWORD, GIT_PATH, MOVE_ASSOCIATED_FILES, \
COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, METADATA_WDTV
COMING_EPS_LAYOUT, COMING_EPS_SORT, COMING_EPS_DISPLAY_PAUSED, METADATA_WDTV, \
QUALITY_NONE, QUALITY_UNKNOWN, QUALITY_SDTV, QUALITY_SDDVD, QUALITY_HDTV, QUALITY_HDWEBDL, \
QUALITY_HDBLURAY, QUALITY_FULLHDBLURAY

if __INITIALIZED__:
return False
Expand All @@ -324,6 +335,7 @@ def initialize(consoleLogging=True):
CheckSection('XBMC')
CheckSection('Growl')
CheckSection('Twitter')
CheckSection('CustomQuality')

LOG_DIR = check_setting_str(CFG, 'General', 'log_dir', 'Logs')
if not helpers.makeDir(LOG_DIR):
Expand Down Expand Up @@ -456,6 +468,15 @@ def initialize(consoleLogging=True):
TWITTER_USERNAME = check_setting_str(CFG, 'Twitter', 'twitter_username', '')
TWITTER_PASSWORD = check_setting_str(CFG, 'Twitter', 'twitter_password', '')
TWITTER_PREFIX = check_setting_str(CFG, 'Twitter', 'twitter_prefix', 'Sick Beard')

QUALITY_NONE = check_setting_str(CFG, 'CustomQuality', 'quality_none', 'N/A')
QUALITY_UNKNOWN = check_setting_str(CFG, 'CustomQuality', 'quality_unknown', 'Unknown')
QUALITY_SDTV = check_setting_str(CFG, 'CustomQuality', 'quality_sdtv', 'SD TV')
QUALITY_SDDVD = check_setting_str(CFG, 'CustomQuality', 'quality_sddvd', 'SD DVD')
QUALITY_HDTV = check_setting_str(CFG, 'CustomQuality', 'quality_hdtv', 'HD TV')
QUALITY_HDWEBDL = check_setting_str(CFG, 'CustomQuality', 'quality_hdwebdl', '720p WEB-DL')
QUALITY_HDBLURAY = check_setting_str(CFG, 'CustomQuality', 'quality_hdbluray', '720p BluRay')
QUALITY_FULLHDBLURAY = check_setting_str(CFG, 'CustomQuality', 'quality_fullhdbluray', '1080p BluRay')

GIT_PATH = check_setting_str(CFG, 'General', 'git_path', '')

Expand Down Expand Up @@ -884,6 +905,16 @@ def save_config():
new_config['GUI']['coming_eps_layout'] = COMING_EPS_LAYOUT
new_config['GUI']['coming_eps_display_paused'] = int(COMING_EPS_DISPLAY_PAUSED)
new_config['GUI']['coming_eps_sort'] = COMING_EPS_SORT

new_config['CustomQuality'] = {}
new_config['CustomQuality']['quality_none'] = QUALITY_NONE
new_config['CustomQuality']['quality_unknown'] = QUALITY_UNKNOWN
new_config['CustomQuality']['quality_sdtv'] = QUALITY_SDTV
new_config['CustomQuality']['quality_sddvd'] = QUALITY_SDDVD
new_config['CustomQuality']['quality_hdtv'] = QUALITY_HDTV
new_config['CustomQuality']['quality_hdwebdl'] = QUALITY_HDWEBDL
new_config['CustomQuality']['quality_hdbluray'] = QUALITY_HDBLURAY
new_config['CustomQuality']['quality_fullhdbluray'] = QUALITY_FULLHDBLURAY

new_config.write()

Expand Down
54 changes: 46 additions & 8 deletions sickbeard/common.py
Expand Up @@ -21,6 +21,7 @@
import operator, platform
import re

from lib.configobj import ConfigObj
from sickbeard import version

USER_AGENT = 'Sick Beard/alpha2-'+version.SICKBEARD_VERSION+' ('+platform.system()+' '+platform.release()+')'
Expand Down Expand Up @@ -66,14 +67,51 @@ class Quality:
# put these bits at the other end of the spectrum, far enough out that they shouldn't interfere
UNKNOWN = 1<<15

qualityStrings = {NONE: "N/A",
UNKNOWN: "Unknown",
SDTV: "SD TV",
SDDVD: "SD DVD",
HDTV: "HD TV",
HDWEBDL: "720p WEB-DL",
HDBLURAY: "720p BluRay",
FULLHDBLURAY: "1080p BluRay"}
# load quality strings from config.ini

This comment has been minimized.

Copy link
@Smenus

Smenus Jan 27, 2011

Instead of loading here, can't you use the sickbeard.QUALITY_* things you set in the init?

qualityStrings = {NONE: sickbeard.QUALITY_NONE,
                    UNKNOWN: sickbeard.QUALITY_UNKNOWN,
                    ...

This comment has been minimized.

Copy link
@jconnop

jconnop Jan 27, 2011

Author Owner

That's what I tried first, however this code is run before those init values are set. It's not the most elegant, I know, but it only happens once per run (I assume) so performance impact is negligible.

This comment has been minimized.

Copy link
@Smenus

Smenus Jan 27, 2011

Ah yeah, I suppose it gets called when __init__.py imports it on line 38.

program_dir = os.path.dirname(os.path.normpath(os.path.abspath(__file__)))
configure_file = os.path.join(program_dir, "config.ini")
configure_obj = ConfigObj(configure_file)
try:
quality_none = configure_obj['CustomQuality']['quality_none']
except:
quality_none = "N/A"
try:
quality_unknown = configure_obj['CustomQuality']['quality_unknown']
except:
quality_unknown = "Unknown"
try:
quality_sdtv = configure_obj['CustomQuality']['quality_sdtv']
except:
quality_sdtv = "SD TV"
try:
quality_sddvd = configure_obj['CustomQuality']['quality_sddvd']
except:
quality_sddvd = "SD DVD"
try:
quality_hdtv = configure_obj['CustomQuality']['quality_hdtv']
except:
quality_hdtv = "HD TV"
try:
quality_hdwebdl = configure_obj['CustomQuality']['quality_hdwebdl']
except:
quality_hdwebdl = "720p WEB-DL"
try:
quality_hdbluray = configure_obj['CustomQuality']['quality_hdbluray']
except:
quality_hdbluray = "720p BluRay"
try:
quality_fullhdbluray = configure_obj['CustomQuality']['quality_fullhdbluray']
except:
quality_fullhdbluray = "1080p BluRay"

qualityStrings = {NONE: quality_none,
UNKNOWN: quality_unknown,
SDTV: quality_sdtv,
SDDVD: quality_sddvd,
HDTV: quality_hdtv,
HDWEBDL: quality_hdwebdl,
HDBLURAY: quality_hdbluray,
FULLHDBLURAY: quality_fullhdbluray}

statusPrefixes = {DOWNLOADED: "Downloaded",
SNATCHED: "Snatched"}
Expand Down

0 comments on commit c28b5c9

Please sign in to comment.