mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-16 16:45:32 +01:00
Rename headphones.CFG to headphones CONFIG
This commit is contained in:
@@ -144,25 +144,25 @@ def main():
|
||||
http_port = args.port
|
||||
logger.info('Using forced web server port: %i', http_port)
|
||||
else:
|
||||
http_port = int(headphones.CFG.HTTP_PORT)
|
||||
http_port = int(headphones.CONFIG.HTTP_PORT)
|
||||
|
||||
# Try to start the server. Will exit here is address is already in use.
|
||||
web_config = {
|
||||
'http_port': http_port,
|
||||
'http_host': headphones.CFG.HTTP_HOST,
|
||||
'http_root': headphones.CFG.HTTP_ROOT,
|
||||
'http_proxy': headphones.CFG.HTTP_PROXY,
|
||||
'enable_https': headphones.CFG.ENABLE_HTTPS,
|
||||
'https_cert': headphones.CFG.HTTPS_CERT,
|
||||
'https_key': headphones.CFG.HTTPS_KEY,
|
||||
'http_username': headphones.CFG.HTTP_USERNAME,
|
||||
'http_password': headphones.CFG.HTTP_PASSWORD,
|
||||
'http_host': headphones.CONFIG.HTTP_HOST,
|
||||
'http_root': headphones.CONFIG.HTTP_ROOT,
|
||||
'http_proxy': headphones.CONFIG.HTTP_PROXY,
|
||||
'enable_https': headphones.CONFIG.ENABLE_HTTPS,
|
||||
'https_cert': headphones.CONFIG.HTTPS_CERT,
|
||||
'https_key': headphones.CONFIG.HTTPS_KEY,
|
||||
'http_username': headphones.CONFIG.HTTP_USERNAME,
|
||||
'http_password': headphones.CONFIG.HTTP_PASSWORD,
|
||||
}
|
||||
webstart.initialize(web_config)
|
||||
|
||||
if headphones.CFG.LAUNCH_BROWSER and not args.nolaunch:
|
||||
headphones.launch_browser(headphones.CFG.HTTP_HOST, http_port,
|
||||
headphones.CFG.HTTP_ROOT)
|
||||
if headphones.CONFIG.LAUNCH_BROWSER and not args.nolaunch:
|
||||
headphones.launch_browser(headphones.CONFIG.HTTP_HOST, http_port,
|
||||
headphones.CONFIG.HTTP_ROOT)
|
||||
|
||||
# Start the background threads
|
||||
headphones.start()
|
||||
|
||||
@@ -163,17 +163,17 @@
|
||||
}
|
||||
|
||||
<%
|
||||
if headphones.CFG.SONGKICK_FILTER_ENABLED:
|
||||
if headphones.CONFIG.SONGKICK_FILTER_ENABLED:
|
||||
songkick_filter_enabled = "true"
|
||||
else:
|
||||
songkick_filter_enabled = "false"
|
||||
|
||||
if not headphones.CFG.SONGKICK_LOCATION:
|
||||
if not headphones.CONFIG.SONGKICK_LOCATION:
|
||||
songkick_location = "none"
|
||||
else:
|
||||
songkick_location = headphones.CFG.SONGKICK_LOCATION
|
||||
songkick_location = headphones.CONFIG.SONGKICK_LOCATION
|
||||
|
||||
if headphones.CFG.SONGKICK_ENABLED:
|
||||
if headphones.CONFIG.SONGKICK_ENABLED:
|
||||
songkick_enabled = "true"
|
||||
else:
|
||||
songkick_enabled = "false"
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
template = '<li><a target="_blank" href="URI"><span class="sk-name">NAME</span><span class="sk-location">LOC</span></a></li>';
|
||||
|
||||
$.getJSON("https://api.songkick.com/api/3.0/artists/mbid:${artist['ArtistID']}/calendar.json?apikey=${headphones.CFG.SONGKICK_APIKEY}&jsoncallback=?",
|
||||
$.getJSON("https://api.songkick.com/api/3.0/artists/mbid:${artist['ArtistID']}/calendar.json?apikey=${headphones.CONFIG.SONGKICK_APIKEY}&jsoncallback=?",
|
||||
function(data){
|
||||
if (data['resultsPage'].totalEntries >= 1) {
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</div>
|
||||
% elif headphones.CURRENT_VERSION != headphones.LATEST_VERSION and headphones.COMMITS_BEHIND > 0 and headphones.INSTALL_TYPE != 'win':
|
||||
<div id="updatebar">
|
||||
A <a href="https://github.com/${headphones.CFG.GIT_USER}/headphones/compare/${headphones.CURRENT_VERSION}...${headphones.LATEST_VERSION}"> newer version</a> is available. You're ${headphones.COMMITS_BEHIND} commits behind. <a href="update">Update</a> or <a href="#" onclick="$('#updatebar').slideUp('slow');">Close</a>
|
||||
A <a href="https://github.com/${headphones.CONFIG.GIT_USER}/headphones/compare/${headphones.CURRENT_VERSION}...${headphones.LATEST_VERSION}"> newer version</a> is available. You're ${headphones.COMMITS_BEHIND} commits behind. <a href="update">Update</a> or <a href="#" onclick="$('#updatebar').slideUp('slow');">Close</a>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
@@ -96,8 +96,8 @@
|
||||
%if version.HEADPHONES_VERSION != 'master':
|
||||
(${version.HEADPHONES_VERSION})
|
||||
%endif
|
||||
%if headphones.CFG.GIT_BRANCH != 'master':
|
||||
(${headphones.CFG.GIT_BRANCH})
|
||||
%if headphones.CONFIG.GIT_BRANCH != 'master':
|
||||
(${headphones.CONFIG.GIT_BRANCH})
|
||||
%endif
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -1320,7 +1320,7 @@
|
||||
<select name="interface"><h3>
|
||||
%for interface in config['interface_list']:
|
||||
<%
|
||||
if interface == headphones.CFG.INTERFACE:
|
||||
if interface == headphones.CONFIG.INTERFACE:
|
||||
selected = 'selected="selected"'
|
||||
else:
|
||||
selected = ''
|
||||
@@ -1369,7 +1369,7 @@
|
||||
<select name="mirror" id="mirror">
|
||||
%for mirror in config['mirror_list']:
|
||||
<%
|
||||
if mirror == headphones.CFG.MIRROR:
|
||||
if mirror == headphones.CONFIG.MIRROR:
|
||||
selected = 'selected="selected"'
|
||||
else:
|
||||
selected = ''
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<a class="menu_link_edit" href="manageArtists"><i class="fa fa-pencil"></i> Manage Artists</a>
|
||||
%if not headphones.CFG.AUTO_ADD_ARTISTS:
|
||||
%if not headphones.CONFIG.AUTO_ADD_ARTISTS:
|
||||
<a class="menu_link_edit" href="manageNew"><i class="fa fa-pencil"></i> Manage New Artists</a>
|
||||
%endif
|
||||
<a class="menu_link_edit" href="manageUnmatched"><i class="fa fa-pencil"></i> Manage Unmatched</a>
|
||||
@@ -53,18 +53,18 @@
|
||||
<br/>
|
||||
<div class="row">
|
||||
<label for="">Path to directory</label>
|
||||
%if headphones.CFG.MUSIC_DIR:
|
||||
<input type="text" value="${headphones.CFG.MUSIC_DIR}" name="path" size="70" />
|
||||
%if headphones.CONFIG.MUSIC_DIR:
|
||||
<input type="text" value="${headphones.CONFIG.MUSIC_DIR}" name="path" size="70" />
|
||||
%else:
|
||||
<input type="text" value="Enter a Music Directory to scan" onfocus="if
|
||||
(this.value==this.defaultValue) this.value='';" name="path" size="70" />
|
||||
%endif
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="libraryscan" id="libraryscan" value="1" ${checked(headphones.CFG.LIBRARYSCAN)}><label>Automatically scan library</label>
|
||||
<input type="checkbox" name="libraryscan" id="libraryscan" value="1" ${checked(headphones.CONFIG.LIBRARYSCAN)}><label>Automatically scan library</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="autoadd" id="autoadd" value="1" ${checked(headphones.CFG.AUTO_ADD_ARTISTS)}><label>Auto-add new artists</label>
|
||||
<input type="checkbox" name="autoadd" id="autoadd" value="1" ${checked(headphones.CONFIG.AUTO_ADD_ARTISTS)}><label>Auto-add new artists</label>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
@@ -83,8 +83,8 @@
|
||||
<div class="row">
|
||||
<label for="">Username</label>
|
||||
<%
|
||||
if headphones.CFG.LASTFM_USERNAME:
|
||||
lastfmvalue = headphones.CFG.LASTFM_USERNAME
|
||||
if headphones.CONFIG.LASTFM_USERNAME:
|
||||
lastfmvalue = headphones.CONFIG.LASTFM_USERNAME
|
||||
else:
|
||||
lastfmvalue = ''
|
||||
%>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<%def name="headerIncludes()">
|
||||
<div id="subhead_container">
|
||||
<div id="subhead_menu">
|
||||
<a id="menu_link_scan" onclick="doAjaxCall('musicScan?path=${headphones.CFG.MUSIC_DIR}&redirect=manageNew',$(this))" data-success="Music library is getting scanned">Scan Music Library</a>
|
||||
<a id="menu_link_scan" onclick="doAjaxCall('musicScan?path=${headphones.CONFIG.MUSIC_DIR}&redirect=manageNew',$(this))" data-success="Music library is getting scanned">Scan Music Library</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="manage" class="back">« Back to manage overview</a>
|
||||
|
||||
@@ -27,8 +27,6 @@ import cherrypy
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from apscheduler.triggers.interval import IntervalTrigger
|
||||
|
||||
from configobj import ConfigObj
|
||||
|
||||
from headphones import versioncheck, logger, version
|
||||
import headphones.config
|
||||
from headphones.common import *
|
||||
@@ -73,7 +71,7 @@ started = False
|
||||
|
||||
DATA_DIR = None
|
||||
|
||||
CFG = None
|
||||
CONFIG = None
|
||||
|
||||
DB_FILE = None
|
||||
|
||||
@@ -96,33 +94,33 @@ def initialize(config_file):
|
||||
|
||||
with INIT_LOCK:
|
||||
|
||||
global CFG
|
||||
global CONFIG
|
||||
global __INITIALIZED__
|
||||
global EXTRA_NEWZNABS
|
||||
global LATEST_VERSION
|
||||
|
||||
CFG = headphones.config.Config(config_file)
|
||||
CONFIG = headphones.config.Config(config_file)
|
||||
|
||||
assert CFG is not None
|
||||
assert CONFIG is not None
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
|
||||
if CFG.HTTP_PORT < 21 or CFG.HTTP_PORT > 65535:
|
||||
headphones.logger.warn('HTTP_PORT out of bounds: 21 < %s < 65535', CFG.HTTP_PORT)
|
||||
CFG.HTTP_PORT = 8181
|
||||
if CONFIG.HTTP_PORT < 21 or CONFIG.HTTP_PORT > 65535:
|
||||
headphones.logger.warn('HTTP_PORT out of bounds: 21 < %s < 65535', CONFIG.HTTP_PORT)
|
||||
CONFIG.HTTP_PORT = 8181
|
||||
|
||||
if CFG.HTTPS_CERT == '':
|
||||
CFG.HTTPS_CERT = os.path.join(DATA_DIR, 'server.crt')
|
||||
if CFG.HTTPS_KEY == '':
|
||||
CFG.HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
|
||||
if CONFIG.HTTPS_CERT == '':
|
||||
CONFIG.HTTPS_CERT = os.path.join(DATA_DIR, 'server.crt')
|
||||
if CONFIG.HTTPS_KEY == '':
|
||||
CONFIG.HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
|
||||
|
||||
if not CFG.LOG_DIR:
|
||||
CFG.LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||
if not CONFIG.LOG_DIR:
|
||||
CONFIG.LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||
|
||||
if not os.path.exists(CFG.LOG_DIR):
|
||||
if not os.path.exists(CONFIG.LOG_DIR):
|
||||
try:
|
||||
os.makedirs(CFG.LOG_DIR)
|
||||
os.makedirs(CONFIG.LOG_DIR)
|
||||
except OSError:
|
||||
if VERBOSE:
|
||||
sys.stderr.write('Unable to create the log directory. Logging to screen only.\n')
|
||||
@@ -130,19 +128,19 @@ def initialize(config_file):
|
||||
# Start the logger, disable console if needed
|
||||
logger.initLogger(console=not QUIET, verbose=VERBOSE)
|
||||
|
||||
if not CFG.CACHE_DIR:
|
||||
if not CONFIG.CACHE_DIR:
|
||||
# Put the cache dir in the data dir for now
|
||||
CFG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
|
||||
if not os.path.exists(CFG.CACHE_DIR):
|
||||
CONFIG.CACHE_DIR = os.path.join(DATA_DIR, 'cache')
|
||||
if not os.path.exists(CONFIG.CACHE_DIR):
|
||||
try:
|
||||
os.makedirs(CFG.CACHE_DIR)
|
||||
os.makedirs(CONFIG.CACHE_DIR)
|
||||
except OSError:
|
||||
logger.error('Could not create cache dir. Check permissions of datadir: %s', DATA_DIR)
|
||||
|
||||
# Sanity check for search interval. Set it to at least 6 hours
|
||||
if CFG.SEARCH_INTERVAL < 360:
|
||||
if CONFIG.SEARCH_INTERVAL < 360:
|
||||
logger.info("Search interval too low. Resetting to 6 hour minimum")
|
||||
CFG.SEARCH_INTERVAL = 360
|
||||
CONFIG.SEARCH_INTERVAL = 360
|
||||
|
||||
# Initialize the database
|
||||
logger.info('Checking to see if the database has all tables....')
|
||||
@@ -153,10 +151,10 @@ def initialize(config_file):
|
||||
|
||||
# Get the currently installed version - returns None, 'win32' or the git hash
|
||||
# Also sets INSTALL_TYPE variable to 'win', 'git' or 'source'
|
||||
CURRENT_VERSION, CFG.GIT_BRANCH = versioncheck.getVersion()
|
||||
CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion()
|
||||
|
||||
# Check for new versions
|
||||
if CFG.CHECK_GITHUB_ON_STARTUP:
|
||||
if CONFIG.CHECK_GITHUB_ON_STARTUP:
|
||||
try:
|
||||
LATEST_VERSION = versioncheck.checkGithub()
|
||||
except:
|
||||
@@ -228,7 +226,7 @@ def launch_browser(host, port, root):
|
||||
if host == '0.0.0.0':
|
||||
host = 'localhost'
|
||||
|
||||
if CFG.ENABLE_HTTPS:
|
||||
if CONFIG.ENABLE_HTTPS:
|
||||
protocol = 'https'
|
||||
else:
|
||||
protocol = 'http'
|
||||
@@ -247,19 +245,19 @@ def start():
|
||||
|
||||
# Start our scheduled background tasks
|
||||
from headphones import updater, searcher, librarysync, postprocessor, torrentfinished
|
||||
SCHED.add_job(updater.dbUpdate, trigger=IntervalTrigger(hours=CFG.UPDATE_DB_INTERVAL))
|
||||
SCHED.add_job(searcher.searchforalbum, trigger=IntervalTrigger(minutes=CFG.SEARCH_INTERVAL))
|
||||
SCHED.add_job(librarysync.libraryScan, trigger=IntervalTrigger(hours=CFG.LIBRARYSCAN_INTERVAL))
|
||||
SCHED.add_job(updater.dbUpdate, trigger=IntervalTrigger(hours=CONFIG.UPDATE_DB_INTERVAL))
|
||||
SCHED.add_job(searcher.searchforalbum, trigger=IntervalTrigger(minutes=CONFIG.SEARCH_INTERVAL))
|
||||
SCHED.add_job(librarysync.libraryScan, trigger=IntervalTrigger(hours=CONFIG.LIBRARYSCAN_INTERVAL))
|
||||
|
||||
if CFG.CHECK_GITHUB:
|
||||
SCHED.add_job(versioncheck.checkGithub, trigger=IntervalTrigger(minutes=CFG.CHECK_GITHUB_INTERVAL))
|
||||
if CONFIG.CHECK_GITHUB:
|
||||
SCHED.add_job(versioncheck.checkGithub, trigger=IntervalTrigger(minutes=CONFIG.CHECK_GITHUB_INTERVAL))
|
||||
|
||||
if CFG.DOWNLOAD_SCAN_INTERVAL > 0:
|
||||
SCHED.add_job(postprocessor.checkFolder, trigger=IntervalTrigger(minutes=CFG.DOWNLOAD_SCAN_INTERVAL))
|
||||
if CONFIG.DOWNLOAD_SCAN_INTERVAL > 0:
|
||||
SCHED.add_job(postprocessor.checkFolder, trigger=IntervalTrigger(minutes=CONFIG.DOWNLOAD_SCAN_INTERVAL))
|
||||
|
||||
# Remove Torrent + data if Post Processed and finished Seeding
|
||||
if CFG.TORRENT_REMOVAL_INTERVAL > 0:
|
||||
SCHED.add_job(torrentfinished.checkTorrentFinished, trigger=IntervalTrigger(minutes=CFG.TORRENT_REMOVAL_INTERVAL))
|
||||
if CONFIG.TORRENT_REMOVAL_INTERVAL > 0:
|
||||
SCHED.add_job(torrentfinished.checkTorrentFinished, trigger=IntervalTrigger(minutes=CONFIG.TORRENT_REMOVAL_INTERVAL))
|
||||
|
||||
SCHED.start()
|
||||
|
||||
@@ -476,7 +474,7 @@ def shutdown(restart=False, update=False):
|
||||
cherrypy.engine.exit()
|
||||
SCHED.shutdown(wait=False)
|
||||
|
||||
CFG.write()
|
||||
CONFIG.write()
|
||||
|
||||
if not restart and not update:
|
||||
logger.info('Headphones is shutting down...')
|
||||
|
||||
@@ -67,7 +67,7 @@ def switch(AlbumID, ReleaseID):
|
||||
total_track_count = len(newtrackdata)
|
||||
have_track_count = len(myDB.select('SELECT * from tracks WHERE AlbumID=? AND Location IS NOT NULL', [AlbumID]))
|
||||
|
||||
if oldalbumdata['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CFG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if oldalbumdata['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CONFIG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', AlbumID])
|
||||
|
||||
# Update have track counts on index
|
||||
|
||||
@@ -44,13 +44,13 @@ class Api(object):
|
||||
|
||||
def checkParams(self,*args,**kwargs):
|
||||
|
||||
if not headphones.CFG.API_ENABLED:
|
||||
if not headphones.CONFIG.API_ENABLED:
|
||||
self.data = 'API not enabled'
|
||||
return
|
||||
if not headphones.CFG.API_KEY:
|
||||
if not headphones.CONFIG.API_KEY:
|
||||
self.data = 'API key not generated'
|
||||
return
|
||||
if len(headphones.CFG.API_KEY) != 32:
|
||||
if len(headphones.CONFIG.API_KEY) != 32:
|
||||
self.data = 'API key not generated correctly'
|
||||
return
|
||||
|
||||
@@ -58,7 +58,7 @@ class Api(object):
|
||||
self.data = 'Missing api key'
|
||||
return
|
||||
|
||||
if kwargs['apikey'] != headphones.CFG.API_KEY:
|
||||
if kwargs['apikey'] != headphones.CONFIG.API_KEY:
|
||||
self.data = 'Incorrect API key'
|
||||
return
|
||||
else:
|
||||
@@ -314,7 +314,7 @@ class Api(object):
|
||||
|
||||
def _getVersion(self, **kwargs):
|
||||
self.data = {
|
||||
'git_path' : headphones.CFG.GIT_PATH,
|
||||
'git_path' : headphones.CONFIG.GIT_PATH,
|
||||
'install_type' : headphones.INSTALL_TYPE,
|
||||
'current_version' : headphones.CURRENT_VERSION,
|
||||
'latest_version' : headphones.LATEST_VERSION,
|
||||
|
||||
@@ -40,7 +40,7 @@ class Cache(object):
|
||||
and for info it is <musicbrainzid>.<date>.txt
|
||||
"""
|
||||
|
||||
path_to_art_cache = os.path.join(headphones.CFG.CACHE_DIR, 'artwork')
|
||||
path_to_art_cache = os.path.join(headphones.CONFIG.CACHE_DIR, 'artwork')
|
||||
|
||||
def __init__(self):
|
||||
self.id = None
|
||||
|
||||
@@ -34,10 +34,10 @@ def dbFilename(filename="headphones.db"):
|
||||
|
||||
def getCacheSize():
|
||||
#this will protect against typecasting problems produced by empty string and None settings
|
||||
if not headphones.CFG.CACHE_SIZEMB:
|
||||
if not headphones.CONFIG.CACHE_SIZEMB:
|
||||
#sqlite will work with this (very slowly)
|
||||
return 0
|
||||
return int(headphones.CFG.CACHE_SIZEMB)
|
||||
return int(headphones.CONFIG.CACHE_SIZEMB)
|
||||
|
||||
class DBConnection:
|
||||
|
||||
@@ -48,7 +48,7 @@ class DBConnection:
|
||||
#don't wait for the disk to finish writing
|
||||
self.connection.execute("PRAGMA synchronous = OFF")
|
||||
#journal disabled since we never do rollbacks
|
||||
self.connection.execute("PRAGMA journal_mode = %s" % headphones.CFG.JOURNAL_MODE)
|
||||
self.connection.execute("PRAGMA journal_mode = %s" % headphones.CONFIG.JOURNAL_MODE)
|
||||
#64mb of cache memory,probably need to make it user configurable
|
||||
self.connection.execute("PRAGMA cache_size=-%s" % (getCacheSize()*1024))
|
||||
self.connection.row_factory = sqlite3.Row
|
||||
|
||||
@@ -460,11 +460,11 @@ def extract_logline(s):
|
||||
def extract_song_data(s):
|
||||
|
||||
#headphones default format
|
||||
music_dir = headphones.CFG.MUSIC_DIR
|
||||
folder_format = headphones.CFG.FOLDER_FORMAT
|
||||
file_format = headphones.CFG.FILE_FORMAT
|
||||
music_dir = headphones.CONFIG.MUSIC_DIR
|
||||
folder_format = headphones.CONFIG.FOLDER_FORMAT
|
||||
file_format = headphones.CONFIG.FILE_FORMAT
|
||||
|
||||
full_format = os.path.join(headphones.CFG.MUSIC_DIR)
|
||||
full_format = os.path.join(headphones.CONFIG.MUSIC_DIR)
|
||||
pattern = re.compile(r'(?P<name>.*?)\s\-\s(?P<album>.*?)\s\[(?P<year>.*?)\]', re.VERBOSE)
|
||||
match = pattern.match(s)
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
if not dbartist:
|
||||
newValueDict = {"ArtistName": "Artist ID: %s" % (artistid),
|
||||
"Status": "Loading",
|
||||
"IncludeExtras": headphones.CFG.INCLUDE_EXTRAS,
|
||||
"Extras": headphones.CFG.EXTRAS }
|
||||
"IncludeExtras": headphones.CONFIG.INCLUDE_EXTRAS,
|
||||
"Extras": headphones.CONFIG.EXTRAS }
|
||||
else:
|
||||
newValueDict = {"Status": "Loading"}
|
||||
|
||||
@@ -227,7 +227,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
rgid = rg['id']
|
||||
skip_log = 0
|
||||
#Make a user configurable variable to skip update of albums with release dates older than this date (in days)
|
||||
pause_delta = headphones.CFG.MB_IGNORE_AGE
|
||||
pause_delta = headphones.CONFIG.MB_IGNORE_AGE
|
||||
|
||||
rg_exists = myDB.action("SELECT * from albums WHERE AlbumID=?", [rg['id']]).fetchone()
|
||||
|
||||
@@ -414,13 +414,13 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
|
||||
newValueDict['DateAdded'] = today
|
||||
|
||||
if headphones.CFG.AUTOWANT_ALL:
|
||||
if headphones.CONFIG.AUTOWANT_ALL:
|
||||
newValueDict['Status'] = "Wanted"
|
||||
elif album['ReleaseDate'] > today and headphones.CFG.AUTOWANT_UPCOMING:
|
||||
elif album['ReleaseDate'] > today and headphones.CONFIG.AUTOWANT_UPCOMING:
|
||||
newValueDict['Status'] = "Wanted"
|
||||
# Sometimes "new" albums are added to musicbrainz after their release date, so let's try to catch these
|
||||
# The first test just makes sure we have year-month-day
|
||||
elif helpers.get_age(album['ReleaseDate']) and helpers.get_age(today) - helpers.get_age(album['ReleaseDate']) < 21 and headphones.CFG.AUTOWANT_UPCOMING:
|
||||
elif helpers.get_age(album['ReleaseDate']) and helpers.get_age(today) - helpers.get_age(album['ReleaseDate']) < 21 and headphones.CONFIG.AUTOWANT_UPCOMING:
|
||||
newValueDict['Status'] = "Wanted"
|
||||
else:
|
||||
newValueDict['Status'] = "Skipped"
|
||||
@@ -464,11 +464,11 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
marked_as_downloaded = False
|
||||
|
||||
if rg_exists:
|
||||
if rg_exists['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CFG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if rg_exists['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CONFIG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']])
|
||||
marked_as_downloaded = True
|
||||
else:
|
||||
if ((have_track_count/float(total_track_count)) >= (headphones.CFG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if ((have_track_count/float(total_track_count)) >= (headphones.CONFIG.ALBUM_COMPLETION_PCT/100.0)):
|
||||
myDB.action('UPDATE albums SET Status=? WHERE AlbumID=?', ['Downloaded', rg['id']])
|
||||
marked_as_downloaded = True
|
||||
|
||||
@@ -478,7 +478,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False):
|
||||
# Start a search for the album if it's new, hasn't been marked as
|
||||
# downloaded and autowant_all is selected. This search is deferred,
|
||||
# in case the search failes and the rest of the import will halt.
|
||||
if not rg_exists and not marked_as_downloaded and headphones.CFG.AUTOWANT_ALL:
|
||||
if not rg_exists and not marked_as_downloaded and headphones.CONFIG.AUTOWANT_ALL:
|
||||
album_searches.append(rg['id'])
|
||||
else:
|
||||
if skip_log == 0:
|
||||
@@ -596,9 +596,9 @@ def addReleaseById(rid, rgid=None):
|
||||
"DateAdded": helpers.today(),
|
||||
"Status": "Paused"}
|
||||
|
||||
if headphones.CFG.INCLUDE_EXTRAS:
|
||||
if headphones.CONFIG.INCLUDE_EXTRAS:
|
||||
newValueDict['IncludeExtras'] = 1
|
||||
newValueDict['Extras'] = headphones.CFG.EXTRAS
|
||||
newValueDict['Extras'] = headphones.CONFIG.EXTRAS
|
||||
|
||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||
|
||||
@@ -670,14 +670,14 @@ def addReleaseById(rid, rgid=None):
|
||||
# Reset status
|
||||
if status == 'Loading':
|
||||
controlValueDict = {"AlbumID": rgid}
|
||||
if headphones.CFG.AUTOWANT_MANUALLY_ADDED:
|
||||
if headphones.CONFIG.AUTOWANT_MANUALLY_ADDED:
|
||||
newValueDict = {"Status": "Wanted"}
|
||||
else:
|
||||
newValueDict = {"Status": "Skipped"}
|
||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||
|
||||
# Start a search for the album
|
||||
if headphones.CFG.AUTOWANT_MANUALLY_ADDED:
|
||||
if headphones.CONFIG.AUTOWANT_MANUALLY_ADDED:
|
||||
import searcher
|
||||
searcher.searchforalbum(rgid, False)
|
||||
|
||||
|
||||
@@ -111,12 +111,12 @@ def getArtists():
|
||||
myDB = db.DBConnection()
|
||||
results = myDB.select("SELECT ArtistID from artists")
|
||||
|
||||
if not headphones.CFG.LASTFM_USERNAME:
|
||||
if not headphones.CONFIG.LASTFM_USERNAME:
|
||||
logger.warn("Last.FM username not set, not importing artists.")
|
||||
return
|
||||
|
||||
logger.info("Fetching artists from Last.FM for username: %s", headphones.CFG.LASTFM_USERNAME)
|
||||
data = request_lastfm("library.getartists", limit=10000, user=headphones.CFG.LASTFM_USERNAME)
|
||||
logger.info("Fetching artists from Last.FM for username: %s", headphones.CONFIG.LASTFM_USERNAME)
|
||||
data = request_lastfm("library.getartists", limit=10000, user=headphones.CONFIG.LASTFM_USERNAME)
|
||||
|
||||
if data and "artists" in data:
|
||||
artistlist = []
|
||||
|
||||
@@ -25,14 +25,14 @@ from headphones import db, logger, helpers, importer, lastfm
|
||||
def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=False):
|
||||
|
||||
|
||||
if cron and not headphones.CFG.LIBRARYSCAN:
|
||||
if cron and not headphones.CONFIG.LIBRARYSCAN:
|
||||
return
|
||||
|
||||
if not dir:
|
||||
if not headphones.CFG.MUSIC_DIR:
|
||||
if not headphones.CONFIG.MUSIC_DIR:
|
||||
return
|
||||
else:
|
||||
dir = headphones.CFG.MUSIC_DIR
|
||||
dir = headphones.CONFIG.MUSIC_DIR
|
||||
|
||||
# If we're appending a dir, it's coming from the post processor which is
|
||||
# already bytestring
|
||||
@@ -318,7 +318,7 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
logger.info('Found %i new artists' % len(artist_list))
|
||||
|
||||
if len(artist_list):
|
||||
if headphones.CFG.AUTO_ADD_ARTISTS:
|
||||
if headphones.CONFIG.AUTO_ADD_ARTISTS:
|
||||
logger.info('Importing %i new artists' % len(artist_list))
|
||||
importer.artistlist_to_mbids(artist_list)
|
||||
else:
|
||||
@@ -327,8 +327,8 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
for artist in artist_list:
|
||||
myDB.action('INSERT OR IGNORE INTO newartists VALUES (?)', [artist])
|
||||
|
||||
if headphones.CFG.DETECT_BITRATE:
|
||||
headphones.CFG.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
if headphones.CONFIG.DETECT_BITRATE:
|
||||
headphones.CONFIG.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
|
||||
else:
|
||||
# If we're appending a new album to the database, update the artists total track counts
|
||||
@@ -364,7 +364,7 @@ def update_album_status(AlbumID=None):
|
||||
album_completion = 0
|
||||
logger.info('Album %s does not have any tracks in database' % album['AlbumTitle'])
|
||||
|
||||
if album_completion >= headphones.CFG.ALBUM_COMPLETION_PCT and album['Status'] == 'Skipped':
|
||||
if album_completion >= headphones.CONFIG.ALBUM_COMPLETION_PCT and album['Status'] == 'Skipped':
|
||||
new_album_status = "Downloaded"
|
||||
|
||||
# I don't think we want to change Downloaded->Skipped.....
|
||||
|
||||
@@ -136,7 +136,7 @@ def initLogger(console=False, verbose=False):
|
||||
logger.setLevel(logging.DEBUG if verbose else logging.INFO)
|
||||
|
||||
# Setup file logger
|
||||
filename = os.path.join(headphones.CFG.LOG_DIR, FILENAME)
|
||||
filename = os.path.join(headphones.CONFIG.LOG_DIR, FILENAME)
|
||||
|
||||
file_formatter = logging.Formatter('%(asctime)s - %(levelname)-7s :: %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
|
||||
file_handler = handlers.RotatingFileHandler(filename, maxBytes=MAX_SIZE, backupCount=MAX_FILES)
|
||||
|
||||
@@ -37,19 +37,19 @@ def startmb():
|
||||
mbuser = None
|
||||
mbpass = None
|
||||
|
||||
if headphones.CFG.MIRROR == "musicbrainz.org":
|
||||
if headphones.CONFIG.MIRROR == "musicbrainz.org":
|
||||
mbhost = "musicbrainz.org"
|
||||
mbport = 80
|
||||
sleepytime = 1
|
||||
elif headphones.CFG.MIRROR == "custom":
|
||||
mbhost = headphones.CFG.CUSTOMHOST
|
||||
mbport = int(headphones.CFG.CUSTOMPORT)
|
||||
sleepytime = int(headphones.CFG.CUSTOMSLEEP)
|
||||
elif headphones.CFG.MIRROR == "headphones":
|
||||
elif headphones.CONFIG.MIRROR == "custom":
|
||||
mbhost = headphones.CONFIG.CUSTOMHOST
|
||||
mbport = int(headphones.CONFIG.CUSTOMPORT)
|
||||
sleepytime = int(headphones.CONFIG.CUSTOMSLEEP)
|
||||
elif headphones.CONFIG.MIRROR == "headphones":
|
||||
mbhost = "144.76.94.239"
|
||||
mbport = 8181
|
||||
mbuser = headphones.CFG.HPUSER
|
||||
mbpass = headphones.CFG.HPPASS
|
||||
mbuser = headphones.CONFIG.HPUSER
|
||||
mbpass = headphones.CONFIG.HPPASS
|
||||
sleepytime = 0
|
||||
else:
|
||||
return False
|
||||
@@ -63,7 +63,7 @@ def startmb():
|
||||
musicbrainzngs.set_rate_limit(limit_or_interval=float(sleepytime))
|
||||
|
||||
# Add headphones credentials
|
||||
if headphones.CFG.MIRROR == "headphones":
|
||||
if headphones.CONFIG.MIRROR == "headphones":
|
||||
if not mbuser and mbpass:
|
||||
logger.warn("No username or password set for VIP server")
|
||||
else:
|
||||
|
||||
@@ -24,7 +24,7 @@ from headphones import logger
|
||||
from beets.mediafile import MediaFile
|
||||
|
||||
# xld
|
||||
if headphones.CFG.ENCODER == 'xld':
|
||||
if headphones.CONFIG.ENCODER == 'xld':
|
||||
import getXldProfile
|
||||
XLD = True
|
||||
else:
|
||||
@@ -35,7 +35,7 @@ def encode(albumPath):
|
||||
# Return if xld details not found
|
||||
if XLD:
|
||||
global xldProfile
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CFG.XLDPROFILE)
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CONFIG.XLDPROFILE)
|
||||
if not xldFormat:
|
||||
logger.error('Details for xld profile \'%s\' not found, files will not be re-encoded', xldProfile)
|
||||
return None
|
||||
@@ -61,13 +61,13 @@ def encode(albumPath):
|
||||
for music in f:
|
||||
if any(music.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS):
|
||||
if not XLD:
|
||||
encoderFormat = headphones.CFG.ENCODEROUTPUTFORMAT.encode(headphones.SYS_ENCODING)
|
||||
encoderFormat = headphones.CONFIG.ENCODEROUTPUTFORMAT.encode(headphones.SYS_ENCODING)
|
||||
else:
|
||||
xldMusicFile = os.path.join(r, music)
|
||||
xldInfoMusic = MediaFile(xldMusicFile)
|
||||
encoderFormat = xldFormat
|
||||
|
||||
if (headphones.CFG.ENCODERLOSSLESS):
|
||||
if (headphones.CONFIG.ENCODERLOSSLESS):
|
||||
ext = os.path.normpath(os.path.splitext(music)[1].lstrip(".")).lower()
|
||||
if not XLD and ext == 'flac' or XLD and (ext != xldFormat and (xldInfoMusic.bitrate / 1000 > 400)):
|
||||
musicFiles.append(os.path.join(r, music))
|
||||
@@ -80,23 +80,23 @@ def encode(albumPath):
|
||||
musicTemp = os.path.normpath(os.path.splitext(music)[0] + '.' + encoderFormat)
|
||||
musicTempFiles.append(os.path.join(tempDirEncode, musicTemp))
|
||||
|
||||
if headphones.CFG.ENCODER_PATH:
|
||||
encoder = headphones.CFG.ENCODER_PATH.encode(headphones.SYS_ENCODING)
|
||||
if headphones.CONFIG.ENCODER_PATH:
|
||||
encoder = headphones.CONFIG.ENCODER_PATH.encode(headphones.SYS_ENCODING)
|
||||
else:
|
||||
if XLD:
|
||||
encoder = os.path.join('/Applications', 'xld')
|
||||
elif headphones.CFG.ENCODER =='lame':
|
||||
elif headphones.CONFIG.ENCODER =='lame':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
## NEED THE DEFAULT LAME INSTALL ON WIN!
|
||||
encoder = "C:/Program Files/lame/lame.exe"
|
||||
else:
|
||||
encoder="lame"
|
||||
elif headphones.CFG.ENCODER =='ffmpeg':
|
||||
elif headphones.CONFIG.ENCODER =='ffmpeg':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
encoder = "C:/Program Files/ffmpeg/bin/ffmpeg.exe"
|
||||
else:
|
||||
encoder="ffmpeg"
|
||||
elif headphones.CFG.ENCODER == 'libav':
|
||||
elif headphones.CONFIG.ENCODER == 'libav':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
encoder = "C:/Program Files/libav/bin/avconv.exe"
|
||||
else:
|
||||
@@ -115,23 +115,23 @@ def encode(albumPath):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music.decode(headphones.SYS_ENCODING, 'replace'), xldBitrate)
|
||||
else:
|
||||
encode = True
|
||||
elif headphones.CFG.ENCODER == 'lame':
|
||||
elif headphones.CONFIG.ENCODER == 'lame':
|
||||
if not any(music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.' + x) for x in ["mp3", "wav"]):
|
||||
logger.warn('Lame cannot encode %s format for %s, use ffmpeg', os.path.splitext(music)[1], music)
|
||||
else:
|
||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.mp3') and (int(infoMusic.bitrate / 1000) <= headphones.CFG.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CFG.BITRATE)
|
||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.mp3') and (int(infoMusic.bitrate / 1000) <= headphones.CONFIG.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE)
|
||||
else:
|
||||
encode = True
|
||||
else:
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.ogg'):
|
||||
logger.warn('Cannot re-encode .ogg %s', music.decode(headphones.SYS_ENCODING, 'replace'))
|
||||
else:
|
||||
encode = True
|
||||
elif (headphones.CFG.ENCODEROUTPUTFORMAT=='mp3' or headphones.CFG.ENCODEROUTPUTFORMAT=='m4a'):
|
||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.'+headphones.CFG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000 ) <= headphones.CFG.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CFG.BITRATE)
|
||||
elif (headphones.CONFIG.ENCODEROUTPUTFORMAT=='mp3' or headphones.CONFIG.ENCODEROUTPUTFORMAT=='m4a'):
|
||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.'+headphones.CONFIG.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000 ) <= headphones.CONFIG.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.CONFIG.BITRATE)
|
||||
else:
|
||||
encode = True
|
||||
# encode
|
||||
@@ -149,11 +149,11 @@ def encode(albumPath):
|
||||
processes = 1
|
||||
|
||||
# Use multicore if enabled
|
||||
if headphones.CFG.ENCODER_MULTICORE:
|
||||
if headphones.CFG.ENCODER_MULTICORE_COUNT == 0:
|
||||
if headphones.CONFIG.ENCODER_MULTICORE:
|
||||
if headphones.CONFIG.ENCODER_MULTICORE_COUNT == 0:
|
||||
processes = multiprocessing.cpu_count()
|
||||
else:
|
||||
processes = headphones.CFG.ENCODER_MULTICORE_COUNT
|
||||
processes = headphones.CONFIG.ENCODER_MULTICORE_COUNT
|
||||
|
||||
logger.debug("Multi-core encoding enabled, spawning %d processes",
|
||||
processes)
|
||||
@@ -194,7 +194,7 @@ def encode(albumPath):
|
||||
for dest in musicTempFiles:
|
||||
if os.path.exists(dest):
|
||||
source = musicFiles[i]
|
||||
if headphones.CFG.DELETE_LOSSLESS_FILES:
|
||||
if headphones.CONFIG.DELETE_LOSSLESS_FILES:
|
||||
os.remove(source)
|
||||
check_dest = os.path.join(albumPath, os.path.split(dest)[1])
|
||||
if os.path.exists(check_dest):
|
||||
@@ -212,7 +212,7 @@ def encode(albumPath):
|
||||
|
||||
# Return with error if any encoding errors
|
||||
if encoder_failed:
|
||||
logger.error("One or more files failed to encode. Ensure you have the latest version of %s installed.", headphones.CFG.ENCODER)
|
||||
logger.error("One or more files failed to encode. Ensure you have the latest version of %s installed.", headphones.CONFIG.ENCODER)
|
||||
return None
|
||||
|
||||
time.sleep(1)
|
||||
@@ -263,17 +263,17 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
cmd.extend([xldDestDir])
|
||||
|
||||
# Lame
|
||||
elif headphones.CFG.ENCODER == 'lame':
|
||||
elif headphones.CONFIG.ENCODER == 'lame':
|
||||
cmd = [encoder]
|
||||
opts = []
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
opts.extend(['-h'])
|
||||
if headphones.CFG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['--resample', str(headphones.CFG.SAMPLINGFREQUENCY), '-b', str(headphones.CFG.BITRATE)])
|
||||
elif headphones.CFG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-v', str(headphones.CFG.ENCODERQUALITY)])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['--resample', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-b', str(headphones.CONFIG.BITRATE)])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-v', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
else:
|
||||
advanced = (headphones.CFG.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CONFIG.ADVANCEDENCODER.split())
|
||||
for tok in advanced:
|
||||
opts.extend([tok.encode(headphones.SYS_ENCODING)])
|
||||
opts.extend([musicSource])
|
||||
@@ -281,42 +281,42 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
cmd.extend(opts)
|
||||
|
||||
# FFmpeg
|
||||
elif headphones.CFG.ENCODER == 'ffmpeg':
|
||||
elif headphones.CONFIG.ENCODER == 'ffmpeg':
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.CFG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.CFG.SAMPLINGFREQUENCY), '-ab', str(headphones.CFG.BITRATE) + 'k'])
|
||||
elif headphones.CFG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.CFG.ENCODERQUALITY)])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-ab', str(headphones.CONFIG.BITRATE) + 'k'])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
advanced = (headphones.CFG.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CONFIG.ADVANCEDENCODER.split())
|
||||
for tok in advanced:
|
||||
opts.extend([tok.encode(headphones.SYS_ENCODING)])
|
||||
opts.extend([musicDest])
|
||||
cmd.extend(opts)
|
||||
|
||||
# Libav
|
||||
elif headphones.CFG.ENCODER == "libav":
|
||||
elif headphones.CONFIG.ENCODER == "libav":
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if not headphones.CONFIG.ADVANCEDENCODER:
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CONFIG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.CFG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.CFG.SAMPLINGFREQUENCY), '-ab', str(headphones.CFG.BITRATE) + 'k'])
|
||||
elif headphones.CFG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.CFG.ENCODERQUALITY)])
|
||||
if headphones.CONFIG.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.CONFIG.SAMPLINGFREQUENCY), '-ab', str(headphones.CONFIG.BITRATE) + 'k'])
|
||||
elif headphones.CONFIG.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.CONFIG.ENCODERQUALITY)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
advanced = (headphones.CFG.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CONFIG.ADVANCEDENCODER.split())
|
||||
for tok in advanced:
|
||||
opts.extend([tok.encode(headphones.SYS_ENCODING)])
|
||||
opts.extend([musicDest])
|
||||
@@ -339,7 +339,7 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
process = subprocess.Popen(cmd, startupinfo=startupinfo,
|
||||
stdin=open(os.devnull, 'rb'), stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate(headphones.CFG.ENCODER)
|
||||
stdout, stderr = process.communicate(headphones.CONFIG.ENCODER)
|
||||
|
||||
# Error if return code not zero
|
||||
if process.returncode:
|
||||
@@ -347,7 +347,7 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
out = stdout if stdout else stderr
|
||||
out = out.decode(headphones.SYS_ENCODING, 'replace')
|
||||
outlast2lines = '\n'.join(out.splitlines()[-2:])
|
||||
logger.error('%s error details: %s' % (headphones.CFG.ENCODER, outlast2lines))
|
||||
logger.error('%s error details: %s' % (headphones.CONFIG.ENCODER, outlast2lines))
|
||||
out = out.rstrip("\n")
|
||||
logger.debug(out)
|
||||
encoded = False
|
||||
|
||||
@@ -45,9 +45,9 @@ class GROWL(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.CFG.GROWL_ENABLED
|
||||
self.host = headphones.CFG.GROWL_HOST
|
||||
self.password = headphones.CFG.GROWL_PASSWORD
|
||||
self.enabled = headphones.CONFIG.GROWL_ENABLED
|
||||
self.host = headphones.CONFIG.GROWL_HOST
|
||||
self.password = headphones.CONFIG.GROWL_PASSWORD
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('Growl', options)
|
||||
@@ -130,24 +130,24 @@ class PROWL(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.CFG.PROWL_ENABLED
|
||||
self.keys = headphones.CFG.PROWL_KEYS
|
||||
self.priority = headphones.CFG.PROWL_PRIORITY
|
||||
self.enabled = headphones.CONFIG.PROWL_ENABLED
|
||||
self.keys = headphones.CONFIG.PROWL_KEYS
|
||||
self.priority = headphones.CONFIG.PROWL_PRIORITY
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('Prowl', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.CFG.PROWL_ENABLED:
|
||||
if not headphones.CONFIG.PROWL_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.prowlapp.com")
|
||||
|
||||
data = {'apikey': headphones.CFG.PROWL_KEYS,
|
||||
data = {'apikey': headphones.CONFIG.PROWL_KEYS,
|
||||
'application': 'Headphones',
|
||||
'event': event,
|
||||
'description': message.encode("utf-8"),
|
||||
'priority': headphones.CFG.PROWL_PRIORITY }
|
||||
'priority': headphones.CONFIG.PROWL_PRIORITY }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/publicapi/add",
|
||||
@@ -197,9 +197,9 @@ class XBMC(object):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.hosts = headphones.CFG.XBMC_HOST
|
||||
self.username = headphones.CFG.XBMC_USERNAME
|
||||
self.password = headphones.CFG.XBMC_PASSWORD
|
||||
self.hosts = headphones.CONFIG.XBMC_HOST
|
||||
self.username = headphones.CONFIG.XBMC_USERNAME
|
||||
self.password = headphones.CONFIG.XBMC_PASSWORD
|
||||
|
||||
def _sendhttp(self, host, command):
|
||||
url_command = urllib.urlencode(command)
|
||||
@@ -270,7 +270,7 @@ class LMS(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.hosts = headphones.CFG.LMS_HOST
|
||||
self.hosts = headphones.CONFIG.LMS_HOST
|
||||
|
||||
def _sendjson(self, host):
|
||||
data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]}
|
||||
@@ -308,10 +308,10 @@ class LMS(object):
|
||||
class Plex(object):
|
||||
def __init__(self):
|
||||
|
||||
self.server_hosts = headphones.CFG.PLEX_SERVER_HOST
|
||||
self.client_hosts = headphones.CFG.PLEX_CLIENT_HOST
|
||||
self.username = headphones.CFG.PLEX_USERNAME
|
||||
self.password = headphones.CFG.PLEX_PASSWORD
|
||||
self.server_hosts = headphones.CONFIG.PLEX_SERVER_HOST
|
||||
self.client_hosts = headphones.CONFIG.PLEX_CLIENT_HOST
|
||||
self.username = headphones.CONFIG.PLEX_USERNAME
|
||||
self.password = headphones.CONFIG.PLEX_PASSWORD
|
||||
|
||||
def _sendhttp(self, host, command):
|
||||
|
||||
@@ -394,8 +394,8 @@ class Plex(object):
|
||||
class NMA(object):
|
||||
def notify(self, artist=None, album=None, snatched=None):
|
||||
title = 'Headphones'
|
||||
api = headphones.CFG.NMA_APIKEY
|
||||
nma_priority = headphones.CFG.NMA_PRIORITY
|
||||
api = headphones.CONFIG.NMA_APIKEY
|
||||
nma_priority = headphones.CONFIG.NMA_PRIORITY
|
||||
|
||||
logger.debug(u"NMA title: " + title)
|
||||
logger.debug(u"NMA API: " + api)
|
||||
@@ -430,19 +430,19 @@ class NMA(object):
|
||||
class PUSHBULLET(object):
|
||||
|
||||
def __init__(self):
|
||||
self.apikey = headphones.CFG.PUSHBULLET_APIKEY
|
||||
self.deviceid = headphones.CFG.PUSHBULLET_DEVICEID
|
||||
self.apikey = headphones.CONFIG.PUSHBULLET_APIKEY
|
||||
self.deviceid = headphones.CONFIG.PUSHBULLET_DEVICEID
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('PUSHBULLET', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.CFG.PUSHBULLET_ENABLED:
|
||||
if not headphones.CONFIG.PUSHBULLET_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.pushbullet.com")
|
||||
|
||||
data = {'device_iden': headphones.CFG.PUSHBULLET_DEVICEID,
|
||||
data = {'device_iden': headphones.CONFIG.PUSHBULLET_DEVICEID,
|
||||
'type': "note",
|
||||
'title': "Headphones",
|
||||
'body': message.encode("utf-8") }
|
||||
@@ -450,7 +450,7 @@ class PUSHBULLET(object):
|
||||
http_handler.request("POST",
|
||||
"/api/pushes",
|
||||
headers = {'Content-type': "application/x-www-form-urlencoded",
|
||||
'Authorization' : 'Basic %s' % base64.b64encode(headphones.CFG.PUSHBULLET_APIKEY + ":") },
|
||||
'Authorization' : 'Basic %s' % base64.b64encode(headphones.CONFIG.PUSHBULLET_APIKEY + ":") },
|
||||
body = urlencode(data))
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
@@ -483,10 +483,10 @@ class PUSHBULLET(object):
|
||||
class PUSHALOT(object):
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.CFG.PUSHALOT_ENABLED:
|
||||
if not headphones.CONFIG.PUSHALOT_ENABLED:
|
||||
return
|
||||
|
||||
pushalot_authorizationtoken = headphones.CFG.PUSHALOT_APIKEY
|
||||
pushalot_authorizationtoken = headphones.CONFIG.PUSHALOT_APIKEY
|
||||
|
||||
logger.debug(u"Pushalot event: " + event)
|
||||
logger.debug(u"Pushalot message: " + message)
|
||||
@@ -558,12 +558,12 @@ class Synoindex(object):
|
||||
class PUSHOVER(object):
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.CFG.PUSHOVER_ENABLED
|
||||
self.keys = headphones.CFG.PUSHOVER_KEYS
|
||||
self.priority = headphones.CFG.PUSHOVER_PRIORITY
|
||||
self.enabled = headphones.CONFIG.PUSHOVER_ENABLED
|
||||
self.keys = headphones.CONFIG.PUSHOVER_KEYS
|
||||
self.priority = headphones.CONFIG.PUSHOVER_PRIORITY
|
||||
|
||||
if headphones.CFG.PUSHOVER_APITOKEN:
|
||||
self.application_token = headphones.CFG.PUSHOVER_APITOKEN
|
||||
if headphones.CONFIG.PUSHOVER_APITOKEN:
|
||||
self.application_token = headphones.CONFIG.PUSHOVER_APITOKEN
|
||||
else:
|
||||
self.application_token = "LdPCoy0dqC21ktsbEyAVCcwvQiVlsz"
|
||||
|
||||
@@ -571,16 +571,16 @@ class PUSHOVER(object):
|
||||
return cherrypy.config['config'].get('Pushover', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.CFG.PUSHOVER_ENABLED:
|
||||
if not headphones.CONFIG.PUSHOVER_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.pushover.net")
|
||||
|
||||
data = {'token': self.application_token,
|
||||
'user': headphones.CFG.PUSHOVER_KEYS,
|
||||
'user': headphones.CONFIG.PUSHOVER_KEYS,
|
||||
'title': event,
|
||||
'message': message.encode("utf-8"),
|
||||
'priority': headphones.CFG.PUSHOVER_PRIORITY }
|
||||
'priority': headphones.CONFIG.PUSHOVER_PRIORITY }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/1/messages.json",
|
||||
@@ -625,11 +625,11 @@ class TwitterNotifier(object):
|
||||
self.consumer_secret = "A4Xkw9i5SjHbTk7XT8zzOPqivhj9MmRDR9Qn95YA9sk"
|
||||
|
||||
def notify_snatch(self, title):
|
||||
if headphones.CFG.TWITTER_ONSNATCH:
|
||||
if headphones.CONFIG.TWITTER_ONSNATCH:
|
||||
self._notifyTwitter(common.notifyStrings[common.NOTIFY_SNATCH]+': '+title+' at '+helpers.now())
|
||||
|
||||
def notify_download(self, title):
|
||||
if headphones.CFG.TWITTER_ENABLED:
|
||||
if headphones.CONFIG.TWITTER_ENABLED:
|
||||
self._notifyTwitter(common.notifyStrings[common.NOTIFY_DOWNLOAD]+': '+title+' at '+helpers.now())
|
||||
|
||||
def test_notify(self):
|
||||
@@ -650,16 +650,16 @@ class TwitterNotifier(object):
|
||||
else:
|
||||
request_token = dict(parse_qsl(content))
|
||||
|
||||
headphones.CFG.TWITTER_USERNAME = request_token['oauth_token']
|
||||
headphones.CFG.TWITTER_PASSWORD = request_token['oauth_token_secret']
|
||||
headphones.CONFIG.TWITTER_USERNAME = request_token['oauth_token']
|
||||
headphones.CONFIG.TWITTER_PASSWORD = request_token['oauth_token_secret']
|
||||
|
||||
return self.AUTHORIZATION_URL+"?oauth_token="+ request_token['oauth_token']
|
||||
|
||||
def _get_credentials(self, key):
|
||||
request_token = {}
|
||||
|
||||
request_token['oauth_token'] = headphones.CFG.TWITTER_USERNAME
|
||||
request_token['oauth_token_secret'] = headphones.CFG.TWITTER_PASSWORD
|
||||
request_token['oauth_token'] = headphones.CONFIG.TWITTER_USERNAME
|
||||
request_token['oauth_token_secret'] = headphones.CONFIG.TWITTER_PASSWORD
|
||||
request_token['oauth_callback_confirmed'] = 'true'
|
||||
|
||||
token = oauth.Token(request_token['oauth_token'], request_token['oauth_token_secret'])
|
||||
@@ -685,8 +685,8 @@ class TwitterNotifier(object):
|
||||
else:
|
||||
logger.info('Your Twitter Access Token key: %s' % access_token['oauth_token'])
|
||||
logger.info('Access Token secret: %s' % access_token['oauth_token_secret'])
|
||||
headphones.CFG.TWITTER_USERNAME = access_token['oauth_token']
|
||||
headphones.CFG.TWITTER_PASSWORD = access_token['oauth_token_secret']
|
||||
headphones.CONFIG.TWITTER_USERNAME = access_token['oauth_token']
|
||||
headphones.CONFIG.TWITTER_PASSWORD = access_token['oauth_token_secret']
|
||||
return True
|
||||
|
||||
|
||||
@@ -694,8 +694,8 @@ class TwitterNotifier(object):
|
||||
|
||||
username=self.consumer_key
|
||||
password=self.consumer_secret
|
||||
access_token_key=headphones.CFG.TWITTER_USERNAME
|
||||
access_token_secret=headphones.CFG.TWITTER_PASSWORD
|
||||
access_token_key=headphones.CONFIG.TWITTER_USERNAME
|
||||
access_token_secret=headphones.CONFIG.TWITTER_PASSWORD
|
||||
|
||||
logger.info(u"Sending tweet: "+message)
|
||||
|
||||
@@ -710,9 +710,9 @@ class TwitterNotifier(object):
|
||||
return True
|
||||
|
||||
def _notifyTwitter(self, message='', force=False):
|
||||
prefix = headphones.CFG.TWITTER_PREFIX
|
||||
prefix = headphones.CONFIG.TWITTER_PREFIX
|
||||
|
||||
if not headphones.CFG.TWITTER_ENABLED and not force:
|
||||
if not headphones.CONFIG.TWITTER_ENABLED and not force:
|
||||
return False
|
||||
|
||||
return self._send_tweet(prefix+": "+message)
|
||||
@@ -783,7 +783,7 @@ class BOXCAR(object):
|
||||
message += '<br></br><a href="http://musicbrainz.org/release-group/%s">MusicBrainz</a>' % rgid
|
||||
|
||||
data = urllib.urlencode({
|
||||
'user_credentials': headphones.CFG.BOXCAR_TOKEN,
|
||||
'user_credentials': headphones.CONFIG.BOXCAR_TOKEN,
|
||||
'notification[title]': title.encode('utf-8'),
|
||||
'notification[long_message]': message.encode('utf-8'),
|
||||
'notification[sound]': "done"
|
||||
@@ -801,9 +801,9 @@ class BOXCAR(object):
|
||||
class SubSonicNotifier(object):
|
||||
|
||||
def __init__(self):
|
||||
self.host = headphones.CFG.SUBSONIC_HOST
|
||||
self.username = headphones.CFG.SUBSONIC_USERNAME
|
||||
self.password = headphones.CFG.SUBSONIC_PASSWORD
|
||||
self.host = headphones.CONFIG.SUBSONIC_HOST
|
||||
self.username = headphones.CONFIG.SUBSONIC_USERNAME
|
||||
self.password = headphones.CONFIG.SUBSONIC_PASSWORD
|
||||
|
||||
def notify(self, albumpaths):
|
||||
# Correct URL
|
||||
|
||||
@@ -37,19 +37,19 @@ def sendNZB(nzb):
|
||||
addToTop = False
|
||||
nzbgetXMLrpc = "%(username)s:%(password)s@%(host)s/xmlrpc"
|
||||
|
||||
if headphones.CFG.NZBGET_HOST == None:
|
||||
if headphones.CONFIG.NZBGET_HOST == None:
|
||||
logger.error(u"No NZBget host found in configuration. Please configure it.")
|
||||
return False
|
||||
|
||||
if headphones.CFG.NZBGET_HOST.startswith('https://'):
|
||||
if headphones.CONFIG.NZBGET_HOST.startswith('https://'):
|
||||
nzbgetXMLrpc = 'https://' + nzbgetXMLrpc
|
||||
headphones.CFG.NZBGET_HOST.replace('https://','',1)
|
||||
headphones.CONFIG.NZBGET_HOST.replace('https://','',1)
|
||||
else:
|
||||
nzbgetXMLrpc = 'http://' + nzbgetXMLrpc
|
||||
headphones.CFG.NZBGET_HOST.replace('http://','',1)
|
||||
headphones.CONFIG.NZBGET_HOST.replace('http://','',1)
|
||||
|
||||
|
||||
url = nzbgetXMLrpc % {"host": headphones.CFG.NZBGET_HOST, "username": headphones.CFG.NZBGET_USERNAME, "password": headphones.CFG.NZBGET_PASSWORD}
|
||||
url = nzbgetXMLrpc % {"host": headphones.CONFIG.NZBGET_HOST, "username": headphones.CONFIG.NZBGET_USERNAME, "password": headphones.CONFIG.NZBGET_PASSWORD}
|
||||
|
||||
nzbGetRPC = xmlrpclib.ServerProxy(url)
|
||||
try:
|
||||
@@ -86,7 +86,7 @@ def sendNZB(nzb):
|
||||
nzbget_version = int(nzbget_version_str[:nzbget_version_str.find(".")])
|
||||
if nzbget_version == 0:
|
||||
if nzbcontent64 is not None:
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
else:
|
||||
if nzb.resultType == "nzb":
|
||||
genProvider = GenericProvider("")
|
||||
@@ -94,27 +94,27 @@ def sendNZB(nzb):
|
||||
if (data == None):
|
||||
return False
|
||||
nzbcontent64 = standard_b64encode(data)
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
elif nzbget_version == 12:
|
||||
if nzbcontent64 is not None:
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, headphones.CONFIG.NZBGET_PRIORITY, False,
|
||||
nzbcontent64, False, dupekey, dupescore, "score")
|
||||
else:
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, headphones.CONFIG.NZBGET_PRIORITY, False,
|
||||
nzb.url, False, dupekey, dupescore, "score")
|
||||
# v13+ has a new combined append method that accepts both (url and content)
|
||||
# also the return value has changed from boolean to integer
|
||||
# (Positive number representing NZBID of the queue item. 0 and negative numbers represent error codes.)
|
||||
elif nzbget_version >= 13:
|
||||
nzbget_result = True if nzbGetRPC.append(nzb.name + ".nzb", nzbcontent64 if nzbcontent64 is not None else nzb.url,
|
||||
headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False, False, dupekey, dupescore,
|
||||
headphones.CONFIG.NZBGET_CATEGORY, headphones.CONFIG.NZBGET_PRIORITY, False, False, dupekey, dupescore,
|
||||
"score") > 0 else False
|
||||
else:
|
||||
if nzbcontent64 is not None:
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, headphones.CONFIG.NZBGET_PRIORITY, False,
|
||||
nzbcontent64)
|
||||
else:
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CONFIG.NZBGET_CATEGORY, headphones.CONFIG.NZBGET_PRIORITY, False,
|
||||
nzb.url)
|
||||
|
||||
if nzbget_result:
|
||||
|
||||
@@ -44,9 +44,9 @@ def checkFolder():
|
||||
if album['FolderName']:
|
||||
|
||||
if album['Kind'] == 'nzb':
|
||||
download_dir = headphones.CFG.DOWNLOAD_DIR
|
||||
download_dir = headphones.CONFIG.DOWNLOAD_DIR
|
||||
else:
|
||||
download_dir = headphones.CFG.DOWNLOAD_TORRENT_DIR
|
||||
download_dir = headphones.CONFIG.DOWNLOAD_TORRENT_DIR
|
||||
|
||||
album_path = os.path.join(download_dir, album['FolderName']).encode(headphones.SYS_ENCODING,'replace')
|
||||
logger.info("Checking if %s exists" % album_path)
|
||||
@@ -90,7 +90,7 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
||||
# frozen during post processing, new artists will not be processed. This
|
||||
# prevents new artists from appearing suddenly. In case forced is True,
|
||||
# this check is skipped, since it is assumed the user wants this.
|
||||
if headphones.CFG.FREEZE_DB and not forced:
|
||||
if headphones.CONFIG.FREEZE_DB and not forced:
|
||||
artist = myDB.select("SELECT ArtistName, ArtistID FROM artists WHERE ArtistId=? OR ArtistName=?", [release_dict['artist_id'], release_dict['artist_name']])
|
||||
|
||||
if not artist:
|
||||
@@ -115,9 +115,9 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
||||
|
||||
logger.info("ArtistID: " + release_dict['artist_id'] + " , ArtistName: " + release_dict['artist_name'])
|
||||
|
||||
if headphones.CFG.INCLUDE_EXTRAS:
|
||||
if headphones.CONFIG.INCLUDE_EXTRAS:
|
||||
newValueDict['IncludeExtras'] = 1
|
||||
newValueDict['Extras'] = headphones.CFG.EXTRAS
|
||||
newValueDict['Extras'] = headphones.CONFIG.EXTRAS
|
||||
|
||||
myDB.upsert("artists", newValueDict, controlValueDict)
|
||||
|
||||
@@ -181,16 +181,16 @@ def verify(albumid, albumpath, Kind=None, forced=False):
|
||||
|
||||
# use xld to split cue
|
||||
|
||||
if headphones.CFG.ENCODER == 'xld' and headphones.CFG.MUSIC_ENCODER and downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list):
|
||||
if headphones.CONFIG.ENCODER == 'xld' and headphones.CONFIG.MUSIC_ENCODER and downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list):
|
||||
|
||||
import getXldProfile
|
||||
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CFG.XLDPROFILE)
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CONFIG.XLDPROFILE)
|
||||
if not xldFormat:
|
||||
logger.info(u'Details for xld profile "%s" not found, cannot split cue' % (xldProfile))
|
||||
else:
|
||||
if headphones.CFG.ENCODERFOLDER:
|
||||
xldencoder = os.path.join(headphones.CFG.ENCODERFOLDER, 'xld')
|
||||
if headphones.CONFIG.ENCODERFOLDER:
|
||||
xldencoder = os.path.join(headphones.CONFIG.ENCODERFOLDER, 'xld')
|
||||
else:
|
||||
xldencoder = os.path.join('/Applications','xld')
|
||||
|
||||
@@ -328,7 +328,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
|
||||
logger.info('Starting post-processing for: %s - %s' % (release['ArtistName'], release['AlbumTitle']))
|
||||
# Check to see if we're preserving the torrent dir
|
||||
if headphones.CFG.KEEP_TORRENT_FILES and Kind=="torrent":
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind=="torrent":
|
||||
new_folder = os.path.join(albumpath, 'headphones-modified'.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
logger.info("Copying files to 'headphones-modified' subfolder to preserve downloaded files for seeding")
|
||||
try:
|
||||
@@ -369,10 +369,10 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
# If one of the options below is set, it will access/touch/modify the
|
||||
# files, which requires write permissions. This step just check this, so
|
||||
# it will not try and fail lateron, with strange exceptions.
|
||||
if headphones.CFG.EMBED_ALBUM_ART or headphones.CFG.CLEANUP_FILES or \
|
||||
headphones.CFG.ADD_ALBUM_ART or headphones.CFG.CORRECT_METADATA or \
|
||||
headphones.CFG.EMBED_LYRICS or headphones.CFG.RENAME_FILES or \
|
||||
headphones.CFG.MOVE_FILES:
|
||||
if headphones.CONFIG.EMBED_ALBUM_ART or headphones.CONFIG.CLEANUP_FILES or \
|
||||
headphones.CONFIG.ADD_ALBUM_ART or headphones.CONFIG.CORRECT_METADATA or \
|
||||
headphones.CONFIG.EMBED_LYRICS or headphones.CONFIG.RENAME_FILES or \
|
||||
headphones.CONFIG.MOVE_FILES:
|
||||
|
||||
try:
|
||||
with open(downloaded_track, "a+b"):
|
||||
@@ -384,7 +384,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
return
|
||||
|
||||
#start encoding
|
||||
if headphones.CFG.MUSIC_ENCODER:
|
||||
if headphones.CONFIG.MUSIC_ENCODER:
|
||||
downloaded_track_list=music_encoder.encode(albumpath)
|
||||
|
||||
if not downloaded_track_list:
|
||||
@@ -392,7 +392,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
|
||||
artwork = None
|
||||
album_art_path = albumart.getAlbumArt(albumid)
|
||||
if headphones.CFG.EMBED_ALBUM_ART or headphones.CFG.ADD_ALBUM_ART:
|
||||
if headphones.CONFIG.EMBED_ALBUM_ART or headphones.CONFIG.ADD_ALBUM_ART:
|
||||
|
||||
if album_art_path:
|
||||
artwork = request.request_content(album_art_path)
|
||||
@@ -406,31 +406,31 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
artwork = False
|
||||
logger.info("No suitable album art found from Last.FM. Not adding album art")
|
||||
|
||||
if headphones.CFG.EMBED_ALBUM_ART and artwork:
|
||||
if headphones.CONFIG.EMBED_ALBUM_ART and artwork:
|
||||
embedAlbumArt(artwork, downloaded_track_list)
|
||||
|
||||
if headphones.CFG.CLEANUP_FILES:
|
||||
if headphones.CONFIG.CLEANUP_FILES:
|
||||
cleanupFiles(albumpath)
|
||||
|
||||
if headphones.CFG.KEEP_NFO:
|
||||
if headphones.CONFIG.KEEP_NFO:
|
||||
renameNFO(albumpath)
|
||||
|
||||
if headphones.CFG.ADD_ALBUM_ART and artwork:
|
||||
if headphones.CONFIG.ADD_ALBUM_ART and artwork:
|
||||
addAlbumArt(artwork, albumpath, release)
|
||||
|
||||
if headphones.CFG.CORRECT_METADATA:
|
||||
if headphones.CONFIG.CORRECT_METADATA:
|
||||
correctMetadata(albumid, release, downloaded_track_list)
|
||||
|
||||
if headphones.CFG.EMBED_LYRICS:
|
||||
if headphones.CONFIG.EMBED_LYRICS:
|
||||
embedLyrics(downloaded_track_list)
|
||||
|
||||
if headphones.CFG.RENAME_FILES:
|
||||
if headphones.CONFIG.RENAME_FILES:
|
||||
renameFiles(albumpath, downloaded_track_list, release)
|
||||
|
||||
if headphones.CFG.MOVE_FILES and not headphones.CFG.DESTINATION_DIR:
|
||||
if headphones.CONFIG.MOVE_FILES and not headphones.CONFIG.DESTINATION_DIR:
|
||||
logger.error('No DESTINATION_DIR has been set. Set "Destination Directory" to the parent directory you want to move the files to')
|
||||
albumpaths = [albumpath]
|
||||
elif headphones.CFG.MOVE_FILES and headphones.CFG.DESTINATION_DIR:
|
||||
elif headphones.CONFIG.MOVE_FILES and headphones.CONFIG.DESTINATION_DIR:
|
||||
albumpaths = moveFiles(albumpath, release, tracks)
|
||||
else:
|
||||
albumpaths = [albumpath]
|
||||
@@ -442,13 +442,13 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
myDB.action('UPDATE snatched SET status = "Processed" WHERE Status NOT LIKE "Seed%" and AlbumID=?', [albumid])
|
||||
|
||||
# Check if torrent has finished seeding
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 1 or headphones.CFG.TORRENT_DOWNLOADER == 2:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 1 or headphones.CONFIG.TORRENT_DOWNLOADER == 2:
|
||||
seed_snatched = myDB.action('SELECT * from snatched WHERE Status="Seed_Snatched" and AlbumID=?', [albumid]).fetchone()
|
||||
if seed_snatched:
|
||||
hash = seed_snatched['FolderName']
|
||||
torrent_removed = False
|
||||
logger.info(u'%s - %s. Checking if torrent has finished seeding and can be removed' % (release['ArtistName'], release['AlbumTitle']))
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 1:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 1:
|
||||
torrent_removed = transmission.removeTorrent(hash, True)
|
||||
else:
|
||||
torrent_removed = utorrent.removeTorrent(hash, True)
|
||||
@@ -468,86 +468,86 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
pushmessage = release['ArtistName'] + ' - ' + release['AlbumTitle']
|
||||
statusmessage = "Download and Postprocessing completed"
|
||||
|
||||
if headphones.CFG.GROWL_ENABLED:
|
||||
if headphones.CONFIG.GROWL_ENABLED:
|
||||
logger.info(u"Growl request")
|
||||
growl = notifiers.GROWL()
|
||||
growl.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.CFG.PROWL_ENABLED:
|
||||
if headphones.CONFIG.PROWL_ENABLED:
|
||||
logger.info(u"Prowl request")
|
||||
prowl = notifiers.PROWL()
|
||||
prowl.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.CFG.XBMC_ENABLED:
|
||||
if headphones.CONFIG.XBMC_ENABLED:
|
||||
xbmc = notifiers.XBMC()
|
||||
if headphones.CFG.XBMC_UPDATE:
|
||||
if headphones.CONFIG.XBMC_UPDATE:
|
||||
xbmc.update()
|
||||
if headphones.CFG.XBMC_NOTIFY:
|
||||
if headphones.CONFIG.XBMC_NOTIFY:
|
||||
xbmc.notify(release['ArtistName'],
|
||||
release['AlbumTitle'],
|
||||
album_art_path)
|
||||
|
||||
if headphones.CFG.LMS_ENABLED:
|
||||
if headphones.CONFIG.LMS_ENABLED:
|
||||
lms = notifiers.LMS()
|
||||
lms.update()
|
||||
|
||||
if headphones.CFG.PLEX_ENABLED:
|
||||
if headphones.CONFIG.PLEX_ENABLED:
|
||||
plex = notifiers.Plex()
|
||||
if headphones.CFG.PLEX_UPDATE:
|
||||
if headphones.CONFIG.PLEX_UPDATE:
|
||||
plex.update()
|
||||
if headphones.CFG.PLEX_NOTIFY:
|
||||
if headphones.CONFIG.PLEX_NOTIFY:
|
||||
plex.notify(release['ArtistName'],
|
||||
release['AlbumTitle'],
|
||||
album_art_path)
|
||||
|
||||
if headphones.CFG.NMA_ENABLED:
|
||||
if headphones.CONFIG.NMA_ENABLED:
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(release['ArtistName'], release['AlbumTitle'])
|
||||
|
||||
if headphones.CFG.PUSHALOT_ENABLED:
|
||||
if headphones.CONFIG.PUSHALOT_ENABLED:
|
||||
logger.info(u"Pushalot request")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.CFG.SYNOINDEX_ENABLED:
|
||||
if headphones.CONFIG.SYNOINDEX_ENABLED:
|
||||
syno = notifiers.Synoindex()
|
||||
for albumpath in albumpaths:
|
||||
syno.notify(albumpath)
|
||||
|
||||
if headphones.CFG.PUSHOVER_ENABLED:
|
||||
if headphones.CONFIG.PUSHOVER_ENABLED:
|
||||
logger.info(u"Pushover request")
|
||||
pushover = notifiers.PUSHOVER()
|
||||
pushover.notify(pushmessage, "Headphones")
|
||||
|
||||
if headphones.CFG.PUSHBULLET_ENABLED:
|
||||
if headphones.CONFIG.PUSHBULLET_ENABLED:
|
||||
logger.info(u"PushBullet request")
|
||||
pushbullet = notifiers.PUSHBULLET()
|
||||
pushbullet.notify(pushmessage, "Download and Postprocessing completed")
|
||||
|
||||
if headphones.CFG.TWITTER_ENABLED:
|
||||
if headphones.CONFIG.TWITTER_ENABLED:
|
||||
logger.info(u"Sending Twitter notification")
|
||||
twitter = notifiers.TwitterNotifier()
|
||||
twitter.notify_download(pushmessage)
|
||||
|
||||
if headphones.CFG.OSX_NOTIFY_ENABLED:
|
||||
if headphones.CONFIG.OSX_NOTIFY_ENABLED:
|
||||
logger.info(u"Sending OS X notification")
|
||||
osx_notify = notifiers.OSX_NOTIFY()
|
||||
osx_notify.notify(release['ArtistName'],
|
||||
release['AlbumTitle'],
|
||||
statusmessage)
|
||||
|
||||
if headphones.CFG.BOXCAR_ENABLED:
|
||||
if headphones.CONFIG.BOXCAR_ENABLED:
|
||||
logger.info(u"Sending Boxcar2 notification")
|
||||
boxcar = notifiers.BOXCAR()
|
||||
boxcar.notify('Headphones processed: ' + pushmessage,
|
||||
statusmessage, release['AlbumID'])
|
||||
|
||||
if headphones.CFG.SUBSONIC_ENABLED:
|
||||
if headphones.CONFIG.SUBSONIC_ENABLED:
|
||||
logger.info(u"Sending Subsonic update")
|
||||
subsonic = notifiers.SubSonicNotifier()
|
||||
subsonic.notify(albumpaths)
|
||||
|
||||
if headphones.CFG.MPC_ENABLED:
|
||||
if headphones.CONFIG.MPC_ENABLED:
|
||||
mpc = notifiers.MPC()
|
||||
mpc.notify()
|
||||
|
||||
@@ -586,11 +586,11 @@ def addAlbumArt(artwork, albumpath, release):
|
||||
'$year': year
|
||||
}
|
||||
|
||||
album_art_name = helpers.replace_all(headphones.CFG.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
||||
album_art_name = helpers.replace_all(headphones.CONFIG.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
||||
|
||||
album_art_name = helpers.replace_illegal_chars(album_art_name).encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
if headphones.CFG.FILE_UNDERSCORES:
|
||||
if headphones.CONFIG.FILE_UNDERSCORES:
|
||||
album_art_name = album_art_name.replace(' ', '_')
|
||||
|
||||
if album_art_name.startswith('.'):
|
||||
@@ -637,7 +637,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
|
||||
artist = release['ArtistName'].replace('/', '_')
|
||||
album = release['AlbumTitle'].replace('/', '_')
|
||||
if headphones.CFG.FILE_UNDERSCORES:
|
||||
if headphones.CONFIG.FILE_UNDERSCORES:
|
||||
artist = artist.replace(' ', '_')
|
||||
album = album.replace(' ', '_')
|
||||
|
||||
@@ -675,7 +675,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
'$originalfolder': origfolder.lower()
|
||||
}
|
||||
|
||||
folder = helpers.replace_all(headphones.CFG.FOLDER_FORMAT.strip(), values, normalize=True)
|
||||
folder = helpers.replace_all(headphones.CONFIG.FOLDER_FORMAT.strip(), values, normalize=True)
|
||||
|
||||
folder = helpers.replace_illegal_chars(folder, type="folder")
|
||||
folder = folder.replace('./', '_/').replace('/.','/_')
|
||||
@@ -704,11 +704,11 @@ def moveFiles(albumpath, release, tracks):
|
||||
make_lossy_folder = False
|
||||
make_lossless_folder = False
|
||||
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.CFG.DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.CFG.LOSSLESS_DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.CONFIG.DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.CONFIG.LOSSLESS_DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
# If they set a destination dir for lossless media, only create the lossy folder if there is lossy media
|
||||
if headphones.CFG.LOSSLESS_DESTINATION_DIR:
|
||||
if headphones.CONFIG.LOSSLESS_DESTINATION_DIR:
|
||||
if lossy_media:
|
||||
make_lossy_folder = True
|
||||
if lossless_media:
|
||||
@@ -717,7 +717,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
else:
|
||||
make_lossy_folder = True
|
||||
|
||||
last_folder = headphones.CFG.FOLDER_FORMAT.strip().split('/')[-1]
|
||||
last_folder = headphones.CONFIG.FOLDER_FORMAT.strip().split('/')[-1]
|
||||
|
||||
if make_lossless_folder:
|
||||
# Only rename the folder if they use the album name, otherwise merge into existing folder
|
||||
@@ -725,20 +725,20 @@ def moveFiles(albumpath, release, tracks):
|
||||
|
||||
create_duplicate_folder = False
|
||||
|
||||
if headphones.CFG.REPLACE_EXISTING_FOLDERS:
|
||||
if headphones.CONFIG.REPLACE_EXISTING_FOLDERS:
|
||||
try:
|
||||
shutil.rmtree(lossless_destination_path)
|
||||
except Exception, e:
|
||||
logger.error("Error deleting existing folder: %s. Creating duplicate folder. Error: %s" % (lossless_destination_path.decode(headphones.SYS_ENCODING, 'replace'), e))
|
||||
create_duplicate_folder = True
|
||||
|
||||
if not headphones.CFG.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
if not headphones.CONFIG.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
temp_folder = folder
|
||||
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.CFG.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.CONFIG.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossless_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
@@ -758,20 +758,20 @@ def moveFiles(albumpath, release, tracks):
|
||||
|
||||
create_duplicate_folder = False
|
||||
|
||||
if headphones.CFG.REPLACE_EXISTING_FOLDERS:
|
||||
if headphones.CONFIG.REPLACE_EXISTING_FOLDERS:
|
||||
try:
|
||||
shutil.rmtree(lossy_destination_path)
|
||||
except Exception, e:
|
||||
logger.error("Error deleting existing folder: %s. Creating duplicate folder. Error: %s" % (lossy_destination_path.decode(headphones.SYS_ENCODING, 'replace'), e))
|
||||
create_duplicate_folder = True
|
||||
|
||||
if not headphones.CFG.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
if not headphones.CONFIG.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
temp_folder = folder
|
||||
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.CFG.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.CONFIG.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossy_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
@@ -829,10 +829,10 @@ def moveFiles(albumpath, release, tracks):
|
||||
temp_fs = []
|
||||
|
||||
if make_lossless_folder:
|
||||
temp_fs.append(headphones.CFG.LOSSLESS_DESTINATION_DIR)
|
||||
temp_fs.append(headphones.CONFIG.LOSSLESS_DESTINATION_DIR)
|
||||
|
||||
if make_lossy_folder:
|
||||
temp_fs.append(headphones.CFG.DESTINATION_DIR)
|
||||
temp_fs.append(headphones.CONFIG.DESTINATION_DIR)
|
||||
|
||||
for temp_f in temp_fs:
|
||||
|
||||
@@ -841,7 +841,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
temp_f = os.path.join(temp_f, f)
|
||||
|
||||
try:
|
||||
os.chmod(os.path.normpath(temp_f).encode(headphones.SYS_ENCODING, 'replace'), int(headphones.CFG.FOLDER_PERMISSIONS, 8))
|
||||
os.chmod(os.path.normpath(temp_f).encode(headphones.SYS_ENCODING, 'replace'), int(headphones.CONFIG.FOLDER_PERMISSIONS, 8))
|
||||
except Exception, e:
|
||||
logger.error("Error trying to change permissions on folder: %s. %s", temp_f, e)
|
||||
|
||||
@@ -1024,12 +1024,12 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
|
||||
ext = os.path.splitext(downloaded_track)[1]
|
||||
|
||||
new_file_name = helpers.replace_all(headphones.CFG.FILE_FORMAT.strip(), values).replace('/','_') + ext
|
||||
new_file_name = helpers.replace_all(headphones.CONFIG.FILE_FORMAT.strip(), values).replace('/','_') + ext
|
||||
|
||||
|
||||
new_file_name = helpers.replace_illegal_chars(new_file_name).encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
if headphones.CFG.FILE_UNDERSCORES:
|
||||
if headphones.CONFIG.FILE_UNDERSCORES:
|
||||
new_file_name = new_file_name.replace(' ', '_')
|
||||
|
||||
if new_file_name.startswith('.'):
|
||||
@@ -1056,7 +1056,7 @@ def updateFilePermissions(albumpaths):
|
||||
for files in f:
|
||||
full_path = os.path.join(r, files)
|
||||
try:
|
||||
os.chmod(full_path, int(headphones.CFG.FILE_PERMISSIONS, 8))
|
||||
os.chmod(full_path, int(headphones.CONFIG.FILE_PERMISSIONS, 8))
|
||||
except:
|
||||
logger.error("Could not change permissions for file: %s", full_path)
|
||||
continue
|
||||
@@ -1086,10 +1086,10 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
|
||||
download_dirs = []
|
||||
if dir:
|
||||
download_dirs.append(dir.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
if headphones.CFG.DOWNLOAD_DIR and not dir:
|
||||
download_dirs.append(headphones.CFG.DOWNLOAD_DIR.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
if headphones.CFG.DOWNLOAD_TORRENT_DIR and not dir:
|
||||
download_dirs.append(headphones.CFG.DOWNLOAD_TORRENT_DIR.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
if headphones.CONFIG.DOWNLOAD_DIR and not dir:
|
||||
download_dirs.append(headphones.CONFIG.DOWNLOAD_DIR.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
if headphones.CONFIG.DOWNLOAD_TORRENT_DIR and not dir:
|
||||
download_dirs.append(headphones.CONFIG.DOWNLOAD_TORRENT_DIR.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
|
||||
# If DOWNLOAD_DIR and DOWNLOAD_TORRENT_DIR are the same, remove the duplicate to prevent us from trying to process the same folder twice.
|
||||
download_dirs = list(set(download_dirs))
|
||||
@@ -1137,7 +1137,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
|
||||
snatched = myDB.action('SELECT AlbumID, Title, Kind, Status from snatched WHERE FolderName LIKE ?', [folder_basename]).fetchone()
|
||||
|
||||
if snatched:
|
||||
if headphones.CFG.KEEP_TORRENT_FILES and snatched['Kind'] == 'torrent' and snatched['Status'] == 'Processed':
|
||||
if headphones.CONFIG.KEEP_TORRENT_FILES and snatched['Kind'] == 'torrent' and snatched['Status'] == 'Processed':
|
||||
logger.info('%s is a torrent folder being preserved for seeding and has already been processed. Skipping.', folder_basename)
|
||||
continue
|
||||
else:
|
||||
|
||||
@@ -47,7 +47,7 @@ def request_response(url, method="get", auto_raise=True,
|
||||
|
||||
# Disable verification of SSL certificates if requested. Note: this could
|
||||
# pose a security issue!
|
||||
kwargs["verify"] = headphones.CFG.VERIFY_SSL_CERT
|
||||
kwargs["verify"] = headphones.CONFIG.VERIFY_SSL_CERT
|
||||
|
||||
# Map method to the request.XXX method. This is a simple hack, but it allows
|
||||
# requests to apply more magic per method. See lib/requests/api.py.
|
||||
|
||||
@@ -34,14 +34,14 @@ def sendNZB(nzb):
|
||||
|
||||
params = {}
|
||||
|
||||
if headphones.CFG.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.CFG.SAB_USERNAME
|
||||
if headphones.CFG.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.CFG.SAB_PASSWORD
|
||||
if headphones.CFG.SAB_APIKEY:
|
||||
params['apikey'] = headphones.CFG.SAB_APIKEY
|
||||
if headphones.CFG.SAB_CATEGORY:
|
||||
params['cat'] = headphones.CFG.SAB_CATEGORY
|
||||
if headphones.CONFIG.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.CONFIG.SAB_USERNAME
|
||||
if headphones.CONFIG.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.CONFIG.SAB_PASSWORD
|
||||
if headphones.CONFIG.SAB_APIKEY:
|
||||
params['apikey'] = headphones.CONFIG.SAB_APIKEY
|
||||
if headphones.CONFIG.SAB_CATEGORY:
|
||||
params['cat'] = headphones.CONFIG.SAB_CATEGORY
|
||||
|
||||
# if it's a normal result we just pass SAB the URL
|
||||
if nzb.resultType == "nzb":
|
||||
@@ -64,13 +64,13 @@ def sendNZB(nzb):
|
||||
params['mode'] = 'addfile'
|
||||
multiPartParams = {"nzbfile": (helpers.latinToAscii(nzb.name)+".nzb", nzbdata)}
|
||||
|
||||
if not headphones.CFG.SAB_HOST.startswith('http'):
|
||||
headphones.CFG.SAB_HOST = 'http://' + headphones.CFG.SAB_HOST
|
||||
if not headphones.CONFIG.SAB_HOST.startswith('http'):
|
||||
headphones.CONFIG.SAB_HOST = 'http://' + headphones.CONFIG.SAB_HOST
|
||||
|
||||
if headphones.CFG.SAB_HOST.endswith('/'):
|
||||
headphones.CFG.SAB_HOST = headphones.CFG.SAB_HOST[0:len(headphones.CFG.SAB_HOST)-1]
|
||||
if headphones.CONFIG.SAB_HOST.endswith('/'):
|
||||
headphones.CONFIG.SAB_HOST = headphones.CONFIG.SAB_HOST[0:len(headphones.CONFIG.SAB_HOST)-1]
|
||||
|
||||
url = headphones.CFG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
url = headphones.CONFIG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
|
||||
try:
|
||||
|
||||
@@ -92,7 +92,7 @@ def sendNZB(nzb):
|
||||
return False
|
||||
|
||||
except httplib.InvalidURL, e:
|
||||
logger.error(u"Invalid SAB host, check your config. Current host: %s" % headphones.CFG.SAB_HOST)
|
||||
logger.error(u"Invalid SAB host, check your config. Current host: %s" % headphones.CONFIG.SAB_HOST)
|
||||
return False
|
||||
|
||||
except Exception, e:
|
||||
@@ -133,20 +133,20 @@ def checkConfig():
|
||||
'section' : 'misc'
|
||||
}
|
||||
|
||||
if headphones.CFG.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.CFG.SAB_USERNAME
|
||||
if headphones.CFG.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.CFG.SAB_PASSWORD
|
||||
if headphones.CFG.SAB_APIKEY:
|
||||
params['apikey'] = headphones.CFG.SAB_APIKEY
|
||||
if headphones.CONFIG.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.CONFIG.SAB_USERNAME
|
||||
if headphones.CONFIG.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.CONFIG.SAB_PASSWORD
|
||||
if headphones.CONFIG.SAB_APIKEY:
|
||||
params['apikey'] = headphones.CONFIG.SAB_APIKEY
|
||||
|
||||
if not headphones.CFG.SAB_HOST.startswith('http'):
|
||||
headphones.CFG.SAB_HOST = 'http://' + headphones.CFG.SAB_HOST
|
||||
if not headphones.CONFIG.SAB_HOST.startswith('http'):
|
||||
headphones.CONFIG.SAB_HOST = 'http://' + headphones.CONFIG.SAB_HOST
|
||||
|
||||
if headphones.CFG.SAB_HOST.endswith('/'):
|
||||
headphones.CFG.SAB_HOST = headphones.CFG.SAB_HOST[0:len(headphones.CFG.SAB_HOST)-1]
|
||||
if headphones.CONFIG.SAB_HOST.endswith('/'):
|
||||
headphones.CONFIG.SAB_HOST = headphones.CONFIG.SAB_HOST[0:len(headphones.CONFIG.SAB_HOST)-1]
|
||||
|
||||
url = headphones.CFG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
url = headphones.CONFIG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
|
||||
try:
|
||||
f = urllib.urlopen(url).read()
|
||||
|
||||
@@ -206,15 +206,15 @@ def searchforalbum(albumid=None, new=False, losslessOnly=False, choose_specific_
|
||||
|
||||
def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
|
||||
|
||||
NZB_PROVIDERS = (headphones.CFG.HEADPHONES_INDEXER or headphones.CFG.NEWZNAB or headphones.CFG.NZBSORG or headphones.CFG.OMGWTFNZBS)
|
||||
NZB_DOWNLOADERS = (headphones.CFG.SAB_HOST or headphones.CFG.BLACKHOLE_DIR or headphones.CFG.NZBGET_HOST)
|
||||
TORRENT_PROVIDERS = (headphones.CFG.KAT or headphones.CFG.PIRATEBAY or headphones.CFG.MININOVA or headphones.CFG.WAFFLES or headphones.CFG.RUTRACKER or headphones.CFG.WHATCD)
|
||||
NZB_PROVIDERS = (headphones.CONFIG.HEADPHONES_INDEXER or headphones.CONFIG.NEWZNAB or headphones.CONFIG.NZBSORG or headphones.CONFIG.OMGWTFNZBS)
|
||||
NZB_DOWNLOADERS = (headphones.CONFIG.SAB_HOST or headphones.CONFIG.BLACKHOLE_DIR or headphones.CONFIG.NZBGET_HOST)
|
||||
TORRENT_PROVIDERS = (headphones.CONFIG.KAT or headphones.CONFIG.PIRATEBAY or headphones.CONFIG.MININOVA or headphones.CONFIG.WAFFLES or headphones.CONFIG.RUTRACKER or headphones.CONFIG.WHATCD)
|
||||
|
||||
results = []
|
||||
myDB = db.DBConnection()
|
||||
albumlength = myDB.select('SELECT sum(TrackDuration) from tracks WHERE AlbumID=?', [album['AlbumID']])[0][0]
|
||||
|
||||
if headphones.CFG.PREFER_TORRENTS == 0:
|
||||
if headphones.CONFIG.PREFER_TORRENTS == 0:
|
||||
|
||||
if NZB_PROVIDERS and NZB_DOWNLOADERS:
|
||||
results = searchNZB(album, new, losslessOnly, albumlength)
|
||||
@@ -222,7 +222,7 @@ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False):
|
||||
if not results and TORRENT_PROVIDERS:
|
||||
results = searchTorrent(album, new, losslessOnly, albumlength)
|
||||
|
||||
elif headphones.CFG.PREFER_TORRENTS == 1:
|
||||
elif headphones.CONFIG.PREFER_TORRENTS == 1:
|
||||
|
||||
if TORRENT_PROVIDERS:
|
||||
results = searchTorrent(album, new, losslessOnly, albumlength)
|
||||
@@ -277,23 +277,23 @@ def more_filtering(results, album, albumlength, new):
|
||||
myDB = db.DBConnection()
|
||||
|
||||
# Lossless - ignore results if target size outside bitrate range
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 and albumlength and (headphones.CFG.LOSSLESS_BITRATE_FROM or headphones.CFG.LOSSLESS_BITRATE_TO):
|
||||
if headphones.CFG.LOSSLESS_BITRATE_FROM:
|
||||
low_size_limit = albumlength/1000 * int(headphones.CFG.LOSSLESS_BITRATE_FROM) * 128
|
||||
if headphones.CFG.LOSSLESS_BITRATE_TO:
|
||||
high_size_limit = albumlength/1000 * int(headphones.CFG.LOSSLESS_BITRATE_TO) * 128
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 and albumlength and (headphones.CONFIG.LOSSLESS_BITRATE_FROM or headphones.CONFIG.LOSSLESS_BITRATE_TO):
|
||||
if headphones.CONFIG.LOSSLESS_BITRATE_FROM:
|
||||
low_size_limit = albumlength/1000 * int(headphones.CONFIG.LOSSLESS_BITRATE_FROM) * 128
|
||||
if headphones.CONFIG.LOSSLESS_BITRATE_TO:
|
||||
high_size_limit = albumlength/1000 * int(headphones.CONFIG.LOSSLESS_BITRATE_TO) * 128
|
||||
|
||||
# Preferred Bitrate - ignore results if target size outside % buffer
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE:
|
||||
logger.debug('Target bitrate: %s kbps' % headphones.CFG.PREFERRED_BITRATE)
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 2 and headphones.CONFIG.PREFERRED_BITRATE:
|
||||
logger.debug('Target bitrate: %s kbps' % headphones.CONFIG.PREFERRED_BITRATE)
|
||||
if albumlength:
|
||||
targetsize = albumlength/1000 * int(headphones.CFG.PREFERRED_BITRATE) * 128
|
||||
targetsize = albumlength/1000 * int(headphones.CONFIG.PREFERRED_BITRATE) * 128
|
||||
logger.info('Target size: %s' % helpers.bytes_to_mb(targetsize))
|
||||
if headphones.CFG.PREFERRED_BITRATE_LOW_BUFFER:
|
||||
low_size_limit = targetsize - (targetsize * int(headphones.CFG.PREFERRED_BITRATE_LOW_BUFFER)/100)
|
||||
if headphones.CFG.PREFERRED_BITRATE_HIGH_BUFFER:
|
||||
high_size_limit = targetsize + (targetsize * int(headphones.CFG.PREFERRED_BITRATE_HIGH_BUFFER)/100)
|
||||
if headphones.CFG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
if headphones.CONFIG.PREFERRED_BITRATE_LOW_BUFFER:
|
||||
low_size_limit = targetsize - (targetsize * int(headphones.CONFIG.PREFERRED_BITRATE_LOW_BUFFER)/100)
|
||||
if headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER:
|
||||
high_size_limit = targetsize + (targetsize * int(headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER)/100)
|
||||
if headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
allow_lossless = True
|
||||
|
||||
newlist = []
|
||||
@@ -341,8 +341,8 @@ def sort_search_results(resultlist, album, new, albumlength):
|
||||
# Add a priority if it has any of the preferred words
|
||||
temp_list = []
|
||||
preferred_words = None
|
||||
if headphones.CFG.PREFERRED_WORDS:
|
||||
preferred_words = helpers.split_string(headphones.CFG.PREFERRED_WORDS)
|
||||
if headphones.CONFIG.PREFERRED_WORDS:
|
||||
preferred_words = helpers.split_string(headphones.CONFIG.PREFERRED_WORDS)
|
||||
for result in resultlist:
|
||||
priority = 0
|
||||
if preferred_words:
|
||||
@@ -357,10 +357,10 @@ def sort_search_results(resultlist, album, new, albumlength):
|
||||
|
||||
resultlist = temp_list
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 2 and headphones.CONFIG.PREFERRED_BITRATE:
|
||||
|
||||
try:
|
||||
targetsize = albumlength/1000 * int(headphones.CFG.PREFERRED_BITRATE) * 128
|
||||
targetsize = albumlength/1000 * int(headphones.CONFIG.PREFERRED_BITRATE) * 128
|
||||
|
||||
if not targetsize:
|
||||
logger.info('No track information for %s - %s. Defaulting to highest quality' % (album['ArtistName'], album['AlbumTitle']))
|
||||
@@ -382,7 +382,7 @@ def sort_search_results(resultlist, album, new, albumlength):
|
||||
|
||||
finallist = sorted(newlist, key=lambda title: (-title[5], title[6]))
|
||||
|
||||
if not len(finallist) and len(flac_list) and headphones.CFG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
if not len(finallist) and len(flac_list) and headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
logger.info("Since there were no appropriate lossy matches (and at least one lossless match, going to use lossless instead")
|
||||
finallist = sorted(flac_list, key=lambda title: (title[5], int(title[1])), reverse=True)
|
||||
except Exception as e:
|
||||
@@ -440,7 +440,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
artistterm = re.sub('[\.\-\/]', ' ', cleanartist).encode('utf-8')
|
||||
|
||||
# If Preferred Bitrate and High Limit and Allow Lossless then get both lossy and lossless
|
||||
if headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE and headphones.CFG.PREFERRED_BITRATE_HIGH_BUFFER and headphones.CFG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 2 and headphones.CONFIG.PREFERRED_BITRATE and headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER and headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
allow_lossless = True
|
||||
else:
|
||||
allow_lossless = False
|
||||
@@ -449,12 +449,12 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
resultlist = []
|
||||
|
||||
if headphones.CFG.HEADPHONES_INDEXER:
|
||||
if headphones.CONFIG.HEADPHONES_INDEXER:
|
||||
provider = "headphones"
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -471,14 +471,14 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
"t": "search",
|
||||
"cat": categories,
|
||||
"apikey": '964d601959918a578a670984bdee9357',
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"maxage": headphones.CONFIG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
data = request.request_feed(
|
||||
url="http://indexer.codeshy.com/api",
|
||||
params=params, headers=headers,
|
||||
auth=(headphones.CFG.HPUSER, headphones.CFG.HPPASS)
|
||||
auth=(headphones.CONFIG.HPUSER, headphones.CONFIG.HPPASS)
|
||||
)
|
||||
|
||||
# Process feed
|
||||
@@ -498,20 +498,20 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.error(u"An unknown error occurred trying to parse the feed: %s" % e)
|
||||
|
||||
if headphones.CFG.NEWZNAB:
|
||||
if headphones.CONFIG.NEWZNAB:
|
||||
provider = "newznab"
|
||||
newznab_hosts = []
|
||||
|
||||
if headphones.CFG.NEWZNAB_HOST and headphones.CFG.NEWZNAB_ENABLED:
|
||||
newznab_hosts.append((headphones.CFG.NEWZNAB_HOST, headphones.CFG.NEWZNAB_APIKEY, headphones.CFG.NEWZNAB_ENABLED))
|
||||
if headphones.CONFIG.NEWZNAB_HOST and headphones.CONFIG.NEWZNAB_ENABLED:
|
||||
newznab_hosts.append((headphones.CONFIG.NEWZNAB_HOST, headphones.CONFIG.NEWZNAB_APIKEY, headphones.CONFIG.NEWZNAB_ENABLED))
|
||||
|
||||
for newznab_host in headphones.CFG.get_extra_newznabs():
|
||||
for newznab_host in headphones.CONFIG.get_extra_newznabs():
|
||||
if newznab_host[2] == '1' or newznab_host[2] == 1:
|
||||
newznab_hosts.append(newznab_host)
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -543,7 +543,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
"t": "search",
|
||||
"apikey": newznab_host[1],
|
||||
"cat": categories,
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"maxage": headphones.CONFIG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
@@ -571,11 +571,11 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.exception("An unknown error occurred trying to parse the feed: %s" % e)
|
||||
|
||||
if headphones.CFG.NZBSORG:
|
||||
if headphones.CONFIG.NZBSORG:
|
||||
provider = "nzbsorg"
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -590,9 +590,9 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
headers = { 'User-Agent': USER_AGENT }
|
||||
params = {
|
||||
"t": "search",
|
||||
"apikey": headphones.CFG.NZBSORG_HASH,
|
||||
"apikey": headphones.CONFIG.NZBSORG_HASH,
|
||||
"cat": categories,
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"maxage": headphones.CONFIG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
@@ -617,12 +617,12 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.exception("Unhandled exception while parsing feed")
|
||||
|
||||
if headphones.CFG.OMGWTFNZBS:
|
||||
if headphones.CONFIG.OMGWTFNZBS:
|
||||
provider = "omgwtfnzbs"
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "22"
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "22,7"
|
||||
else:
|
||||
categories = "7"
|
||||
@@ -636,10 +636,10 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
headers = { 'User-Agent': USER_AGENT }
|
||||
params = {
|
||||
"user": headphones.CFG.OMGWTFNZBS_UID,
|
||||
"api": headphones.CFG.OMGWTFNZBS_APIKEY,
|
||||
"user": headphones.CONFIG.OMGWTFNZBS_UID,
|
||||
"api": headphones.CONFIG.OMGWTFNZBS_APIKEY,
|
||||
"catid": categories,
|
||||
"retention": headphones.CFG.USENET_RETENTION,
|
||||
"retention": headphones.CONFIG.USENET_RETENTION,
|
||||
"search": term
|
||||
}
|
||||
|
||||
@@ -689,7 +689,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if kind == 'nzb':
|
||||
folder_name = helpers.sab_sanitize_foldername(bestqual[0])
|
||||
|
||||
if headphones.CFG.NZB_DOWNLOADER == 1:
|
||||
if headphones.CONFIG.NZB_DOWNLOADER == 1:
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
@@ -697,7 +697,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if not nzbget.sendNZB(nzb):
|
||||
return
|
||||
|
||||
elif headphones.CFG.NZB_DOWNLOADER == 0:
|
||||
elif headphones.CONFIG.NZB_DOWNLOADER == 0:
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
@@ -715,7 +715,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
|
||||
else:
|
||||
nzb_name = folder_name + '.nzb'
|
||||
download_path = os.path.join(headphones.CFG.BLACKHOLE_DIR, nzb_name)
|
||||
download_path = os.path.join(headphones.CONFIG.BLACKHOLE_DIR, nzb_name)
|
||||
|
||||
try:
|
||||
prev = os.umask(headphones.UMASK)
|
||||
@@ -732,14 +732,14 @@ def send_to_downloader(data, bestqual, album):
|
||||
folder_name = '%s - %s [%s]' % (helpers.latinToAscii(album['ArtistName']).encode('UTF-8').replace('/', '_'), helpers.latinToAscii(album['AlbumTitle']).encode('UTF-8').replace('/', '_'), get_year_from_release_date(album['ReleaseDate']))
|
||||
|
||||
# Blackhole
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 0:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 0:
|
||||
|
||||
# Get torrent name from .torrent, this is usually used by the torrent client as the folder name
|
||||
torrent_name = helpers.replace_illegal_chars(folder_name) + '.torrent'
|
||||
download_path = os.path.join(headphones.CFG.TORRENTBLACKHOLE_DIR, torrent_name)
|
||||
download_path = os.path.join(headphones.CONFIG.TORRENTBLACKHOLE_DIR, torrent_name)
|
||||
|
||||
if bestqual[2].lower().startswith("magnet:"):
|
||||
if headphones.CFG.MAGNET_LINKS == 1:
|
||||
if headphones.CONFIG.MAGNET_LINKS == 1:
|
||||
try:
|
||||
if headphones.SYS_PLATFORM == 'win32':
|
||||
os.startfile(bestqual[2])
|
||||
@@ -798,7 +798,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
# Extract folder name from torrent
|
||||
folder_name = read_torrent_name(download_path, bestqual[0])
|
||||
|
||||
elif headphones.CFG.TORRENT_DOWNLOADER == 1:
|
||||
elif headphones.CONFIG.TORRENT_DOWNLOADER == 1:
|
||||
logger.info("Sending torrent to Transmission")
|
||||
|
||||
# rutracker needs cookies to be set, pass the .torrent file instead of url
|
||||
@@ -832,7 +832,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if seed_ratio is not None:
|
||||
transmission.setSeedRatio(torrentid, seed_ratio)
|
||||
|
||||
else:# if headphones.CFG.TORRENT_DOWNLOADER == 2:
|
||||
else:# if headphones.CONFIG.TORRENT_DOWNLOADER == 2:
|
||||
logger.info("Sending torrent to uTorrent")
|
||||
|
||||
# rutracker needs cookies to be set, pass the .torrent file instead of url
|
||||
@@ -882,39 +882,39 @@ def send_to_downloader(data, bestqual, album):
|
||||
provider = provider.split("//")[1]
|
||||
name = folder_name if folder_name else None
|
||||
|
||||
if headphones.CFG.GROWL_ENABLED and headphones.CFG.GROWL_ONSNATCH:
|
||||
if headphones.CONFIG.GROWL_ENABLED and headphones.CONFIG.GROWL_ONSNATCH:
|
||||
logger.info(u"Sending Growl notification")
|
||||
growl = notifiers.GROWL()
|
||||
growl.notify(name,"Download started")
|
||||
if headphones.CFG.PROWL_ENABLED and headphones.CFG.PROWL_ONSNATCH:
|
||||
if headphones.CONFIG.PROWL_ENABLED and headphones.CONFIG.PROWL_ONSNATCH:
|
||||
logger.info(u"Sending Prowl notification")
|
||||
prowl = notifiers.PROWL()
|
||||
prowl.notify(name,"Download started")
|
||||
if headphones.CFG.PUSHOVER_ENABLED and headphones.CFG.PUSHOVER_ONSNATCH:
|
||||
if headphones.CONFIG.PUSHOVER_ENABLED and headphones.CONFIG.PUSHOVER_ONSNATCH:
|
||||
logger.info(u"Sending Pushover notification")
|
||||
prowl = notifiers.PUSHOVER()
|
||||
prowl.notify(name,"Download started")
|
||||
if headphones.CFG.PUSHBULLET_ENABLED and headphones.CFG.PUSHBULLET_ONSNATCH:
|
||||
if headphones.CONFIG.PUSHBULLET_ENABLED and headphones.CONFIG.PUSHBULLET_ONSNATCH:
|
||||
logger.info(u"Sending PushBullet notification")
|
||||
pushbullet = notifiers.PUSHBULLET()
|
||||
pushbullet.notify(name + " has been snatched!", "Download started")
|
||||
if headphones.CFG.TWITTER_ENABLED and headphones.CFG.TWITTER_ONSNATCH:
|
||||
if headphones.CONFIG.TWITTER_ENABLED and headphones.CONFIG.TWITTER_ONSNATCH:
|
||||
logger.info(u"Sending Twitter notification")
|
||||
twitter = notifiers.TwitterNotifier()
|
||||
twitter.notify_snatch(name)
|
||||
if headphones.CFG.NMA_ENABLED and headphones.CFG.NMA_ONSNATCH:
|
||||
if headphones.CONFIG.NMA_ENABLED and headphones.CONFIG.NMA_ONSNATCH:
|
||||
logger.info(u"Sending NMA notification")
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(snatched=name)
|
||||
if headphones.CFG.PUSHALOT_ENABLED and headphones.CFG.PUSHALOT_ONSNATCH:
|
||||
if headphones.CONFIG.PUSHALOT_ENABLED and headphones.CONFIG.PUSHALOT_ONSNATCH:
|
||||
logger.info(u"Sending Pushalot notification")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(name,"Download started")
|
||||
if headphones.CFG.OSX_NOTIFY_ENABLED and headphones.CFG.OSX_NOTIFY_ONSNATCH:
|
||||
if headphones.CONFIG.OSX_NOTIFY_ENABLED and headphones.CONFIG.OSX_NOTIFY_ONSNATCH:
|
||||
logger.info(u"Sending OS X notification")
|
||||
osx_notify = notifiers.OSX_NOTIFY()
|
||||
osx_notify.notify(artist, albumname, 'Snatched: ' + provider + '. ' + name)
|
||||
if headphones.CFG.BOXCAR_ENABLED and headphones.CFG.BOXCAR_ONSNATCH:
|
||||
if headphones.CONFIG.BOXCAR_ENABLED and headphones.CONFIG.BOXCAR_ONSNATCH:
|
||||
logger.info(u"Sending Boxcar2 notification")
|
||||
b2msg = 'From ' + provider + '<br></br>' + name
|
||||
boxcar = notifiers.BOXCAR()
|
||||
@@ -944,18 +944,18 @@ def verifyresult(title, artistterm, term, lossless):
|
||||
return False
|
||||
|
||||
# Filter out FLAC if we're not specifically looking for it
|
||||
if headphones.CFG.PREFERRED_QUALITY == (0 or '0') and 'flac' in title.lower() and not lossless:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == (0 or '0') and 'flac' in title.lower() and not lossless:
|
||||
logger.info("Removed %s from results because it's a lossless album and we're not looking for a lossless album right now.", title)
|
||||
return False
|
||||
|
||||
if headphones.CFG.IGNORED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CFG.IGNORED_WORDS):
|
||||
if headphones.CONFIG.IGNORED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CONFIG.IGNORED_WORDS):
|
||||
if each_word.lower() in title.lower():
|
||||
logger.info("Removed '%s' from results because it contains ignored word: '%s'", title, each_word)
|
||||
return False
|
||||
|
||||
if headphones.CFG.REQUIRED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CFG.REQUIRED_WORDS):
|
||||
if headphones.CONFIG.REQUIRED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CONFIG.REQUIRED_WORDS):
|
||||
if ' OR ' in each_word:
|
||||
or_words = helpers.split_string(each_word, 'OR')
|
||||
if any(word.lower() in title.lower() for word in or_words):
|
||||
@@ -990,8 +990,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
# rutracker login
|
||||
|
||||
if headphones.CFG.RUTRACKER and album:
|
||||
rulogin = rutracker.login(headphones.CFG.RUTRACKER_USER, headphones.CFG.RUTRACKER_PASSWORD)
|
||||
if headphones.CONFIG.RUTRACKER and album:
|
||||
rulogin = rutracker.login(headphones.CONFIG.RUTRACKER_USER, headphones.CONFIG.RUTRACKER_PASSWORD)
|
||||
if not rulogin:
|
||||
logger.info(u'Could not login to rutracker, search results will exclude this provider')
|
||||
|
||||
@@ -1038,7 +1038,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
albumterm = re.sub('[\.\-\/]', ' ', cleanalbum).encode('utf-8', 'replace')
|
||||
|
||||
# If Preferred Bitrate and High Limit and Allow Lossless then get both lossy and lossless
|
||||
if headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE and headphones.CFG.PREFERRED_BITRATE_HIGH_BUFFER and headphones.CFG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 2 and headphones.CONFIG.PREFERRED_BITRATE and headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER and headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
allow_lossless = True
|
||||
else:
|
||||
allow_lossless = False
|
||||
@@ -1047,7 +1047,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
resultlist = []
|
||||
pre_sorted_results = False
|
||||
minimumseeders = int(headphones.CFG.NUMBEROFSEEDERS) - 1
|
||||
minimumseeders = int(headphones.CONFIG.NUMBEROFSEEDERS) - 1
|
||||
|
||||
def set_proxy(proxy_url):
|
||||
if not proxy_url.startswith('http'):
|
||||
@@ -1058,13 +1058,13 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
return proxy_url
|
||||
|
||||
|
||||
if headphones.CFG.KAT:
|
||||
if headphones.CONFIG.KAT:
|
||||
provider = "Kick Ass Torrents"
|
||||
ka_term = term.replace("!", "")
|
||||
|
||||
# Use proxy if specified
|
||||
if headphones.CFG.KAT_PROXY_URL:
|
||||
providerurl = fix_url(set_proxy(headphones.CFG.KAT_PROXY_URL))
|
||||
if headphones.CONFIG.KAT_PROXY_URL:
|
||||
providerurl = fix_url(set_proxy(headphones.CONFIG.KAT_PROXY_URL))
|
||||
else:
|
||||
providerurl = fix_url("https://kickass.to")
|
||||
|
||||
@@ -1072,11 +1072,11 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
providerurl = providerurl + "/usearch/" + ka_term
|
||||
|
||||
# Pick category for torrents
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "7" # Music
|
||||
format = "2" # FLAC
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "7" # Music
|
||||
format = "10" # MP3 and FLAC
|
||||
maxsize = 10000000000
|
||||
@@ -1122,16 +1122,16 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.exception("Unhandled exception in the KAT parser")
|
||||
|
||||
if headphones.CFG.WAFFLES:
|
||||
if headphones.CONFIG.WAFFLES:
|
||||
provider = "Waffles.fm"
|
||||
providerurl = fix_url("https://www.waffles.fm/browse.php")
|
||||
|
||||
bitrate = None
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = "FLAC"
|
||||
bitrate = "(Lossless)"
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
format = "FLAC OR MP3"
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1156,8 +1156,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
logger.info('Parsing results from Waffles')
|
||||
|
||||
params = {
|
||||
"uid": headphones.CFG.WAFFLES_UID,
|
||||
"passkey": headphones.CFG.WAFFLES_PASSKEY,
|
||||
"uid": headphones.CONFIG.WAFFLES_UID,
|
||||
"passkey": headphones.CONFIG.WAFFLES_PASSKEY,
|
||||
"rss": "1",
|
||||
"c0": "1",
|
||||
"s": "seeders", # sort by
|
||||
@@ -1188,7 +1188,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
logger.error(u"An error occurred while trying to parse the response from Waffles.fm: %s", e)
|
||||
|
||||
# rutracker.org
|
||||
if headphones.CFG.RUTRACKER and rulogin:
|
||||
if headphones.CONFIG.RUTRACKER and rulogin:
|
||||
|
||||
provider = "rutracker.org"
|
||||
|
||||
@@ -1197,10 +1197,10 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
logger.info(u'Release date not specified, ignoring for rutracker.org')
|
||||
else:
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = 'lossless'
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
format = 'lossless+mp3'
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1229,19 +1229,19 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
else:
|
||||
logger.info(u"No valid results found from %s" % (provider))
|
||||
|
||||
if headphones.CFG.WHATCD:
|
||||
if headphones.CONFIG.WHATCD:
|
||||
provider = "What.cd"
|
||||
providerurl = "http://what.cd/"
|
||||
|
||||
bitrate = None
|
||||
bitrate_string = bitrate
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly: # Lossless Only mode
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly: # Lossless Only mode
|
||||
search_formats = [gazelleformat.FLAC]
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 2: # Preferred quality mode
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 2: # Preferred quality mode
|
||||
search_formats = [None] # should return all
|
||||
bitrate = headphones.CFG.PREFERRED_BITRATE
|
||||
bitrate = headphones.CONFIG.PREFERRED_BITRATE
|
||||
if bitrate:
|
||||
for encoding_string in gazelleencoding.ALL_ENCODINGS:
|
||||
if re.search(bitrate, encoding_string, flags=re.I):
|
||||
@@ -1249,7 +1249,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
if bitrate_string not in gazelleencoding.ALL_ENCODINGS:
|
||||
logger.info(u"Your preferred bitrate is not one of the available What.cd filters, so not using it as a search parameter.")
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless: # Highest quality including lossless
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless: # Highest quality including lossless
|
||||
search_formats = [gazelleformat.FLAC, gazelleformat.MP3]
|
||||
maxsize = 10000000000
|
||||
else: # Highest quality excluding lossless
|
||||
@@ -1259,7 +1259,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
if not gazelle or not gazelle.logged_in():
|
||||
try:
|
||||
logger.info(u"Attempting to log in to What.cd...")
|
||||
gazelle = gazelleapi.GazelleAPI(headphones.CFG.WHATCD_USERNAME, headphones.CFG.WHATCD_PASSWORD)
|
||||
gazelle = gazelleapi.GazelleAPI(headphones.CONFIG.WHATCD_USERNAME, headphones.CONFIG.WHATCD_PASSWORD)
|
||||
gazelle._login()
|
||||
except Exception as e:
|
||||
gazelle = None
|
||||
@@ -1309,13 +1309,13 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
'torrent'))
|
||||
|
||||
# Pirate Bay
|
||||
if headphones.CFG.PIRATEBAY:
|
||||
if headphones.CONFIG.PIRATEBAY:
|
||||
provider = "The Pirate Bay"
|
||||
tpb_term = term.replace("!", "")
|
||||
|
||||
# Use proxy if specified
|
||||
if headphones.CFG.PIRATEBAY_PROXY_URL:
|
||||
providerurl = fix_url(set_proxy(headphones.CFG.PIRATEBAY_PROXY_URL))
|
||||
if headphones.CONFIG.PIRATEBAY_PROXY_URL:
|
||||
providerurl = fix_url(set_proxy(headphones.CONFIG.PIRATEBAY_PROXY_URL))
|
||||
else:
|
||||
providerurl = fix_url("https://thepiratebay.se")
|
||||
|
||||
@@ -1323,10 +1323,10 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
providerurl = providerurl + "/search/" + tpb_term + "/0/7/" # 7 is sort by seeders
|
||||
|
||||
# Pick category for torrents
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
category = '104' # FLAC
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
category = '100' # General audio category
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1353,7 +1353,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
title = ''.join(item.find("a", {"class" : "detLink"}))
|
||||
seeds = int(''.join(item.find("td", {"align" : "right"})))
|
||||
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 0:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 0:
|
||||
try:
|
||||
url = item.find("a", {"title":"Download this torrent"})['href']
|
||||
except TypeError:
|
||||
@@ -1379,15 +1379,15 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.error(u"An unknown error occurred in the Pirate Bay parser: %s" % e)
|
||||
|
||||
if headphones.CFG.MININOVA:
|
||||
if headphones.CONFIG.MININOVA:
|
||||
provider = "Mininova"
|
||||
providerurl = fix_url("http://www.mininova.org/rss/" + term + "/5")
|
||||
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CONFIG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "7" #music
|
||||
format = "2" #flac
|
||||
maxsize = 10000000000
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CONFIG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "7" #music
|
||||
format = "10" #mp3+flac
|
||||
maxsize = 10000000000
|
||||
@@ -1451,7 +1451,7 @@ def preprocess(resultlist):
|
||||
for result in resultlist:
|
||||
if result[4] == 'torrent':
|
||||
#Get out of here if we're using Transmission
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 1: ## if not a magnet link still need the .torrent to generate hash... uTorrent support labeling
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 1: ## if not a magnet link still need the .torrent to generate hash... uTorrent support labeling
|
||||
return True, result
|
||||
# get outta here if rutracker
|
||||
if result[3] == 'rutracker.org':
|
||||
@@ -1475,6 +1475,6 @@ def preprocess(resultlist):
|
||||
headers = {'User-Agent': USER_AGENT}
|
||||
|
||||
if result[3] == 'headphones':
|
||||
return request.request_content(url=result[2], headers=headers, auth=(headphones.CFG.HPUSER, headphones.CFG.HPPASS)), result
|
||||
return request.request_content(url=result[2], headers=headers, auth=(headphones.CONFIG.HPUSER, headphones.CONFIG.HPPASS)), result
|
||||
else:
|
||||
return request.request_content(url=result[2], headers=headers), result
|
||||
|
||||
@@ -294,7 +294,7 @@ class Rutracker():
|
||||
os.umask(prev)
|
||||
|
||||
# Add file to utorrent
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 2:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 2:
|
||||
self.utorrent_add_file(download_path)
|
||||
|
||||
except Exception as e:
|
||||
@@ -306,7 +306,7 @@ class Rutracker():
|
||||
#TODO get this working in utorrent.py
|
||||
def utorrent_add_file(self, filename):
|
||||
|
||||
host = headphones.CFG.UTORRENT_HOST
|
||||
host = headphones.CONFIG.UTORRENT_HOST
|
||||
if not host.startswith('http'):
|
||||
host = 'http://' + host
|
||||
if host.endswith('/'):
|
||||
@@ -315,8 +315,8 @@ class Rutracker():
|
||||
host = host[:-4]
|
||||
|
||||
base_url = host
|
||||
username = headphones.CFG.UTORRENT_USERNAME
|
||||
password = headphones.CFG.UTORRENT_PASSWORD
|
||||
username = headphones.CONFIG.UTORRENT_USERNAME
|
||||
password = headphones.CONFIG.UTORRENT_PASSWORD
|
||||
|
||||
session = requests.Session()
|
||||
url = base_url + '/gui/'
|
||||
|
||||
@@ -33,7 +33,7 @@ def checkTorrentFinished():
|
||||
hash = album['FolderName']
|
||||
albumid = album['AlbumID']
|
||||
torrent_removed = False
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 1:
|
||||
if headphones.CONFIG.TORRENT_DOWNLOADER == 1:
|
||||
torrent_removed = transmission.removeTorrent(hash, True)
|
||||
else:
|
||||
torrent_removed = utorrent.removeTorrent(hash, True)
|
||||
|
||||
@@ -33,9 +33,9 @@ def addTorrent(link):
|
||||
if link.endswith('.torrent'):
|
||||
with open(link, 'rb') as f:
|
||||
metainfo = str(base64.b64encode(f.read()))
|
||||
arguments = {'metainfo': metainfo, 'download-dir':headphones.CFG.DOWNLOAD_TORRENT_DIR}
|
||||
arguments = {'metainfo': metainfo, 'download-dir':headphones.CONFIG.DOWNLOAD_TORRENT_DIR}
|
||||
else:
|
||||
arguments = {'filename': link, 'download-dir': headphones.CFG.DOWNLOAD_TORRENT_DIR}
|
||||
arguments = {'filename': link, 'download-dir': headphones.CONFIG.DOWNLOAD_TORRENT_DIR}
|
||||
|
||||
response = torrentAction(method,arguments)
|
||||
|
||||
@@ -122,9 +122,9 @@ def removeTorrent(torrentid, remove_data = False):
|
||||
|
||||
def torrentAction(method, arguments):
|
||||
|
||||
host = headphones.CFG.TRANSMISSION_HOST
|
||||
username = headphones.CFG.TRANSMISSION_USERNAME
|
||||
password = headphones.CFG.TRANSMISSION_PASSWORD
|
||||
host = headphones.CONFIG.TRANSMISSION_HOST
|
||||
username = headphones.CONFIG.TRANSMISSION_USERNAME
|
||||
password = headphones.CONFIG.TRANSMISSION_PASSWORD
|
||||
sessionid = None
|
||||
|
||||
if not host.startswith('http'):
|
||||
|
||||
@@ -28,7 +28,7 @@ class utorrentclient(object):
|
||||
|
||||
def __init__(self, base_url = None, username = None, password = None,):
|
||||
|
||||
host = headphones.CFG.UTORRENT_HOST
|
||||
host = headphones.CONFIG.UTORRENT_HOST
|
||||
if not host.startswith('http'):
|
||||
host = 'http://' + host
|
||||
|
||||
@@ -39,8 +39,8 @@ class utorrentclient(object):
|
||||
host = host[:-4]
|
||||
|
||||
self.base_url = host
|
||||
self.username = headphones.CFG.UTORRENT_USERNAME
|
||||
self.password = headphones.CFG.UTORRENT_PASSWORD
|
||||
self.username = headphones.CONFIG.UTORRENT_USERNAME
|
||||
self.password = headphones.CONFIG.UTORRENT_PASSWORD
|
||||
self.opener = self._make_opener('uTorrent', self.base_url, self.username, self.password)
|
||||
self.token = self._get_token()
|
||||
#TODO refresh token, when necessary
|
||||
@@ -157,7 +157,7 @@ class utorrentclient(object):
|
||||
logger.debug('uTorrent webUI raised the following error: ' + str(err))
|
||||
|
||||
def labelTorrent(hash):
|
||||
label = headphones.CFG.UTORRENT_LABEL
|
||||
label = headphones.CONFIG.UTORRENT_LABEL
|
||||
uTorrentClient = utorrentclient()
|
||||
if label:
|
||||
uTorrentClient.setprops(hash,'label',label)
|
||||
|
||||
@@ -24,8 +24,8 @@ from headphones import logger, version, request
|
||||
|
||||
def runGit(args):
|
||||
|
||||
if headphones.CFG.GIT_PATH:
|
||||
git_locations = ['"'+headphones.CFG.GIT_PATH+'"']
|
||||
if headphones.CONFIG.GIT_PATH:
|
||||
git_locations = ['"'+headphones.CONFIG.GIT_PATH+'"']
|
||||
else:
|
||||
git_locations = ['git']
|
||||
|
||||
@@ -82,16 +82,16 @@ def getVersion():
|
||||
logger.error('Output doesn\'t look like a hash, not using it')
|
||||
cur_commit_hash = None
|
||||
|
||||
if headphones.CFG.DO_NOT_OVERRIDE_GIT_BRANCH and headphones.CFG.GIT_BRANCH:
|
||||
branch_name = headphones.CFG.GIT_BRANCH
|
||||
if headphones.CONFIG.DO_NOT_OVERRIDE_GIT_BRANCH and headphones.CONFIG.GIT_BRANCH:
|
||||
branch_name = headphones.CONFIG.GIT_BRANCH
|
||||
|
||||
else:
|
||||
branch_name, err = runGit('rev-parse --abbrev-ref HEAD')
|
||||
branch_name = branch_name
|
||||
|
||||
if not branch_name and headphones.CFG.GIT_BRANCH:
|
||||
logger.error('Could not retrieve branch name from git. Falling back to %s' % headphones.CFG.GIT_BRANCH)
|
||||
branch_name = headphones.CFG.GIT_BRANCH
|
||||
if not branch_name and headphones.CONFIG.GIT_BRANCH:
|
||||
logger.error('Could not retrieve branch name from git. Falling back to %s' % headphones.CONFIG.GIT_BRANCH)
|
||||
branch_name = headphones.CONFIG.GIT_BRANCH
|
||||
if not branch_name:
|
||||
logger.error('Could not retrieve branch name from git. Defaulting to master')
|
||||
branch_name = 'master'
|
||||
@@ -111,7 +111,7 @@ def getVersion():
|
||||
current_version = f.read().strip(' \n\r')
|
||||
|
||||
if current_version:
|
||||
return current_version, headphones.CFG.GIT_BRANCH
|
||||
return current_version, headphones.CONFIG.GIT_BRANCH
|
||||
else:
|
||||
return None, 'master'
|
||||
|
||||
@@ -120,7 +120,7 @@ def checkGithub():
|
||||
|
||||
# Get the latest version available from github
|
||||
logger.info('Retrieving latest version information from GitHub')
|
||||
url = 'https://api.github.com/repos/%s/headphones/commits/%s' % (headphones.CFG.GIT_USER, headphones.CFG.GIT_BRANCH)
|
||||
url = 'https://api.github.com/repos/%s/headphones/commits/%s' % (headphones.CONFIG.GIT_USER, headphones.CONFIG.GIT_BRANCH)
|
||||
version = request.request_json(url, timeout=20, validator=lambda x: type(x) == dict)
|
||||
|
||||
if version is None:
|
||||
@@ -140,7 +140,7 @@ def checkGithub():
|
||||
return headphones.LATEST_VERSION
|
||||
|
||||
logger.info('Comparing currently installed version with latest GitHub version')
|
||||
url = 'https://api.github.com/repos/%s/headphones/compare/%s...%s' % (headphones.CFG.GIT_USER, headphones.LATEST_VERSION, headphones.CURRENT_VERSION)
|
||||
url = 'https://api.github.com/repos/%s/headphones/compare/%s...%s' % (headphones.CONFIG.GIT_USER, headphones.LATEST_VERSION, headphones.CURRENT_VERSION)
|
||||
commits = request.request_json(url, timeout=20, whitelist_status_code=404, validator=lambda x: type(x) == dict)
|
||||
|
||||
if commits is None:
|
||||
@@ -166,7 +166,7 @@ def update():
|
||||
logger.info('Windows .exe updating not supported yet.')
|
||||
|
||||
elif headphones.INSTALL_TYPE == 'git':
|
||||
output, err = runGit('pull origin ' + headphones.CFG.GIT_BRANCH)
|
||||
output, err = runGit('pull origin ' + headphones.CONFIG.GIT_BRANCH)
|
||||
|
||||
if not output:
|
||||
logger.error('Couldn\'t download latest version')
|
||||
@@ -181,7 +181,7 @@ def update():
|
||||
logger.info('Output: ' + str(output))
|
||||
|
||||
else:
|
||||
tar_download_url = 'https://github.com/%s/headphones/tarball/%s' % (headphones.CFG.GIT_USER, headphones.CFG.GIT_BRANCH)
|
||||
tar_download_url = 'https://github.com/%s/headphones/tarball/%s' % (headphones.CONFIG.GIT_USER, headphones.CONFIG.GIT_BRANCH)
|
||||
update_dir = os.path.join(headphones.PROG_DIR, 'update')
|
||||
version_path = os.path.join(headphones.PROG_DIR, 'version.txt')
|
||||
|
||||
@@ -192,7 +192,7 @@ def update():
|
||||
logger.error("Unable to retrieve new version from '%s', can't update", tar_download_url)
|
||||
return
|
||||
|
||||
download_name = headphones.CFG.GIT_BRANCH + '-github'
|
||||
download_name = headphones.CONFIG.GIT_BRANCH + '-github'
|
||||
tar_download_path = os.path.join(headphones.PROG_DIR, download_name)
|
||||
|
||||
# Save tar to disk
|
||||
|
||||
@@ -40,7 +40,7 @@ except ImportError:
|
||||
def serve_template(templatename, **kwargs):
|
||||
|
||||
interface_dir = os.path.join(str(headphones.PROG_DIR), 'data/interfaces/')
|
||||
template_dir = os.path.join(str(interface_dir), headphones.CFG.INTERFACE)
|
||||
template_dir = os.path.join(str(interface_dir), headphones.CONFIG.INTERFACE)
|
||||
|
||||
_hplookup = TemplateLookup(directories=[template_dir])
|
||||
|
||||
@@ -674,7 +674,7 @@ class WebInterface(object):
|
||||
markArtists.exposed = True
|
||||
|
||||
def importLastFM(self, username):
|
||||
headphones.CFG.LASTFM_USERNAME = username
|
||||
headphones.CONFIG.LASTFM_USERNAME = username
|
||||
headphones.config_write()
|
||||
threading.Thread(target=lastfm.getArtists).start()
|
||||
raise cherrypy.HTTPRedirect("home")
|
||||
@@ -686,7 +686,7 @@ class WebInterface(object):
|
||||
importLastFMTag.exposed = True
|
||||
|
||||
def importItunes(self, path):
|
||||
headphones.CFG.PATH_TO_XML = path
|
||||
headphones.CONFIG.PATH_TO_XML = path
|
||||
headphones.config_write()
|
||||
threading.Thread(target=importer.itunesImport, args=[path]).start()
|
||||
time.sleep(10)
|
||||
@@ -694,9 +694,9 @@ class WebInterface(object):
|
||||
importItunes.exposed = True
|
||||
|
||||
def musicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0):
|
||||
headphones.CFG.LIBRARYSCAN = libraryscan
|
||||
headphones.CFG.AUTO_ADD_ARTISTS = autoadd
|
||||
headphones.CFG.MUSIC_DIR = path
|
||||
headphones.CONFIG.LIBRARYSCAN = libraryscan
|
||||
headphones.CONFIG.AUTO_ADD_ARTISTS = autoadd
|
||||
headphones.CONFIG.MUSIC_DIR = path
|
||||
headphones.config_write()
|
||||
if scan:
|
||||
try:
|
||||
@@ -952,208 +952,208 @@ class WebInterface(object):
|
||||
interface_list = [ name for name in os.listdir(interface_dir) if os.path.isdir(os.path.join(interface_dir, name)) ]
|
||||
|
||||
config = {
|
||||
"http_host" : headphones.CFG.HTTP_HOST,
|
||||
"http_user" : headphones.CFG.HTTP_USERNAME,
|
||||
"http_port" : headphones.CFG.HTTP_PORT,
|
||||
"http_pass" : headphones.CFG.HTTP_PASSWORD,
|
||||
"launch_browser" : checked(headphones.CFG.LAUNCH_BROWSER),
|
||||
"enable_https" : checked(headphones.CFG.ENABLE_HTTPS),
|
||||
"https_cert" : headphones.CFG.HTTPS_CERT,
|
||||
"https_key" : headphones.CFG.HTTPS_KEY,
|
||||
"api_enabled" : checked(headphones.CFG.API_ENABLED),
|
||||
"api_key" : headphones.CFG.API_KEY,
|
||||
"download_scan_interval" : headphones.CFG.DOWNLOAD_SCAN_INTERVAL,
|
||||
"update_db_interval" : headphones.CFG.UPDATE_DB_INTERVAL,
|
||||
"mb_ignore_age" : headphones.CFG.MB_IGNORE_AGE,
|
||||
"search_interval" : headphones.CFG.SEARCH_INTERVAL,
|
||||
"libraryscan_interval" : headphones.CFG.LIBRARYSCAN_INTERVAL,
|
||||
"sab_host" : headphones.CFG.SAB_HOST,
|
||||
"sab_user" : headphones.CFG.SAB_USERNAME,
|
||||
"sab_api" : headphones.CFG.SAB_APIKEY,
|
||||
"sab_pass" : headphones.CFG.SAB_PASSWORD,
|
||||
"sab_cat" : headphones.CFG.SAB_CATEGORY,
|
||||
"nzbget_host" : headphones.CFG.NZBGET_HOST,
|
||||
"nzbget_user" : headphones.CFG.NZBGET_USERNAME,
|
||||
"nzbget_pass" : headphones.CFG.NZBGET_PASSWORD,
|
||||
"nzbget_cat" : headphones.CFG.NZBGET_CATEGORY,
|
||||
"nzbget_priority" : headphones.CFG.NZBGET_PRIORITY,
|
||||
"transmission_host" : headphones.CFG.TRANSMISSION_HOST,
|
||||
"transmission_user" : headphones.CFG.TRANSMISSION_USERNAME,
|
||||
"transmission_pass" : headphones.CFG.TRANSMISSION_PASSWORD,
|
||||
"utorrent_host" : headphones.CFG.UTORRENT_HOST,
|
||||
"utorrent_user" : headphones.CFG.UTORRENT_USERNAME,
|
||||
"utorrent_pass" : headphones.CFG.UTORRENT_PASSWORD,
|
||||
"utorrent_label" : headphones.CFG.UTORRENT_LABEL,
|
||||
"nzb_downloader_sabnzbd" : radio(headphones.CFG.NZB_DOWNLOADER, 0),
|
||||
"nzb_downloader_nzbget" : radio(headphones.CFG.NZB_DOWNLOADER, 1),
|
||||
"nzb_downloader_blackhole" : radio(headphones.CFG.NZB_DOWNLOADER, 2),
|
||||
"torrent_downloader_blackhole" : radio(headphones.CFG.TORRENT_DOWNLOADER, 0),
|
||||
"torrent_downloader_transmission" : radio(headphones.CFG.TORRENT_DOWNLOADER, 1),
|
||||
"torrent_downloader_utorrent" : radio(headphones.CFG.TORRENT_DOWNLOADER, 2),
|
||||
"download_dir" : headphones.CFG.DOWNLOAD_DIR,
|
||||
"use_blackhole" : checked(headphones.CFG.BLACKHOLE),
|
||||
"blackhole_dir" : headphones.CFG.BLACKHOLE_DIR,
|
||||
"usenet_retention" : headphones.CFG.USENET_RETENTION,
|
||||
"headphones_indexer" : checked(headphones.CFG.HEADPHONES_INDEXER),
|
||||
"use_newznab" : checked(headphones.CFG.NEWZNAB),
|
||||
"newznab_host" : headphones.CFG.NEWZNAB_HOST,
|
||||
"newznab_api" : headphones.CFG.NEWZNAB_APIKEY,
|
||||
"newznab_enabled" : checked(headphones.CFG.NEWZNAB_ENABLED),
|
||||
"extra_newznabs" : headphones.CFG.get_extra_newznabs(),
|
||||
"use_nzbsorg" : checked(headphones.CFG.NZBSORG),
|
||||
"nzbsorg_uid" : headphones.CFG.NZBSORG_UID,
|
||||
"nzbsorg_hash" : headphones.CFG.NZBSORG_HASH,
|
||||
"use_omgwtfnzbs" : checked(headphones.CFG.OMGWTFNZBS),
|
||||
"omgwtfnzbs_uid" : headphones.CFG.OMGWTFNZBS_UID,
|
||||
"omgwtfnzbs_apikey" : headphones.CFG.OMGWTFNZBS_APIKEY,
|
||||
"preferred_words" : headphones.CFG.PREFERRED_WORDS,
|
||||
"ignored_words" : headphones.CFG.IGNORED_WORDS,
|
||||
"required_words" : headphones.CFG.REQUIRED_WORDS,
|
||||
"torrentblackhole_dir" : headphones.CFG.TORRENTBLACKHOLE_DIR,
|
||||
"download_torrent_dir" : headphones.CFG.DOWNLOAD_TORRENT_DIR,
|
||||
"numberofseeders" : headphones.CFG.NUMBEROFSEEDERS,
|
||||
"use_kat" : checked(headphones.CFG.KAT),
|
||||
"kat_proxy_url" : headphones.CFG.KAT_PROXY_URL,
|
||||
"kat_ratio": headphones.CFG.KAT_RATIO,
|
||||
"use_piratebay" : checked(headphones.CFG.PIRATEBAY),
|
||||
"piratebay_proxy_url" : headphones.CFG.PIRATEBAY_PROXY_URL,
|
||||
"piratebay_ratio": headphones.CFG.PIRATEBAY_RATIO,
|
||||
"use_mininova" : checked(headphones.CFG.MININOVA),
|
||||
"mininova_ratio": headphones.CFG.MININOVA_RATIO,
|
||||
"use_waffles" : checked(headphones.CFG.WAFFLES),
|
||||
"waffles_uid" : headphones.CFG.WAFFLES_UID,
|
||||
"waffles_passkey": headphones.CFG.WAFFLES_PASSKEY,
|
||||
"waffles_ratio": headphones.CFG.WAFFLES_RATIO,
|
||||
"use_rutracker" : checked(headphones.CFG.RUTRACKER),
|
||||
"rutracker_user" : headphones.CFG.RUTRACKER_USER,
|
||||
"rutracker_password": headphones.CFG.RUTRACKER_PASSWORD,
|
||||
"rutracker_ratio": headphones.CFG.RUTRACKER_RATIO,
|
||||
"use_whatcd" : checked(headphones.CFG.WHATCD),
|
||||
"whatcd_username" : headphones.CFG.WHATCD_USERNAME,
|
||||
"whatcd_password": headphones.CFG.WHATCD_PASSWORD,
|
||||
"whatcd_ratio": headphones.CFG.WHATCD_RATIO,
|
||||
"pref_qual_0" : radio(headphones.CFG.PREFERRED_QUALITY, 0),
|
||||
"pref_qual_1" : radio(headphones.CFG.PREFERRED_QUALITY, 1),
|
||||
"pref_qual_2" : radio(headphones.CFG.PREFERRED_QUALITY, 2),
|
||||
"pref_qual_3" : radio(headphones.CFG.PREFERRED_QUALITY, 3),
|
||||
"pref_bitrate" : headphones.CFG.PREFERRED_BITRATE,
|
||||
"pref_bitrate_high" : headphones.CFG.PREFERRED_BITRATE_HIGH_BUFFER,
|
||||
"pref_bitrate_low" : headphones.CFG.PREFERRED_BITRATE_LOW_BUFFER,
|
||||
"pref_bitrate_allow_lossless" : checked(headphones.CFG.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
||||
"detect_bitrate" : checked(headphones.CFG.DETECT_BITRATE),
|
||||
"lossless_bitrate_from" : headphones.CFG.LOSSLESS_BITRATE_FROM,
|
||||
"lossless_bitrate_to" : headphones.CFG.LOSSLESS_BITRATE_TO,
|
||||
"freeze_db" : checked(headphones.CFG.FREEZE_DB),
|
||||
"move_files" : checked(headphones.CFG.MOVE_FILES),
|
||||
"rename_files" : checked(headphones.CFG.RENAME_FILES),
|
||||
"correct_metadata" : checked(headphones.CFG.CORRECT_METADATA),
|
||||
"cleanup_files" : checked(headphones.CFG.CLEANUP_FILES),
|
||||
"keep_nfo" : checked(headphones.CFG.KEEP_NFO),
|
||||
"add_album_art" : checked(headphones.CFG.ADD_ALBUM_ART),
|
||||
"album_art_format" : headphones.CFG.ALBUM_ART_FORMAT,
|
||||
"embed_album_art" : checked(headphones.CFG.EMBED_ALBUM_ART),
|
||||
"embed_lyrics" : checked(headphones.CFG.EMBED_LYRICS),
|
||||
"replace_existing_folders" : checked(headphones.CFG.REPLACE_EXISTING_FOLDERS),
|
||||
"dest_dir" : headphones.CFG.DESTINATION_DIR,
|
||||
"lossless_dest_dir" : headphones.CFG.LOSSLESS_DESTINATION_DIR,
|
||||
"folder_format" : headphones.CFG.FOLDER_FORMAT,
|
||||
"file_format" : headphones.CFG.FILE_FORMAT,
|
||||
"file_underscores" : checked(headphones.CFG.FILE_UNDERSCORES),
|
||||
"include_extras" : checked(headphones.CFG.INCLUDE_EXTRAS),
|
||||
"autowant_upcoming" : checked(headphones.CFG.AUTOWANT_UPCOMING),
|
||||
"autowant_all" : checked(headphones.CFG.AUTOWANT_ALL),
|
||||
"autowant_manually_added" : checked(headphones.CFG.AUTOWANT_MANUALLY_ADDED),
|
||||
"keep_torrent_files" : checked(headphones.CFG.KEEP_TORRENT_FILES),
|
||||
"prefer_torrents_0" : radio(headphones.CFG.PREFER_TORRENTS, 0),
|
||||
"prefer_torrents_1" : radio(headphones.CFG.PREFER_TORRENTS, 1),
|
||||
"prefer_torrents_2" : radio(headphones.CFG.PREFER_TORRENTS, 2),
|
||||
"magnet_links_0" : radio(headphones.CFG.MAGNET_LINKS, 0),
|
||||
"magnet_links_1" : radio(headphones.CFG.MAGNET_LINKS, 1),
|
||||
"magnet_links_2" : radio(headphones.CFG.MAGNET_LINKS, 2),
|
||||
"log_dir" : headphones.CFG.LOG_DIR,
|
||||
"cache_dir" : headphones.CFG.CACHE_DIR,
|
||||
"http_host" : headphones.CONFIG.HTTP_HOST,
|
||||
"http_user" : headphones.CONFIG.HTTP_USERNAME,
|
||||
"http_port" : headphones.CONFIG.HTTP_PORT,
|
||||
"http_pass" : headphones.CONFIG.HTTP_PASSWORD,
|
||||
"launch_browser" : checked(headphones.CONFIG.LAUNCH_BROWSER),
|
||||
"enable_https" : checked(headphones.CONFIG.ENABLE_HTTPS),
|
||||
"https_cert" : headphones.CONFIG.HTTPS_CERT,
|
||||
"https_key" : headphones.CONFIG.HTTPS_KEY,
|
||||
"api_enabled" : checked(headphones.CONFIG.API_ENABLED),
|
||||
"api_key" : headphones.CONFIG.API_KEY,
|
||||
"download_scan_interval" : headphones.CONFIG.DOWNLOAD_SCAN_INTERVAL,
|
||||
"update_db_interval" : headphones.CONFIG.UPDATE_DB_INTERVAL,
|
||||
"mb_ignore_age" : headphones.CONFIG.MB_IGNORE_AGE,
|
||||
"search_interval" : headphones.CONFIG.SEARCH_INTERVAL,
|
||||
"libraryscan_interval" : headphones.CONFIG.LIBRARYSCAN_INTERVAL,
|
||||
"sab_host" : headphones.CONFIG.SAB_HOST,
|
||||
"sab_user" : headphones.CONFIG.SAB_USERNAME,
|
||||
"sab_api" : headphones.CONFIG.SAB_APIKEY,
|
||||
"sab_pass" : headphones.CONFIG.SAB_PASSWORD,
|
||||
"sab_cat" : headphones.CONFIG.SAB_CATEGORY,
|
||||
"nzbget_host" : headphones.CONFIG.NZBGET_HOST,
|
||||
"nzbget_user" : headphones.CONFIG.NZBGET_USERNAME,
|
||||
"nzbget_pass" : headphones.CONFIG.NZBGET_PASSWORD,
|
||||
"nzbget_cat" : headphones.CONFIG.NZBGET_CATEGORY,
|
||||
"nzbget_priority" : headphones.CONFIG.NZBGET_PRIORITY,
|
||||
"transmission_host" : headphones.CONFIG.TRANSMISSION_HOST,
|
||||
"transmission_user" : headphones.CONFIG.TRANSMISSION_USERNAME,
|
||||
"transmission_pass" : headphones.CONFIG.TRANSMISSION_PASSWORD,
|
||||
"utorrent_host" : headphones.CONFIG.UTORRENT_HOST,
|
||||
"utorrent_user" : headphones.CONFIG.UTORRENT_USERNAME,
|
||||
"utorrent_pass" : headphones.CONFIG.UTORRENT_PASSWORD,
|
||||
"utorrent_label" : headphones.CONFIG.UTORRENT_LABEL,
|
||||
"nzb_downloader_sabnzbd" : radio(headphones.CONFIG.NZB_DOWNLOADER, 0),
|
||||
"nzb_downloader_nzbget" : radio(headphones.CONFIG.NZB_DOWNLOADER, 1),
|
||||
"nzb_downloader_blackhole" : radio(headphones.CONFIG.NZB_DOWNLOADER, 2),
|
||||
"torrent_downloader_blackhole" : radio(headphones.CONFIG.TORRENT_DOWNLOADER, 0),
|
||||
"torrent_downloader_transmission" : radio(headphones.CONFIG.TORRENT_DOWNLOADER, 1),
|
||||
"torrent_downloader_utorrent" : radio(headphones.CONFIG.TORRENT_DOWNLOADER, 2),
|
||||
"download_dir" : headphones.CONFIG.DOWNLOAD_DIR,
|
||||
"use_blackhole" : checked(headphones.CONFIG.BLACKHOLE),
|
||||
"blackhole_dir" : headphones.CONFIG.BLACKHOLE_DIR,
|
||||
"usenet_retention" : headphones.CONFIG.USENET_RETENTION,
|
||||
"headphones_indexer" : checked(headphones.CONFIG.HEADPHONES_INDEXER),
|
||||
"use_newznab" : checked(headphones.CONFIG.NEWZNAB),
|
||||
"newznab_host" : headphones.CONFIG.NEWZNAB_HOST,
|
||||
"newznab_api" : headphones.CONFIG.NEWZNAB_APIKEY,
|
||||
"newznab_enabled" : checked(headphones.CONFIG.NEWZNAB_ENABLED),
|
||||
"extra_newznabs" : headphones.CONFIG.get_extra_newznabs(),
|
||||
"use_nzbsorg" : checked(headphones.CONFIG.NZBSORG),
|
||||
"nzbsorg_uid" : headphones.CONFIG.NZBSORG_UID,
|
||||
"nzbsorg_hash" : headphones.CONFIG.NZBSORG_HASH,
|
||||
"use_omgwtfnzbs" : checked(headphones.CONFIG.OMGWTFNZBS),
|
||||
"omgwtfnzbs_uid" : headphones.CONFIG.OMGWTFNZBS_UID,
|
||||
"omgwtfnzbs_apikey" : headphones.CONFIG.OMGWTFNZBS_APIKEY,
|
||||
"preferred_words" : headphones.CONFIG.PREFERRED_WORDS,
|
||||
"ignored_words" : headphones.CONFIG.IGNORED_WORDS,
|
||||
"required_words" : headphones.CONFIG.REQUIRED_WORDS,
|
||||
"torrentblackhole_dir" : headphones.CONFIG.TORRENTBLACKHOLE_DIR,
|
||||
"download_torrent_dir" : headphones.CONFIG.DOWNLOAD_TORRENT_DIR,
|
||||
"numberofseeders" : headphones.CONFIG.NUMBEROFSEEDERS,
|
||||
"use_kat" : checked(headphones.CONFIG.KAT),
|
||||
"kat_proxy_url" : headphones.CONFIG.KAT_PROXY_URL,
|
||||
"kat_ratio": headphones.CONFIG.KAT_RATIO,
|
||||
"use_piratebay" : checked(headphones.CONFIG.PIRATEBAY),
|
||||
"piratebay_proxy_url" : headphones.CONFIG.PIRATEBAY_PROXY_URL,
|
||||
"piratebay_ratio": headphones.CONFIG.PIRATEBAY_RATIO,
|
||||
"use_mininova" : checked(headphones.CONFIG.MININOVA),
|
||||
"mininova_ratio": headphones.CONFIG.MININOVA_RATIO,
|
||||
"use_waffles" : checked(headphones.CONFIG.WAFFLES),
|
||||
"waffles_uid" : headphones.CONFIG.WAFFLES_UID,
|
||||
"waffles_passkey": headphones.CONFIG.WAFFLES_PASSKEY,
|
||||
"waffles_ratio": headphones.CONFIG.WAFFLES_RATIO,
|
||||
"use_rutracker" : checked(headphones.CONFIG.RUTRACKER),
|
||||
"rutracker_user" : headphones.CONFIG.RUTRACKER_USER,
|
||||
"rutracker_password": headphones.CONFIG.RUTRACKER_PASSWORD,
|
||||
"rutracker_ratio": headphones.CONFIG.RUTRACKER_RATIO,
|
||||
"use_whatcd" : checked(headphones.CONFIG.WHATCD),
|
||||
"whatcd_username" : headphones.CONFIG.WHATCD_USERNAME,
|
||||
"whatcd_password": headphones.CONFIG.WHATCD_PASSWORD,
|
||||
"whatcd_ratio": headphones.CONFIG.WHATCD_RATIO,
|
||||
"pref_qual_0" : radio(headphones.CONFIG.PREFERRED_QUALITY, 0),
|
||||
"pref_qual_1" : radio(headphones.CONFIG.PREFERRED_QUALITY, 1),
|
||||
"pref_qual_2" : radio(headphones.CONFIG.PREFERRED_QUALITY, 2),
|
||||
"pref_qual_3" : radio(headphones.CONFIG.PREFERRED_QUALITY, 3),
|
||||
"pref_bitrate" : headphones.CONFIG.PREFERRED_BITRATE,
|
||||
"pref_bitrate_high" : headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER,
|
||||
"pref_bitrate_low" : headphones.CONFIG.PREFERRED_BITRATE_LOW_BUFFER,
|
||||
"pref_bitrate_allow_lossless" : checked(headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
||||
"detect_bitrate" : checked(headphones.CONFIG.DETECT_BITRATE),
|
||||
"lossless_bitrate_from" : headphones.CONFIG.LOSSLESS_BITRATE_FROM,
|
||||
"lossless_bitrate_to" : headphones.CONFIG.LOSSLESS_BITRATE_TO,
|
||||
"freeze_db" : checked(headphones.CONFIG.FREEZE_DB),
|
||||
"move_files" : checked(headphones.CONFIG.MOVE_FILES),
|
||||
"rename_files" : checked(headphones.CONFIG.RENAME_FILES),
|
||||
"correct_metadata" : checked(headphones.CONFIG.CORRECT_METADATA),
|
||||
"cleanup_files" : checked(headphones.CONFIG.CLEANUP_FILES),
|
||||
"keep_nfo" : checked(headphones.CONFIG.KEEP_NFO),
|
||||
"add_album_art" : checked(headphones.CONFIG.ADD_ALBUM_ART),
|
||||
"album_art_format" : headphones.CONFIG.ALBUM_ART_FORMAT,
|
||||
"embed_album_art" : checked(headphones.CONFIG.EMBED_ALBUM_ART),
|
||||
"embed_lyrics" : checked(headphones.CONFIG.EMBED_LYRICS),
|
||||
"replace_existing_folders" : checked(headphones.CONFIG.REPLACE_EXISTING_FOLDERS),
|
||||
"dest_dir" : headphones.CONFIG.DESTINATION_DIR,
|
||||
"lossless_dest_dir" : headphones.CONFIG.LOSSLESS_DESTINATION_DIR,
|
||||
"folder_format" : headphones.CONFIG.FOLDER_FORMAT,
|
||||
"file_format" : headphones.CONFIG.FILE_FORMAT,
|
||||
"file_underscores" : checked(headphones.CONFIG.FILE_UNDERSCORES),
|
||||
"include_extras" : checked(headphones.CONFIG.INCLUDE_EXTRAS),
|
||||
"autowant_upcoming" : checked(headphones.CONFIG.AUTOWANT_UPCOMING),
|
||||
"autowant_all" : checked(headphones.CONFIG.AUTOWANT_ALL),
|
||||
"autowant_manually_added" : checked(headphones.CONFIG.AUTOWANT_MANUALLY_ADDED),
|
||||
"keep_torrent_files" : checked(headphones.CONFIG.KEEP_TORRENT_FILES),
|
||||
"prefer_torrents_0" : radio(headphones.CONFIG.PREFER_TORRENTS, 0),
|
||||
"prefer_torrents_1" : radio(headphones.CONFIG.PREFER_TORRENTS, 1),
|
||||
"prefer_torrents_2" : radio(headphones.CONFIG.PREFER_TORRENTS, 2),
|
||||
"magnet_links_0" : radio(headphones.CONFIG.MAGNET_LINKS, 0),
|
||||
"magnet_links_1" : radio(headphones.CONFIG.MAGNET_LINKS, 1),
|
||||
"magnet_links_2" : radio(headphones.CONFIG.MAGNET_LINKS, 2),
|
||||
"log_dir" : headphones.CONFIG.LOG_DIR,
|
||||
"cache_dir" : headphones.CONFIG.CACHE_DIR,
|
||||
"interface_list" : interface_list,
|
||||
"music_encoder": checked(headphones.CFG.MUSIC_ENCODER),
|
||||
"encoder": headphones.CFG.ENCODER,
|
||||
"xldprofile": headphones.CFG.XLDPROFILE,
|
||||
"bitrate": int(headphones.CFG.BITRATE),
|
||||
"encoderfolder": headphones.CFG.ENCODER_PATH,
|
||||
"advancedencoder": headphones.CFG.ADVANCEDENCODER,
|
||||
"encoderoutputformat": headphones.CFG.ENCODEROUTPUTFORMAT,
|
||||
"samplingfrequency": headphones.CFG.SAMPLINGFREQUENCY,
|
||||
"encodervbrcbr": headphones.CFG.ENCODERVBRCBR,
|
||||
"encoderquality": headphones.CFG.ENCODERQUALITY,
|
||||
"encoderlossless": checked(headphones.CFG.ENCODERLOSSLESS),
|
||||
"encoder_multicore": checked(headphones.CFG.ENCODER_MULTICORE),
|
||||
"encoder_multicore_count": int(headphones.CFG.ENCODER_MULTICORE_COUNT),
|
||||
"delete_lossless_files": checked(headphones.CFG.DELETE_LOSSLESS_FILES),
|
||||
"growl_enabled": checked(headphones.CFG.GROWL_ENABLED),
|
||||
"growl_onsnatch": checked(headphones.CFG.GROWL_ONSNATCH),
|
||||
"growl_host": headphones.CFG.GROWL_HOST,
|
||||
"growl_password": headphones.CFG.GROWL_PASSWORD,
|
||||
"prowl_enabled": checked(headphones.CFG.PROWL_ENABLED),
|
||||
"prowl_onsnatch": checked(headphones.CFG.PROWL_ONSNATCH),
|
||||
"prowl_keys": headphones.CFG.PROWL_KEYS,
|
||||
"prowl_priority": headphones.CFG.PROWL_PRIORITY,
|
||||
"xbmc_enabled": checked(headphones.CFG.XBMC_ENABLED),
|
||||
"xbmc_host": headphones.CFG.XBMC_HOST,
|
||||
"xbmc_username": headphones.CFG.XBMC_USERNAME,
|
||||
"xbmc_password": headphones.CFG.XBMC_PASSWORD,
|
||||
"xbmc_update": checked(headphones.CFG.XBMC_UPDATE),
|
||||
"xbmc_notify": checked(headphones.CFG.XBMC_NOTIFY),
|
||||
"lms_enabled": checked(headphones.CFG.LMS_ENABLED),
|
||||
"lms_host": headphones.CFG.LMS_HOST,
|
||||
"plex_enabled": checked(headphones.CFG.PLEX_ENABLED),
|
||||
"plex_server_host": headphones.CFG.PLEX_SERVER_HOST,
|
||||
"plex_client_host": headphones.CFG.PLEX_CLIENT_HOST,
|
||||
"plex_username": headphones.CFG.PLEX_USERNAME,
|
||||
"plex_password": headphones.CFG.PLEX_PASSWORD,
|
||||
"plex_update": checked(headphones.CFG.PLEX_UPDATE),
|
||||
"plex_notify": checked(headphones.CFG.PLEX_NOTIFY),
|
||||
"nma_enabled": checked(headphones.CFG.NMA_ENABLED),
|
||||
"nma_apikey": headphones.CFG.NMA_APIKEY,
|
||||
"nma_priority": int(headphones.CFG.NMA_PRIORITY),
|
||||
"nma_onsnatch": checked(headphones.CFG.NMA_ONSNATCH),
|
||||
"pushalot_enabled": checked(headphones.CFG.PUSHALOT_ENABLED),
|
||||
"pushalot_apikey": headphones.CFG.PUSHALOT_APIKEY,
|
||||
"pushalot_onsnatch": checked(headphones.CFG.PUSHALOT_ONSNATCH),
|
||||
"synoindex_enabled": checked(headphones.CFG.SYNOINDEX_ENABLED),
|
||||
"pushover_enabled": checked(headphones.CFG.PUSHOVER_ENABLED),
|
||||
"pushover_onsnatch": checked(headphones.CFG.PUSHOVER_ONSNATCH),
|
||||
"pushover_keys": headphones.CFG.PUSHOVER_KEYS,
|
||||
"pushover_apitoken": headphones.CFG.PUSHOVER_APITOKEN,
|
||||
"pushover_priority": headphones.CFG.PUSHOVER_PRIORITY,
|
||||
"pushbullet_enabled": checked(headphones.CFG.PUSHBULLET_ENABLED),
|
||||
"pushbullet_onsnatch": checked(headphones.CFG.PUSHBULLET_ONSNATCH),
|
||||
"pushbullet_apikey": headphones.CFG.PUSHBULLET_APIKEY,
|
||||
"pushbullet_deviceid": headphones.CFG.PUSHBULLET_DEVICEID,
|
||||
"subsonic_enabled": checked(headphones.CFG.SUBSONIC_ENABLED),
|
||||
"subsonic_host": headphones.CFG.SUBSONIC_HOST,
|
||||
"subsonic_username": headphones.CFG.SUBSONIC_USERNAME,
|
||||
"subsonic_password": headphones.CFG.SUBSONIC_PASSWORD,
|
||||
"twitter_enabled": checked(headphones.CFG.TWITTER_ENABLED),
|
||||
"twitter_onsnatch": checked(headphones.CFG.TWITTER_ONSNATCH),
|
||||
"osx_notify_enabled": checked(headphones.CFG.OSX_NOTIFY_ENABLED),
|
||||
"osx_notify_onsnatch": checked(headphones.CFG.OSX_NOTIFY_ONSNATCH),
|
||||
"osx_notify_app": headphones.CFG.OSX_NOTIFY_APP,
|
||||
"boxcar_enabled": checked(headphones.CFG.BOXCAR_ENABLED),
|
||||
"boxcar_onsnatch": checked(headphones.CFG.BOXCAR_ONSNATCH),
|
||||
"boxcar_token": headphones.CFG.BOXCAR_TOKEN,
|
||||
"music_encoder": checked(headphones.CONFIG.MUSIC_ENCODER),
|
||||
"encoder": headphones.CONFIG.ENCODER,
|
||||
"xldprofile": headphones.CONFIG.XLDPROFILE,
|
||||
"bitrate": int(headphones.CONFIG.BITRATE),
|
||||
"encoderfolder": headphones.CONFIG.ENCODER_PATH,
|
||||
"advancedencoder": headphones.CONFIG.ADVANCEDENCODER,
|
||||
"encoderoutputformat": headphones.CONFIG.ENCODEROUTPUTFORMAT,
|
||||
"samplingfrequency": headphones.CONFIG.SAMPLINGFREQUENCY,
|
||||
"encodervbrcbr": headphones.CONFIG.ENCODERVBRCBR,
|
||||
"encoderquality": headphones.CONFIG.ENCODERQUALITY,
|
||||
"encoderlossless": checked(headphones.CONFIG.ENCODERLOSSLESS),
|
||||
"encoder_multicore": checked(headphones.CONFIG.ENCODER_MULTICORE),
|
||||
"encoder_multicore_count": int(headphones.CONFIG.ENCODER_MULTICORE_COUNT),
|
||||
"delete_lossless_files": checked(headphones.CONFIG.DELETE_LOSSLESS_FILES),
|
||||
"growl_enabled": checked(headphones.CONFIG.GROWL_ENABLED),
|
||||
"growl_onsnatch": checked(headphones.CONFIG.GROWL_ONSNATCH),
|
||||
"growl_host": headphones.CONFIG.GROWL_HOST,
|
||||
"growl_password": headphones.CONFIG.GROWL_PASSWORD,
|
||||
"prowl_enabled": checked(headphones.CONFIG.PROWL_ENABLED),
|
||||
"prowl_onsnatch": checked(headphones.CONFIG.PROWL_ONSNATCH),
|
||||
"prowl_keys": headphones.CONFIG.PROWL_KEYS,
|
||||
"prowl_priority": headphones.CONFIG.PROWL_PRIORITY,
|
||||
"xbmc_enabled": checked(headphones.CONFIG.XBMC_ENABLED),
|
||||
"xbmc_host": headphones.CONFIG.XBMC_HOST,
|
||||
"xbmc_username": headphones.CONFIG.XBMC_USERNAME,
|
||||
"xbmc_password": headphones.CONFIG.XBMC_PASSWORD,
|
||||
"xbmc_update": checked(headphones.CONFIG.XBMC_UPDATE),
|
||||
"xbmc_notify": checked(headphones.CONFIG.XBMC_NOTIFY),
|
||||
"lms_enabled": checked(headphones.CONFIG.LMS_ENABLED),
|
||||
"lms_host": headphones.CONFIG.LMS_HOST,
|
||||
"plex_enabled": checked(headphones.CONFIG.PLEX_ENABLED),
|
||||
"plex_server_host": headphones.CONFIG.PLEX_SERVER_HOST,
|
||||
"plex_client_host": headphones.CONFIG.PLEX_CLIENT_HOST,
|
||||
"plex_username": headphones.CONFIG.PLEX_USERNAME,
|
||||
"plex_password": headphones.CONFIG.PLEX_PASSWORD,
|
||||
"plex_update": checked(headphones.CONFIG.PLEX_UPDATE),
|
||||
"plex_notify": checked(headphones.CONFIG.PLEX_NOTIFY),
|
||||
"nma_enabled": checked(headphones.CONFIG.NMA_ENABLED),
|
||||
"nma_apikey": headphones.CONFIG.NMA_APIKEY,
|
||||
"nma_priority": int(headphones.CONFIG.NMA_PRIORITY),
|
||||
"nma_onsnatch": checked(headphones.CONFIG.NMA_ONSNATCH),
|
||||
"pushalot_enabled": checked(headphones.CONFIG.PUSHALOT_ENABLED),
|
||||
"pushalot_apikey": headphones.CONFIG.PUSHALOT_APIKEY,
|
||||
"pushalot_onsnatch": checked(headphones.CONFIG.PUSHALOT_ONSNATCH),
|
||||
"synoindex_enabled": checked(headphones.CONFIG.SYNOINDEX_ENABLED),
|
||||
"pushover_enabled": checked(headphones.CONFIG.PUSHOVER_ENABLED),
|
||||
"pushover_onsnatch": checked(headphones.CONFIG.PUSHOVER_ONSNATCH),
|
||||
"pushover_keys": headphones.CONFIG.PUSHOVER_KEYS,
|
||||
"pushover_apitoken": headphones.CONFIG.PUSHOVER_APITOKEN,
|
||||
"pushover_priority": headphones.CONFIG.PUSHOVER_PRIORITY,
|
||||
"pushbullet_enabled": checked(headphones.CONFIG.PUSHBULLET_ENABLED),
|
||||
"pushbullet_onsnatch": checked(headphones.CONFIG.PUSHBULLET_ONSNATCH),
|
||||
"pushbullet_apikey": headphones.CONFIG.PUSHBULLET_APIKEY,
|
||||
"pushbullet_deviceid": headphones.CONFIG.PUSHBULLET_DEVICEID,
|
||||
"subsonic_enabled": checked(headphones.CONFIG.SUBSONIC_ENABLED),
|
||||
"subsonic_host": headphones.CONFIG.SUBSONIC_HOST,
|
||||
"subsonic_username": headphones.CONFIG.SUBSONIC_USERNAME,
|
||||
"subsonic_password": headphones.CONFIG.SUBSONIC_PASSWORD,
|
||||
"twitter_enabled": checked(headphones.CONFIG.TWITTER_ENABLED),
|
||||
"twitter_onsnatch": checked(headphones.CONFIG.TWITTER_ONSNATCH),
|
||||
"osx_notify_enabled": checked(headphones.CONFIG.OSX_NOTIFY_ENABLED),
|
||||
"osx_notify_onsnatch": checked(headphones.CONFIG.OSX_NOTIFY_ONSNATCH),
|
||||
"osx_notify_app": headphones.CONFIG.OSX_NOTIFY_APP,
|
||||
"boxcar_enabled": checked(headphones.CONFIG.BOXCAR_ENABLED),
|
||||
"boxcar_onsnatch": checked(headphones.CONFIG.BOXCAR_ONSNATCH),
|
||||
"boxcar_token": headphones.CONFIG.BOXCAR_TOKEN,
|
||||
"mirror_list": headphones.MIRRORLIST,
|
||||
"mirror": headphones.CFG.MIRROR,
|
||||
"customhost": headphones.CFG.CUSTOMHOST,
|
||||
"customport": headphones.CFG.CUSTOMPORT,
|
||||
"customsleep": headphones.CFG.CUSTOMSLEEP,
|
||||
"hpuser": headphones.CFG.HPUSER,
|
||||
"hppass": headphones.CFG.HPPASS,
|
||||
"songkick_enabled": checked(headphones.CFG.SONGKICK_ENABLED),
|
||||
"songkick_apikey": headphones.CFG.SONGKICK_APIKEY,
|
||||
"songkick_location": headphones.CFG.SONGKICK_LOCATION,
|
||||
"songkick_filter_enabled": checked(headphones.CFG.SONGKICK_FILTER_ENABLED),
|
||||
"cache_sizemb": headphones.CFG.CACHE_SIZEMB,
|
||||
"file_permissions": headphones.CFG.FILE_PERMISSIONS,
|
||||
"folder_permissions": headphones.CFG.FOLDER_PERMISSIONS,
|
||||
"mpc_enabled": checked(headphones.CFG.MPC_ENABLED)
|
||||
"mirror": headphones.CONFIG.MIRROR,
|
||||
"customhost": headphones.CONFIG.CUSTOMHOST,
|
||||
"customport": headphones.CONFIG.CUSTOMPORT,
|
||||
"customsleep": headphones.CONFIG.CUSTOMSLEEP,
|
||||
"hpuser": headphones.CONFIG.HPUSER,
|
||||
"hppass": headphones.CONFIG.HPPASS,
|
||||
"songkick_enabled": checked(headphones.CONFIG.SONGKICK_ENABLED),
|
||||
"songkick_apikey": headphones.CONFIG.SONGKICK_APIKEY,
|
||||
"songkick_location": headphones.CONFIG.SONGKICK_LOCATION,
|
||||
"songkick_filter_enabled": checked(headphones.CONFIG.SONGKICK_FILTER_ENABLED),
|
||||
"cache_sizemb": headphones.CONFIG.CACHE_SIZEMB,
|
||||
"file_permissions": headphones.CONFIG.FILE_PERMISSIONS,
|
||||
"folder_permissions": headphones.CONFIG.FOLDER_PERMISSIONS,
|
||||
"mpc_enabled": checked(headphones.CONFIG.MPC_ENABLED)
|
||||
}
|
||||
|
||||
# Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 (append new extras to the end)
|
||||
@@ -1163,8 +1163,8 @@ class WebInterface(object):
|
||||
}
|
||||
|
||||
extras_list = [extra_munges.get(x, x) for x in headphones.POSSIBLE_EXTRAS]
|
||||
if headphones.CFG.EXTRAS:
|
||||
extras = map(int, headphones.CFG.EXTRAS.split(','))
|
||||
if headphones.CONFIG.EXTRAS:
|
||||
extras = map(int, headphones.CONFIG.EXTRAS.split(','))
|
||||
else:
|
||||
extras = []
|
||||
|
||||
@@ -1185,7 +1185,7 @@ class WebInterface(object):
|
||||
|
||||
def configUpdate(self, **kwargs):
|
||||
# Handle the variable config options. Note - keys with False values aren't getting passed
|
||||
headphones.CFG.clear_extra_newznabs()
|
||||
headphones.CONFIG.clear_extra_newznabs()
|
||||
for kwarg in kwargs:
|
||||
if kwarg.startswith('newznab_host'):
|
||||
newznab_number = kwarg[12:]
|
||||
@@ -1196,7 +1196,7 @@ class WebInterface(object):
|
||||
newznab_enabled = int(kwargs.get('newznab_enabled' + newznab_number))
|
||||
except KeyError:
|
||||
newznab_enabled = 0
|
||||
headphones.CFG.add_extra_newznab((newznab_host, newznab_api, newznab_enabled))
|
||||
headphones.CONFIG.add_extra_newznab((newznab_host, newznab_api, newznab_enabled))
|
||||
|
||||
# Convert the extras to list then string. Coming in as 0 or 1 (append new extras to the end)
|
||||
temp_extras_list = []
|
||||
@@ -1222,17 +1222,17 @@ class WebInterface(object):
|
||||
if extra in kwargs:
|
||||
del kwargs[extra]
|
||||
|
||||
headphones.CFG.EXTRAS = ','.join(str(n) for n in temp_extras_list)
|
||||
headphones.CONFIG.EXTRAS = ','.join(str(n) for n in temp_extras_list)
|
||||
|
||||
headphones.CFG.process_kwargs(kwargs)
|
||||
headphones.CONFIG.process_kwargs(kwargs)
|
||||
|
||||
# Sanity checking
|
||||
if headphones.CFG.SEARCH_INTERVAL < 360:
|
||||
if headphones.CONFIG.SEARCH_INTERVAL < 360:
|
||||
logger.info("Search interval too low. Resetting to 6 hour minimum")
|
||||
headphones.CFG.SEARCH_INTERVAL = 360
|
||||
headphones.CONFIG.SEARCH_INTERVAL = 360
|
||||
|
||||
# Write the config
|
||||
headphones.CFG.write()
|
||||
headphones.CONFIG.write()
|
||||
|
||||
#reconfigure musicbrainz database connection with the new values
|
||||
mb.startmb()
|
||||
@@ -1402,7 +1402,7 @@ class Artwork(object):
|
||||
cherrypy.response.headers['Cache-Control'] = 'no-cache'
|
||||
else:
|
||||
relpath = relpath.replace('cache/','',1)
|
||||
path = os.path.join(headphones.CFG.CACHE_DIR,relpath)
|
||||
path = os.path.join(headphones.CONFIG.CACHE_DIR,relpath)
|
||||
fileext = os.path.splitext(relpath)[1][1::]
|
||||
cherrypy.response.headers['Content-type'] = 'image/' + fileext
|
||||
cherrypy.response.headers['Cache-Control'] = 'max-age=31556926'
|
||||
@@ -1435,7 +1435,7 @@ class Artwork(object):
|
||||
cherrypy.response.headers['Cache-Control'] = 'no-cache'
|
||||
else:
|
||||
relpath = relpath.replace('cache/','',1)
|
||||
path = os.path.join(headphones.CFG.CACHE_DIR,relpath)
|
||||
path = os.path.join(headphones.CONFIG.CACHE_DIR,relpath)
|
||||
fileext = os.path.splitext(relpath)[1][1::]
|
||||
cherrypy.response.headers['Content-type'] = 'image/' + fileext
|
||||
cherrypy.response.headers['Cache-Control'] = 'max-age=31556926'
|
||||
|
||||
@@ -36,12 +36,12 @@ def initialize(options=None):
|
||||
if not (https_cert and os.path.exists(https_cert)) or not (https_key and os.path.exists(https_key)):
|
||||
if not create_https_certificates(https_cert, https_key):
|
||||
logger.warn(u"Unable to create cert/key files, disabling HTTPS")
|
||||
headphones.CFG.ENABLE_HTTPS = False
|
||||
headphones.CONFIG.ENABLE_HTTPS = False
|
||||
enable_https = False
|
||||
|
||||
if not (os.path.exists(https_cert) and os.path.exists(https_key)):
|
||||
logger.warn(u"Disabled HTTPS because of missing CERT and KEY files")
|
||||
headphones.CFG.ENABLE_HTTPS = False
|
||||
headphones.CONFIG.ENABLE_HTTPS = False
|
||||
enable_https = False
|
||||
|
||||
options_dict = {
|
||||
@@ -94,7 +94,7 @@ def initialize(options=None):
|
||||
},
|
||||
'/cache':{
|
||||
'tools.staticdir.on': True,
|
||||
'tools.staticdir.dir': headphones.CFG.CACHE_DIR
|
||||
'tools.staticdir.dir': headphones.CONFIG.CACHE_DIR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user