mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Saving the config appears to work again
This commit is contained in:
@@ -21,8 +21,6 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib/'))
|
||||
|
||||
from headphones import webstart, logger
|
||||
|
||||
from configobj import ConfigObj
|
||||
|
||||
import locale
|
||||
import time
|
||||
import signal
|
||||
@@ -114,9 +112,9 @@ def main():
|
||||
headphones.DATA_DIR = headphones.PROG_DIR
|
||||
|
||||
if args.config:
|
||||
headphones.CONFIG_FILE = args.config
|
||||
config_file = args.config
|
||||
else:
|
||||
headphones.CONFIG_FILE = os.path.join(headphones.DATA_DIR, 'config.ini')
|
||||
config_file = os.path.join(headphones.DATA_DIR, 'config.ini')
|
||||
|
||||
# Try to create the DATA_DIR if it doesn't exist
|
||||
if not os.path.exists(headphones.DATA_DIR):
|
||||
@@ -131,10 +129,9 @@ def main():
|
||||
|
||||
# Put the database in the DATA_DIR
|
||||
headphones.DB_FILE = os.path.join(headphones.DATA_DIR, 'headphones.db')
|
||||
headphones.CFG = ConfigObj(headphones.CONFIG_FILE, encoding='utf-8')
|
||||
|
||||
# Read config and start logging
|
||||
headphones.initialize()
|
||||
headphones.initialize(config_file)
|
||||
|
||||
if headphones.DAEMON:
|
||||
headphones.daemonize()
|
||||
@@ -147,24 +144,25 @@ def main():
|
||||
http_port = args.port
|
||||
logger.info('Using forced web server port: %i', http_port)
|
||||
else:
|
||||
http_port = int(headphones.HTTP_PORT)
|
||||
http_port = int(headphones.CFG.HTTP_PORT)
|
||||
|
||||
# Try to start the server. Will exit here is address is already in use.
|
||||
webstart.initialize({
|
||||
web_config = {
|
||||
'http_port': http_port,
|
||||
'http_host': headphones.HTTP_HOST,
|
||||
'http_root': headphones.HTTP_ROOT,
|
||||
'http_proxy': headphones.HTTP_PROXY,
|
||||
'enable_https': headphones.ENABLE_HTTPS,
|
||||
'https_cert': headphones.HTTPS_CERT,
|
||||
'https_key': headphones.HTTPS_KEY,
|
||||
'http_username': headphones.HTTP_USERNAME,
|
||||
'http_password': headphones.HTTP_PASSWORD,
|
||||
})
|
||||
'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,
|
||||
}
|
||||
webstart.initialize(web_config)
|
||||
|
||||
if headphones.LAUNCH_BROWSER and not args.nolaunch:
|
||||
headphones.launch_browser(headphones.HTTP_HOST, http_port,
|
||||
headphones.HTTP_ROOT)
|
||||
if headphones.CFG.LAUNCH_BROWSER and not args.nolaunch:
|
||||
headphones.launch_browser(headphones.CFG.HTTP_HOST, http_port,
|
||||
headphones.CFG.HTTP_ROOT)
|
||||
|
||||
# Start the background threads
|
||||
headphones.start()
|
||||
@@ -190,4 +188,4 @@ def main():
|
||||
|
||||
# Call main()
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -163,17 +163,17 @@
|
||||
}
|
||||
|
||||
<%
|
||||
if headphones.SONGKICK_FILTER_ENABLED:
|
||||
if headphones.CFG.SONGKICK_FILTER_ENABLED:
|
||||
songkick_filter_enabled = "true"
|
||||
else:
|
||||
songkick_filter_enabled = "false"
|
||||
|
||||
if not headphones.SONGKICK_LOCATION:
|
||||
if not headphones.CFG.SONGKICK_LOCATION:
|
||||
songkick_location = "none"
|
||||
else:
|
||||
songkick_location = headphones.SONGKICK_LOCATION
|
||||
songkick_location = headphones.CFG.SONGKICK_LOCATION
|
||||
|
||||
if headphones.SONGKICK_ENABLED:
|
||||
if headphones.CFG.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.SONGKICK_APIKEY}&jsoncallback=?",
|
||||
$.getJSON("https://api.songkick.com/api/3.0/artists/mbid:${artist['ArtistID']}/calendar.json?apikey=${headphones.CFG.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.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.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>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
@@ -96,8 +96,8 @@
|
||||
%if version.HEADPHONES_VERSION != 'master':
|
||||
(${version.HEADPHONES_VERSION})
|
||||
%endif
|
||||
%if headphones.GIT_BRANCH != 'master':
|
||||
(${headphones.GIT_BRANCH})
|
||||
%if headphones.CFG.GIT_BRANCH != 'master':
|
||||
(${headphones.CFG.GIT_BRANCH})
|
||||
%endif
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -397,7 +397,7 @@
|
||||
<fieldset>
|
||||
<legend>Headphones Indexer</legend>
|
||||
<div class="row checkbox">
|
||||
<input id="use_headphones_indexer" type="checkbox" name="use_headphones_indexer" onclick="initConfigCheckbox($(this));" value="1" ${config['use_headphones_indexer']} /><label>Use Headphones Indexer</label>
|
||||
<input id="headphones_indexer" type="checkbox" name="headphones_indexer" onclick="initConfigCheckbox($(this));" value="1" ${config['headphones_indexer']} /><label>Use Headphones Indexer</label>
|
||||
</div>
|
||||
<div class="config">
|
||||
<div class="row">
|
||||
@@ -1303,7 +1303,7 @@
|
||||
<select name="interface"><h3>
|
||||
%for interface in config['interface_list']:
|
||||
<%
|
||||
if interface == headphones.INTERFACE:
|
||||
if interface == headphones.CFG.INTERFACE:
|
||||
selected = 'selected="selected"'
|
||||
else:
|
||||
selected = ''
|
||||
@@ -1352,7 +1352,7 @@
|
||||
<select name="mirror" id="mirror">
|
||||
%for mirror in config['mirror_list']:
|
||||
<%
|
||||
if mirror == headphones.MIRROR:
|
||||
if mirror == headphones.CFG.MIRROR:
|
||||
selected = 'selected="selected"'
|
||||
else:
|
||||
selected = ''
|
||||
@@ -2013,7 +2013,7 @@
|
||||
$( "#tabs" ).tabs();
|
||||
});
|
||||
initActions();
|
||||
initConfigCheckbox("#use_headphones_indexer");
|
||||
initConfigCheckbox("#headphones_indexer");
|
||||
initConfigCheckbox("#usenewznab");
|
||||
initConfigCheckbox("#usenzbsorg");
|
||||
initConfigCheckbox("#useomgwtfnzbs");
|
||||
|
||||
@@ -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.ADD_ARTISTS:
|
||||
%if not headphones.CFG.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.MUSIC_DIR:
|
||||
<input type="text" value="${headphones.MUSIC_DIR}" name="path" size="70" />
|
||||
%if headphones.CFG.MUSIC_DIR:
|
||||
<input type="text" value="${headphones.CFG.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.LIBRARYSCAN)}><label>Automatically scan library</label>
|
||||
<input type="checkbox" name="libraryscan" id="libraryscan" value="1" ${checked(headphones.CFG.LIBRARYSCAN)}><label>Automatically scan library</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="autoadd" id="autoadd" value="1" ${checked(headphones.ADD_ARTISTS)}><label>Auto-add new artists</label>
|
||||
<input type="checkbox" name="autoadd" id="autoadd" value="1" ${checked(headphones.CFG.AUTO_ADD_ARTISTS)}><label>Auto-add new artists</label>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
@@ -83,8 +83,8 @@
|
||||
<div class="row">
|
||||
<label for="">Username</label>
|
||||
<%
|
||||
if headphones.LASTFM_USERNAME:
|
||||
lastfmvalue = headphones.LASTFM_USERNAME
|
||||
if headphones.CFG.LASTFM_USERNAME:
|
||||
lastfmvalue = headphones.CFG.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.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.CFG.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>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if oldalbumdata['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CFG.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.API_ENABLED:
|
||||
if not headphones.CFG.API_ENABLED:
|
||||
self.data = 'API not enabled'
|
||||
return
|
||||
if not headphones.API_KEY:
|
||||
if not headphones.CFG.API_KEY:
|
||||
self.data = 'API key not generated'
|
||||
return
|
||||
if len(headphones.API_KEY) != 32:
|
||||
if len(headphones.CFG.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.API_KEY:
|
||||
if kwargs['apikey'] != headphones.CFG.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.GIT_PATH,
|
||||
'git_path' : headphones.CFG.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.CACHE_DIR, 'artwork')
|
||||
path_to_art_cache = os.path.join(headphones.CFG.CACHE_DIR, 'artwork')
|
||||
|
||||
def __init__(self):
|
||||
self.id = None
|
||||
|
||||
404
headphones/config.py
Normal file
404
headphones/config.py
Normal file
@@ -0,0 +1,404 @@
|
||||
import headphones.logger
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
from configobj import ConfigObj
|
||||
|
||||
_config_definitions = {
|
||||
'CONFIG_VERSION': (str, 'General', '0'),
|
||||
'HTTP_PORT': (int, 'General', 8181),
|
||||
'HTTP_HOST': (str, 'General', '0.0.0.0'),
|
||||
'HTTP_USERNAME': (str, 'General', ''),
|
||||
'HTTP_PASSWORD': (str, 'General', ''),
|
||||
'HTTP_ROOT': (str, 'General', '/'),
|
||||
'HTTP_PROXY': (int, 'General', 0),
|
||||
'ENABLE_HTTPS': (int, 'General', 0),
|
||||
'LAUNCH_BROWSER': (int, 'General', 1),
|
||||
'API_ENABLED': (int, 'General', 0),
|
||||
'API_KEY': (str, 'General', ''),
|
||||
'GIT_PATH': (str, 'General', ''),
|
||||
'GIT_USER': (str, 'General', 'rembo10'),
|
||||
'GIT_BRANCH': (str, 'General', 'master'),
|
||||
'DO_NOT_OVERRIDE_GIT_BRANCH': (int, 'General', 0),
|
||||
'LOG_DIR': (str, 'General', ''),
|
||||
'CACHE_DIR': (str, 'General', ''),
|
||||
'CHECK_GITHUB': (int, 'General', 1),
|
||||
'CHECK_GITHUB_ON_STARTUP': (int, 'General', 1),
|
||||
'CHECK_GITHUB_INTERVAL': (int, 'General', 360),
|
||||
'MUSIC_DIR': (str, 'General', ''),
|
||||
'DESTINATION_DIR': (str, 'General',''),
|
||||
'LOSSLESS_DESTINATION_DIR': (str, 'General', ''),
|
||||
'PREFERRED_QUALITY': (int, 'General', 0),
|
||||
'PREFERRED_BITRATE': (str, 'General', ''),
|
||||
'PREFERRED_BITRATE_HIGH_BUFFER': (int, 'General', 0),
|
||||
'PREFERRED_BITRATE_LOW_BUFFER': (int, 'General', 0),
|
||||
'PREFERRED_BITRATE_ALLOW_LOSSLESS': (int, 'General', 0),
|
||||
'DETECT_BITRATE': (int, 'General', 0),
|
||||
'LOSSLESS_BITRATE_FROM': (int, 'General', 0),
|
||||
'LOSSLESS_BITRATE_TO': (int, 'General', 0),
|
||||
'AUTO_ADD_ARTISTS': (int, 'General', 1),
|
||||
'CORRECT_METADATA': (int, 'General', 0),
|
||||
'FREEZE_DB': (int, 'General', 0),
|
||||
'MOVE_FILES': (int, 'General', 0),
|
||||
'RENAME_FILES': (int, 'General', 0),
|
||||
'FOLDER_FORMAT': (str, 'General', 'Artist/Album [Year]'),
|
||||
'FILE_FORMAT': (str, 'General', 'Track Artist - Album [Year] - Title'),
|
||||
'FILE_UNDERSCORES': (int, 'General', 0),
|
||||
'CLEANUP_FILES': (int, 'General', 0),
|
||||
'KEEP_NFO': (int, 'General', 0),
|
||||
'ADD_ALBUM_ART': (int, 'General', 0),
|
||||
'ALBUM_ART_FORMAT': (str, 'General', 'folder'),
|
||||
'EMBED_ALBUM_ART': (int, 'General', 0),
|
||||
'EMBED_LYRICS': (int, 'General', 0),
|
||||
'REPLACE_EXISTING_FOLDERS': (int, 'General', 0),
|
||||
'NZB_DOWNLOADER': (int, 'General', 0), # 0: sabnzbd, 1: nzbget, 2: blackhole
|
||||
'TORRENT_DOWNLOADER': (int, 'General', 0), # 0: blackhole, 1: transmission, 2: utorrent
|
||||
'DOWNLOAD_DIR': (str, 'General', ''),
|
||||
'BLACKHOLE': (int, 'General', 0),
|
||||
'BLACKHOLE_DIR': (str, 'General', ''),
|
||||
'USENET_RETENTION': (int, 'General', '1500'),
|
||||
'INCLUDE_EXTRAS': (int, 'General', 0),
|
||||
'EXTRAS': (str, 'General', ''),
|
||||
'AUTOWANT_UPCOMING': (int, 'General', 1),
|
||||
'AUTOWANT_ALL': (int, 'General', 0),
|
||||
'AUTOWANT_MANUALLY_ADDED': (int, 'General', 1),
|
||||
'KEEP_TORRENT_FILES': (int, 'General', 0),
|
||||
'PREFER_TORRENTS': (int, 'General', 0),
|
||||
|
||||
'OPEN_MAGNET_LINKS': (int, 'General', 0),
|
||||
'SEARCH_INTERVAL': (int, 'General', 1440),
|
||||
'LIBRARYSCAN': (int, 'General', 1),
|
||||
'LIBRARYSCAN_INTERVAL': (int, 'General', 300),
|
||||
'DOWNLOAD_SCAN_INTERVAL': (int, 'General', 5),
|
||||
'UPDATE_DB_INTERVAL': (int, 'General', 24),
|
||||
'MB_IGNORE_AGE': (int, 'General', 365),
|
||||
'TORRENT_REMOVAL_INTERVAL': (int, 'General', 720),
|
||||
'TORRENTBLACKHOLE_DIR': (str, 'General', ''),
|
||||
'NUMBEROFSEEDERS': (str, 'General', '10'),
|
||||
'DOWNLOAD_TORRENT_DIR': (str, 'General', ''),
|
||||
'KAT': (int, 'Kat', 0),
|
||||
'KAT_PROXY_URL': (str, 'Kat', ''),
|
||||
'KAT_RATIO': (str, 'Kat', ''),
|
||||
'PIRATEBAY': (int, 'Piratebay', 0),
|
||||
'PIRATEBAY_PROXY_URL': (str, 'Piratebay', ''),
|
||||
'PIRATEBAY_RATIO': (str, 'Piratebay', ''),
|
||||
'MININOVA': (int, 'Mininova', 0),
|
||||
'MININOVA_RATIO': (str, 'Mininova', ''),
|
||||
'WAFFLES': (int, 'Waffles', 0),
|
||||
'WAFFLES_UID': (str, 'Waffles', ''),
|
||||
'WAFFLES_PASSKEY': (str, 'Waffles', ''),
|
||||
'WAFFLES_RATIO': (str, 'Waffles', ''),
|
||||
'RUTRACKER': (int, 'Rutracker', 0),
|
||||
'RUTRACKER_USER': (str, 'Rutracker', ''),
|
||||
'RUTRACKER_PASSWORD': (str, 'Rutracker', ''),
|
||||
'RUTRACKER_RATIO': (str, 'Rutracker', ''),
|
||||
'WHATCD': (int, 'What.cd', 0),
|
||||
'WHATCD_USERNAME': (str, 'What.cd', ''),
|
||||
'WHATCD_PASSWORD': (str, 'What.cd', ''),
|
||||
'WHATCD_RATIO': (str, 'What.cd', ''),
|
||||
'SAB_HOST': (str, 'SABnzbd', ''),
|
||||
'SAB_USERNAME': (str, 'SABnzbd', ''),
|
||||
'SAB_PASSWORD': (str, 'SABnzbd', ''),
|
||||
'SAB_APIKEY': (str, 'SABnzbd', ''),
|
||||
'SAB_CATEGORY': (str, 'SABnzbd', ''),
|
||||
'NZBGET_USERNAME': (str, 'NZBget', 'nzbget_username', 'nzbget'),
|
||||
'NZBGET_PASSWORD': (str, 'NZBget', 'nzbget_password', ''),
|
||||
'NZBGET_CATEGORY': (str, 'NZBget', 'nzbget_category', ''),
|
||||
'NZBGET_HOST': (str, 'NZBget', 'nzbget_host', ''),
|
||||
'NZBGET_PRIORITY': (int, 'NZBget', 'nzbget_priority', 0),
|
||||
'TRANSMISSION_HOST': (str, 'Transmission', 'transmission_host', ''),
|
||||
'TRANSMISSION_USERNAME': (str, 'Transmission', 'transmission_username', ''),
|
||||
'TRANSMISSION_PASSWORD': (str, 'Transmission', 'transmission_password', ''),
|
||||
'UTORRENT_HOST': (str, 'uTorrent', 'utorrent_host', ''),
|
||||
'UTORRENT_USERNAME': (str, 'uTorrent', 'utorrent_username', ''),
|
||||
'UTORRENT_PASSWORD': (str, 'uTorrent', 'utorrent_password', ''),
|
||||
'UTORRENT_LABEL': (str, 'uTorrent', 'utorrent_label', ''),
|
||||
'NEWZNAB': (int, 'Newznab', 'newznab', 0),
|
||||
'NEWZNAB_HOST': (str, 'Newznab', 'newznab_host', ''),
|
||||
'NEWZNAB_APIKEY': (str, 'Newznab', 'newznab_apikey', ''),
|
||||
'NEWZNAB_ENABLED': (int, 'Newznab', 'newznab_enabled', 1),
|
||||
'NZBSORG': (int, 'NZBsorg', 'nzbsorg', 0),
|
||||
'NZBSORG_UID': (str, 'NZBsorg', 'nzbsorg_uid', ''),
|
||||
'NZBSORG_HASH': (str, 'NZBsorg', 'nzbsorg_hash', ''),
|
||||
'OMGWTFNZBS': (int, 'omgwtfnzbs', 'omgwtfnzbs', 0),
|
||||
'OMGWTFNZBS_UID': (str, 'omgwtfnzbs', 'omgwtfnzbs_uid', ''),
|
||||
'OMGWTFNZBS_APIKEY': (str, 'omgwtfnzbs', 'omgwtfnzbs_apikey', ''),
|
||||
'PREFERRED_WORDS': (str, 'General', 'preferred_words', ''),
|
||||
'IGNORED_WORDS': (str, 'General', 'ignored_words', ''),
|
||||
'REQUIRED_WORDS': (str, 'General', 'required_words', ''),
|
||||
'LASTFM_USERNAME': (str, 'General', 'lastfm_username', ''),
|
||||
'INTERFACE': (str, 'General', 'interface', 'default'),
|
||||
'FOLDER_PERMISSIONS': (str, 'General', 'folder_permissions', '0755'),
|
||||
'FILE_PERMISSIONS': (str, 'General', 'file_permissions', '0644'),
|
||||
'ENCODERFOLDER': (str, 'General', 'encoderfolder', ''),
|
||||
'ENCODER_PATH': (str, 'General', 'encoder_path', ''),
|
||||
'ENCODER': (str, 'General', 'encoder', 'ffmpeg'),
|
||||
'XLDPROFILE': (str, 'General', 'xldprofile', ''),
|
||||
'BITRATE': (int, 'General', 'bitrate', 192),
|
||||
'SAMPLINGFREQUENCY': (int, 'General', 'samplingfrequency', 44100),
|
||||
'MUSIC_ENCODER': (int, 'General', 'music_encoder', 0),
|
||||
'ADVANCEDENCODER': (str, 'General', 'advancedencoder', ''),
|
||||
'ENCODEROUTPUTFORMAT': (str, 'General', 'encoderoutputformat', 'mp3'),
|
||||
'ENCODERQUALITY': (int, 'General', 'encoderquality', 2),
|
||||
'ENCODERVBRCBR': (str, 'General', 'encodervbrcbr', 'cbr'),
|
||||
'ENCODERLOSSLESS': (int, 'General', 'encoderlossless', 1),
|
||||
'ENCODER_MULTICORE': (int, 'General', 'encoder_multicore', 0),
|
||||
'DELETE_LOSSLESS_FILES': (int, 'General', 'delete_lossless_files', 1),
|
||||
'GROWL_ENABLED': (int, 'Growl', 'growl_enabled', 0),
|
||||
'GROWL_HOST': (str, 'Growl', 'growl_host', ''),
|
||||
'GROWL_PASSWORD': (str, 'Growl', 'growl_password', ''),
|
||||
'GROWL_ONSNATCH': (int, 'Growl', 'growl_onsnatch', 0),
|
||||
'PROWL_ENABLED': (int, 'Prowl', 'prowl_enabled', 0),
|
||||
'PROWL_KEYS': (str, 'Prowl', 'prowl_keys', ''),
|
||||
'PROWL_ONSNATCH': (int, 'Prowl', 'prowl_onsnatch', 0),
|
||||
'PROWL_PRIORITY': (int, 'Prowl', 'prowl_priority', 0),
|
||||
'XBMC_ENABLED': (int, 'XBMC', 'xbmc_enabled', 0),
|
||||
'XBMC_HOST': (str, 'XBMC', 'xbmc_host', ''),
|
||||
'XBMC_USERNAME': (str, 'XBMC', 'xbmc_username', ''),
|
||||
'XBMC_PASSWORD': (str, 'XBMC', 'xbmc_password', ''),
|
||||
'XBMC_UPDATE': (int, 'XBMC', 'xbmc_update', 0),
|
||||
'XBMC_NOTIFY': (int, 'XBMC', 'xbmc_notify', 0),
|
||||
'LMS_ENABLED': (int, 'LMS', 'lms_enabled', 0),
|
||||
'LMS_HOST': (str, 'LMS', 'lms_host', ''),
|
||||
'PLEX_ENABLED': (int, 'Plex', 'plex_enabled', 0),
|
||||
'PLEX_SERVER_HOST': (str, 'Plex', 'plex_server_host', ''),
|
||||
'PLEX_CLIENT_HOST': (str, 'Plex', 'plex_client_host', ''),
|
||||
'PLEX_USERNAME': (str, 'Plex', 'plex_username', ''),
|
||||
'PLEX_PASSWORD': (str, 'Plex', 'plex_password', ''),
|
||||
'PLEX_UPDATE': (int, 'Plex', 'plex_update', 0),
|
||||
'PLEX_NOTIFY': (int, 'Plex', 'plex_notify', 0),
|
||||
'NMA_ENABLED': (int, 'NMA', 'nma_enabled', 0),
|
||||
'NMA_APIKEY': (str, 'NMA', 'nma_apikey', ''),
|
||||
'NMA_PRIORITY': (int, 'NMA', 'nma_priority', 0),
|
||||
'NMA_ONSNATCH': (int, 'NMA', 'nma_onsnatch', 0),
|
||||
'PUSHALOT_ENABLED': (int, 'Pushalot', 'pushalot_enabled', 0),
|
||||
'PUSHALOT_APIKEY': (str, 'Pushalot', 'pushalot_apikey', ''),
|
||||
'PUSHALOT_ONSNATCH': (int, 'Pushalot', 'pushalot_onsnatch', 0),
|
||||
'SYNOINDEX_ENABLED': (int, 'Synoindex', 'synoindex_enabled', 0),
|
||||
'PUSHOVER_ENABLED': (int, 'Pushover', 'pushover_enabled', 0),
|
||||
'PUSHOVER_KEYS': (str, 'Pushover', 'pushover_keys', ''),
|
||||
'PUSHOVER_ONSNATCH': (int, 'Pushover', 'pushover_onsnatch', 0),
|
||||
'PUSHOVER_PRIORITY': (int, 'Pushover', 'pushover_priority', 0),
|
||||
'PUSHOVER_APITOKEN': (str, 'Pushover', 'pushover_apitoken', ''),
|
||||
'PUSHBULLET_ENABLED': (int, 'PushBullet', 'pushbullet_enabled', 0),
|
||||
'PUSHBULLET_APIKEY': (str, 'PushBullet', 'pushbullet_apikey', ''),
|
||||
'PUSHBULLET_DEVICEID': (str, 'PushBullet', 'pushbullet_deviceid', ''),
|
||||
'PUSHBULLET_ONSNATCH': (int, 'PushBullet', 'pushbullet_onsnatch', 0),
|
||||
'TWITTER_ENABLED': (int, 'Twitter', 'twitter_enabled', 0),
|
||||
'TWITTER_ONSNATCH': (int, 'Twitter', 'twitter_onsnatch', 0),
|
||||
'TWITTER_USERNAME': (str, 'Twitter', 'twitter_username', ''),
|
||||
'TWITTER_PASSWORD': (str, 'Twitter', 'twitter_password', ''),
|
||||
'TWITTER_PREFIX': (str, 'Twitter', 'twitter_prefix', 'Headphones'),
|
||||
'OSX_NOTIFY_ENABLED': (int, 'OSX_Notify', 'osx_notify_enabled', 0),
|
||||
'OSX_NOTIFY_ONSNATCH': (int, 'OSX_Notify', 'osx_notify_onsnatch', 0),
|
||||
'OSX_NOTIFY_APP': (str, 'OSX_Notify', 'osx_notify_app', '/Applications/Headphones'),
|
||||
'BOXCAR_ENABLED': (int, 'Boxcar', 'boxcar_enabled', 0),
|
||||
'BOXCAR_ONSNATCH': (int, 'Boxcar', 'boxcar_onsnatch', 0),
|
||||
'BOXCAR_TOKEN': (str, 'Boxcar', 'boxcar_token', ''),
|
||||
'SUBSONIC_ENABLED': (int, 'Subsonic', 'subsonic_enabled', 0),
|
||||
'SUBSONIC_HOST': (str, 'Subsonic', 'subsonic_host', ''),
|
||||
'SUBSONIC_USERNAME': (str, 'Subsonic', 'subsonic_username', ''),
|
||||
'SUBSONIC_PASSWORD': (str, 'Subsonic', 'subsonic_password', ''),
|
||||
'SONGKICK_ENABLED': (int, 'Songkick', 'songkick_enabled', 1),
|
||||
'SONGKICK_APIKEY': (str, 'Songkick', 'songkick_apikey', 'nd1We7dFW2RqxPw8'),
|
||||
'SONGKICK_LOCATION': (str, 'Songkick', 'songkick_location', ''),
|
||||
'SONGKICK_FILTER_ENABLED': (int, 'Songkick', 'songkick_filter_enabled', 0),
|
||||
'MIRROR': (str, 'General', 'mirror', 'musicbrainz.org'),
|
||||
'CUSTOMHOST': (str, 'General', 'customhost', 'localhost'),
|
||||
'CUSTOMPORT': (int, 'General', 'customport', 5000),
|
||||
'CUSTOMSLEEP': (int, 'General', 'customsleep', 1),
|
||||
'HPUSER': (str, 'General', 'hpuser', ''),
|
||||
'HPPASS': (str, 'General', 'hppass', ''),
|
||||
'CACHE_SIZEMB': (int, 'Advanced', 'cache_sizemb', 32),
|
||||
'JOURNAL_MODE': (str, 'Advanced', 'journal_mode', 'wal'),
|
||||
'ALBUM_COMPLETION_PCT': (int, 'Advanced', 'album_completion_pct', 80), # This is used in importer.py to determine how complete an album needs to be - to be considered "downloaded". Percentage from 0-100
|
||||
'VERIFY_SSL_CERT': (bool, 'Advanced', 'verify_ssl_cert', 1),
|
||||
'HTTPS_CERT': (str, 'General', 'https_cert', ''),
|
||||
'HTTPS_KEY': (str, 'General', 'https_key', ''),
|
||||
'ENCODER_MULTICORE_COUNT': (int, 'General', 'encoder_multicore_count', 0),
|
||||
'EXTRA_NEWZNABS': (list, 'Newznab', 'extra_newznabs', ''),
|
||||
'MPC_ENABLED': (bool, 'MPC', 'mpc_enabled', False),
|
||||
'HEADPHONES_INDEXER': (bool, 'General', 'headphones_indexer', False)
|
||||
}
|
||||
|
||||
|
||||
class Config(object):
|
||||
""" Wraps access to particular values in a config file """
|
||||
|
||||
def __init__(self, config_file):
|
||||
""" Initialize the config with values from a file """
|
||||
self._config_file = config_file
|
||||
self._config = ConfigObj(self._config_file, encoding='utf-8')
|
||||
for key in _config_definitions.keys():
|
||||
self.check_setting(key)
|
||||
self.ENCODER_MULTICORE_COUNT = max(0, self.ENCODER_MULTICORE_COUNT)
|
||||
self._upgrade()
|
||||
|
||||
def _define(self, name):
|
||||
key = name.upper()
|
||||
ini_key = name.lower()
|
||||
definition = _config_definitions[key]
|
||||
if len(definition) == 3:
|
||||
definition_type, section, default = definition
|
||||
else:
|
||||
definition_type, section, _, default = definition
|
||||
return key, definition_type, section, ini_key, default
|
||||
|
||||
def check_section(self, section):
|
||||
""" Check if INI section exists, if not create it """
|
||||
if section not in self._config:
|
||||
self._config[section] = {}
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def check_setting(self, key):
|
||||
""" Cast any value in the config to the right type or use the default """
|
||||
key, definition_type, section, ini_key, default = self._define(key)
|
||||
self.check_section(section)
|
||||
try:
|
||||
my_val = definition_type(self._config[section][ini_key])
|
||||
except Exception:
|
||||
my_val = definition_type(default)
|
||||
self._config[section][ini_key] = my_val
|
||||
return my_val
|
||||
|
||||
def write(self):
|
||||
""" Make a copy of the stored config and write it to the configured file """
|
||||
new_config = ConfigObj(encoding="UTF-8")
|
||||
new_config.filename = self._config_file
|
||||
|
||||
for key in _config_definitions.keys():
|
||||
key, definition_type, section, ini_key, default = self._define(key)
|
||||
self.check_setting(key)
|
||||
if section not in new_config:
|
||||
new_config[section] = {}
|
||||
new_config[section][ini_key] = self._config[section][ini_key]
|
||||
|
||||
# Write it to file
|
||||
headphones.logger.info("Writing configuration to file")
|
||||
|
||||
try:
|
||||
new_config.write()
|
||||
except IOError as e:
|
||||
headphones.logger.error("Error writing configuration file: %s", e)
|
||||
|
||||
def get_extra_newznabs(self):
|
||||
""" Return the extra newznab tuples """
|
||||
extra_newznabs = list(
|
||||
itertools.izip(*[itertools.islice(self.EXTRA_NEWZNABS, i, None, 3)
|
||||
for i in range(3)])
|
||||
)
|
||||
return extra_newznabs
|
||||
|
||||
def clear_extra_newznabs(self):
|
||||
""" Forget about the configured extra newznabs """
|
||||
self.EXTRA_NEWZNABS = []
|
||||
|
||||
def add_extra_newznab(self, newznab):
|
||||
""" Add a new extra newznab """
|
||||
for item in newznab:
|
||||
self.EXTRA_NEWZNABS.append(item)
|
||||
|
||||
def __getattr__(self, name):
|
||||
"""
|
||||
Returns something from the ini unless it is a real property
|
||||
of the configuration object or is not all caps.
|
||||
"""
|
||||
if not re.match(r'[A-Z_]+$', name):
|
||||
return super(Config, self).__getattr__(name)
|
||||
else:
|
||||
return self.check_setting(name)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""
|
||||
Maps all-caps properties to ini values unless they exist on the
|
||||
configuration object.
|
||||
"""
|
||||
if not re.match(r'[A-Z_]+$', name):
|
||||
super(Config, self).__setattr__(name, value)
|
||||
return value
|
||||
else:
|
||||
key, definition_type, section, ini_key, default = self._define(name)
|
||||
self._config[section][ini_key] = definition_type(value)
|
||||
return self._config[section][ini_key]
|
||||
|
||||
def process_kwargs(self, kwargs):
|
||||
"""
|
||||
Given a big bunch of key value pairs, apply them to the ini.
|
||||
"""
|
||||
for name, value in kwargs.items():
|
||||
key, definition_type, section, ini_key, default = self._define(name)
|
||||
self._config[section][ini_key] = definition_type(value)
|
||||
|
||||
def _upgrade(self):
|
||||
""" Update folder formats in the config & bump up config version """
|
||||
if self.CONFIG_VERSION == '0':
|
||||
from headphones.helpers import replace_all
|
||||
file_values = {
|
||||
'tracknumber': 'Track',
|
||||
'title': 'Title',
|
||||
'artist': 'Artist',
|
||||
'album': 'Album',
|
||||
'year': 'Year'
|
||||
}
|
||||
folder_values = {
|
||||
'artist': 'Artist',
|
||||
'album': 'Album',
|
||||
'year': 'Year',
|
||||
'releasetype': 'Type',
|
||||
'first': 'First',
|
||||
'lowerfirst': 'first'
|
||||
}
|
||||
self.FILE_FORMAT = replace_all(self.FILE_FORMAT, file_values)
|
||||
self.FOLDER_FORMAT = replace_all(self.FOLDER_FORMAT, folder_values)
|
||||
|
||||
self.CONFIG_VERSION = '1'
|
||||
|
||||
if self.CONFIG_VERSION == '1':
|
||||
from headphones.helpers import replace_all
|
||||
file_values = {
|
||||
'Track': '$Track',
|
||||
'Title': '$Title',
|
||||
'Artist': '$Artist',
|
||||
'Album': '$Album',
|
||||
'Year': '$Year',
|
||||
'track': '$track',
|
||||
'title': '$title',
|
||||
'artist': '$artist',
|
||||
'album': '$album',
|
||||
'year': '$year'
|
||||
}
|
||||
folder_values = {
|
||||
'Artist': '$Artist',
|
||||
'Album': '$Album',
|
||||
'Year': '$Year',
|
||||
'Type': '$Type',
|
||||
'First': '$First',
|
||||
'artist': '$artist',
|
||||
'album': '$album',
|
||||
'year': '$year',
|
||||
'type': '$type',
|
||||
'first': '$first'
|
||||
}
|
||||
self.FILE_FORMAT = replace_all(self.FILE_FORMAT, file_values)
|
||||
self.FOLDER_FORMAT = replace_all(self.FOLDER_FORMAT, folder_values)
|
||||
self.CONFIG_VERSION = '2'
|
||||
|
||||
if self.CONFIG_VERSION == '2':
|
||||
# Update the config to use direct path to the encoder rather than the encoder folder
|
||||
if self.ENCODERFOLDER:
|
||||
self.ENCODER_PATH = os.path.join(self.ENCODERFOLDER, self.ENCODER)
|
||||
self.CONFIG_VERSION = '3'
|
||||
|
||||
if self.CONFIG_VERSION == '3':
|
||||
# Update the BLACKHOLE option to the NZB_DOWNLOADER format
|
||||
if self.BLACKHOLE:
|
||||
self.NZB_DOWNLOADER = 2
|
||||
self.CONFIG_VERSION = '4'
|
||||
|
||||
# Enable Headphones Indexer if they have a VIP account
|
||||
if self.CONFIG_VERSION == '4':
|
||||
if self.HPUSER and self.HPPASS:
|
||||
self.HEADPHONES_INDEXER = True
|
||||
self.CONFIG_VERSION = '5'
|
||||
@@ -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.CACHE_SIZEMB:
|
||||
if not headphones.CFG.CACHE_SIZEMB:
|
||||
#sqlite will work with this (very slowly)
|
||||
return 0
|
||||
return int(headphones.CACHE_SIZEMB)
|
||||
return int(headphones.CFG.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.JOURNAL_MODE)
|
||||
self.connection.execute("PRAGMA journal_mode = %s" % headphones.CFG.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.MUSIC_DIR
|
||||
folder_format = headphones.FOLDER_FORMAT
|
||||
file_format = headphones.FILE_FORMAT
|
||||
music_dir = headphones.CFG.MUSIC_DIR
|
||||
folder_format = headphones.CFG.FOLDER_FORMAT
|
||||
file_format = headphones.CFG.FILE_FORMAT
|
||||
|
||||
full_format = os.path.join(headphones.MUSIC_DIR)
|
||||
full_format = os.path.join(headphones.CFG.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.INCLUDE_EXTRAS,
|
||||
"Extras": headphones.EXTRAS }
|
||||
"IncludeExtras": headphones.CFG.INCLUDE_EXTRAS,
|
||||
"Extras": headphones.CFG.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.MB_IGNORE_AGE
|
||||
pause_delta = headphones.CFG.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.AUTOWANT_ALL:
|
||||
if headphones.CFG.AUTOWANT_ALL:
|
||||
newValueDict['Status'] = "Wanted"
|
||||
elif album['ReleaseDate'] > today and headphones.AUTOWANT_UPCOMING:
|
||||
elif album['ReleaseDate'] > today and headphones.CFG.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.AUTOWANT_UPCOMING:
|
||||
elif helpers.get_age(album['ReleaseDate']) and helpers.get_age(today) - helpers.get_age(album['ReleaseDate']) < 21 and headphones.CFG.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.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if rg_exists['Status'] == 'Skipped' and ((have_track_count/float(total_track_count)) >= (headphones.CFG.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.ALBUM_COMPLETION_PCT/100.0)):
|
||||
if ((have_track_count/float(total_track_count)) >= (headphones.CFG.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.AUTOWANT_ALL:
|
||||
if not rg_exists and not marked_as_downloaded and headphones.CFG.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.INCLUDE_EXTRAS:
|
||||
if headphones.CFG.INCLUDE_EXTRAS:
|
||||
newValueDict['IncludeExtras'] = 1
|
||||
newValueDict['Extras'] = headphones.EXTRAS
|
||||
newValueDict['Extras'] = headphones.CFG.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.AUTOWANT_MANUALLY_ADDED:
|
||||
if headphones.CFG.AUTOWANT_MANUALLY_ADDED:
|
||||
newValueDict = {"Status": "Wanted"}
|
||||
else:
|
||||
newValueDict = {"Status": "Skipped"}
|
||||
myDB.upsert("albums", newValueDict, controlValueDict)
|
||||
|
||||
# Start a search for the album
|
||||
if headphones.AUTOWANT_MANUALLY_ADDED:
|
||||
if headphones.CFG.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.LASTFM_USERNAME:
|
||||
if not headphones.CFG.LASTFM_USERNAME:
|
||||
logger.warn("Last.FM username not set, not importing artists.")
|
||||
return
|
||||
|
||||
logger.info("Fetching artists from Last.FM for username: %s", headphones.LASTFM_USERNAME)
|
||||
data = request_lastfm("library.getartists", limit=10000, user=headphones.LASTFM_USERNAME)
|
||||
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)
|
||||
|
||||
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.LIBRARYSCAN:
|
||||
if cron and not headphones.CFG.LIBRARYSCAN:
|
||||
return
|
||||
|
||||
if not dir:
|
||||
if not headphones.MUSIC_DIR:
|
||||
if not headphones.CFG.MUSIC_DIR:
|
||||
return
|
||||
else:
|
||||
dir = headphones.MUSIC_DIR
|
||||
dir = headphones.CFG.MUSIC_DIR
|
||||
|
||||
# If we're appending a dir, it's coming from the post processor which is
|
||||
# already bytestring
|
||||
@@ -203,7 +203,6 @@ def libraryScan(dir=None, append=False, ArtistID=None, ArtistName=None, cron=Fal
|
||||
elif latest_artist[song_count] != latest_artist[song_count-1] and song_count !=0:
|
||||
logger.info("Now matching songs by %s" % song['ArtistName'])
|
||||
|
||||
#print song['ArtistName']+' - '+song['AlbumTitle']+' - '+song['TrackTitle']
|
||||
song_count += 1
|
||||
completion_percentage = float(song_count)/total_number_of_songs * 100
|
||||
|
||||
@@ -317,7 +316,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.ADD_ARTISTS:
|
||||
if headphones.CFG.AUTO_ADD_ARTISTS:
|
||||
logger.info('Importing %i new artists' % len(artist_list))
|
||||
importer.artistlist_to_mbids(artist_list)
|
||||
else:
|
||||
@@ -326,8 +325,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.DETECT_BITRATE:
|
||||
headphones.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
if headphones.CFG.DETECT_BITRATE:
|
||||
headphones.CFG.PREFERRED_BITRATE = sum(bitrates)/len(bitrates)/1000
|
||||
|
||||
else:
|
||||
# If we're appending a new album to the database, update the artists total track counts
|
||||
@@ -363,7 +362,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.ALBUM_COMPLETION_PCT and album['Status'] == 'Skipped':
|
||||
if album_completion >= headphones.CFG.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.LOG_DIR, FILENAME)
|
||||
filename = os.path.join(headphones.CFG.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.MIRROR == "musicbrainz.org":
|
||||
if headphones.CFG.MIRROR == "musicbrainz.org":
|
||||
mbhost = "musicbrainz.org"
|
||||
mbport = 80
|
||||
sleepytime = 1
|
||||
elif headphones.MIRROR == "custom":
|
||||
mbhost = headphones.CUSTOMHOST
|
||||
mbport = int(headphones.CUSTOMPORT)
|
||||
sleepytime = int(headphones.CUSTOMSLEEP)
|
||||
elif headphones.MIRROR == "headphones":
|
||||
elif headphones.CFG.MIRROR == "custom":
|
||||
mbhost = headphones.CFG.CUSTOMHOST
|
||||
mbport = int(headphones.CFG.CUSTOMPORT)
|
||||
sleepytime = int(headphones.CFG.CUSTOMSLEEP)
|
||||
elif headphones.CFG.MIRROR == "headphones":
|
||||
mbhost = "144.76.94.239"
|
||||
mbport = 8181
|
||||
mbuser = headphones.HPUSER
|
||||
mbpass = headphones.HPPASS
|
||||
mbuser = headphones.CFG.HPUSER
|
||||
mbpass = headphones.CFG.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.MIRROR == "headphones":
|
||||
if headphones.CFG.MIRROR == "headphones":
|
||||
if not mbuser and mbpass:
|
||||
logger.warn("No username or password set for VIP server")
|
||||
else:
|
||||
@@ -278,7 +278,7 @@ def getArtist(artistid, extrasonly=False):
|
||||
extras = map(int, db_artist['Extras'].split(','))
|
||||
else:
|
||||
extras = []
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "dj-mix", "mixtape/street", "broadcast", "interview", "demo"]
|
||||
extras_list = headphones.POSSIBLE_EXTRAS
|
||||
|
||||
includes = []
|
||||
|
||||
@@ -558,8 +558,6 @@ def get_new_releases(rgid,includeExtras=False,forcefull=False):
|
||||
|
||||
myDB.upsert("alltracks", newValueDict, controlValueDict)
|
||||
num_new_releases = num_new_releases + 1
|
||||
#print releasedata['title']
|
||||
#print num_new_releases
|
||||
if album_checker:
|
||||
logger.info('[%s] Existing release %s (%s) updated' % (release['ArtistName'], release['AlbumTitle'], rel_id_check))
|
||||
else:
|
||||
|
||||
@@ -24,7 +24,7 @@ from headphones import logger
|
||||
from beets.mediafile import MediaFile
|
||||
|
||||
# xld
|
||||
if headphones.ENCODER == 'xld':
|
||||
if headphones.CFG.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.XLDPROFILE)
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CFG.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.ENCODEROUTPUTFORMAT.encode(headphones.SYS_ENCODING)
|
||||
encoderFormat = headphones.CFG.ENCODEROUTPUTFORMAT.encode(headphones.SYS_ENCODING)
|
||||
else:
|
||||
xldMusicFile = os.path.join(r, music)
|
||||
xldInfoMusic = MediaFile(xldMusicFile)
|
||||
encoderFormat = xldFormat
|
||||
|
||||
if (headphones.ENCODERLOSSLESS):
|
||||
if (headphones.CFG.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.ENCODER_PATH:
|
||||
encoder = headphones.ENCODER_PATH.encode(headphones.SYS_ENCODING)
|
||||
if headphones.CFG.ENCODER_PATH:
|
||||
encoder = headphones.CFG.ENCODER_PATH.encode(headphones.SYS_ENCODING)
|
||||
else:
|
||||
if XLD:
|
||||
encoder = os.path.join('/Applications', 'xld')
|
||||
elif headphones.ENCODER =='lame':
|
||||
elif headphones.CFG.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.ENCODER =='ffmpeg':
|
||||
elif headphones.CFG.ENCODER =='ffmpeg':
|
||||
if headphones.SYS_PLATFORM == "win32":
|
||||
encoder = "C:/Program Files/ffmpeg/bin/ffmpeg.exe"
|
||||
else:
|
||||
encoder="ffmpeg"
|
||||
elif headphones.ENCODER == 'libav':
|
||||
elif headphones.CFG.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.ENCODER == 'lame':
|
||||
elif headphones.CFG.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.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.BITRATE)
|
||||
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)
|
||||
else:
|
||||
encode = True
|
||||
else:
|
||||
if headphones.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if headphones.CFG.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.ENCODEROUTPUTFORMAT=='mp3' or headphones.ENCODEROUTPUTFORMAT=='m4a'):
|
||||
if (music.decode(headphones.SYS_ENCODING, 'replace').lower().endswith('.'+headphones.ENCODEROUTPUTFORMAT) and (int(infoMusic.bitrate / 1000 ) <= headphones.BITRATE)):
|
||||
logger.info('%s has bitrate <= %skb, will not be re-encoded', music, headphones.BITRATE)
|
||||
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)
|
||||
else:
|
||||
encode = True
|
||||
# encode
|
||||
@@ -149,11 +149,11 @@ def encode(albumPath):
|
||||
processes = 1
|
||||
|
||||
# Use multicore if enabled
|
||||
if headphones.ENCODER_MULTICORE:
|
||||
if headphones.ENCODER_MULTICORE_COUNT == 0:
|
||||
if headphones.CFG.ENCODER_MULTICORE:
|
||||
if headphones.CFG.ENCODER_MULTICORE_COUNT == 0:
|
||||
processes = multiprocessing.cpu_count()
|
||||
else:
|
||||
processes = headphones.ENCODER_MULTICORE_COUNT
|
||||
processes = headphones.CFG.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.DELETE_LOSSLESS_FILES:
|
||||
if headphones.CFG.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.ENCODER)
|
||||
logger.error("One or more files failed to encode. Ensure you have the latest version of %s installed.", headphones.CFG.ENCODER)
|
||||
return None
|
||||
|
||||
time.sleep(1)
|
||||
@@ -263,17 +263,17 @@ def command(encoder, musicSource, musicDest, albumPath):
|
||||
cmd.extend([xldDestDir])
|
||||
|
||||
# Lame
|
||||
elif headphones.ENCODER == 'lame':
|
||||
elif headphones.CFG.ENCODER == 'lame':
|
||||
cmd = [encoder]
|
||||
opts = []
|
||||
if not headphones.ADVANCEDENCODER:
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
opts.extend(['-h'])
|
||||
if headphones.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['--resample', str(headphones.SAMPLINGFREQUENCY), '-b', str(headphones.BITRATE)])
|
||||
elif headphones.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-v', str(headphones.ENCODERQUALITY)])
|
||||
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)])
|
||||
else:
|
||||
advanced = (headphones.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CFG.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.ENCODER == 'ffmpeg':
|
||||
elif headphones.CFG.ENCODER == 'ffmpeg':
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.ADVANCEDENCODER:
|
||||
if headphones.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.SAMPLINGFREQUENCY), '-ab', str(headphones.BITRATE) + 'k'])
|
||||
elif headphones.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.ENCODERQUALITY)])
|
||||
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)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
advanced = (headphones.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CFG.ADVANCEDENCODER.split())
|
||||
for tok in advanced:
|
||||
opts.extend([tok.encode(headphones.SYS_ENCODING)])
|
||||
opts.extend([musicDest])
|
||||
cmd.extend(opts)
|
||||
|
||||
# Libav
|
||||
elif headphones.ENCODER == "libav":
|
||||
elif headphones.CFG.ENCODER == "libav":
|
||||
cmd = [encoder, '-i', musicSource]
|
||||
opts = []
|
||||
if not headphones.ADVANCEDENCODER:
|
||||
if headphones.ENCODEROUTPUTFORMAT=='ogg':
|
||||
if not headphones.CFG.ADVANCEDENCODER:
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='ogg':
|
||||
opts.extend(['-acodec', 'libvorbis'])
|
||||
if headphones.ENCODEROUTPUTFORMAT=='m4a':
|
||||
if headphones.CFG.ENCODEROUTPUTFORMAT=='m4a':
|
||||
opts.extend(['-strict', 'experimental'])
|
||||
if headphones.ENCODERVBRCBR=='cbr':
|
||||
opts.extend(['-ar', str(headphones.SAMPLINGFREQUENCY), '-ab', str(headphones.BITRATE) + 'k'])
|
||||
elif headphones.ENCODERVBRCBR=='vbr':
|
||||
opts.extend(['-aq', str(headphones.ENCODERQUALITY)])
|
||||
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)])
|
||||
opts.extend(['-y', '-ac', '2', '-vn'])
|
||||
else:
|
||||
advanced = (headphones.ADVANCEDENCODER.split())
|
||||
advanced = (headphones.CFG.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.ENCODER)
|
||||
stdout, stderr = process.communicate(headphones.CFG.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.ENCODER, outlast2lines))
|
||||
logger.error('%s error details: %s' % (headphones.CFG.ENCODER, outlast2lines))
|
||||
out = out.rstrip("\n")
|
||||
logger.debug(out)
|
||||
encoded = False
|
||||
|
||||
@@ -45,9 +45,9 @@ class GROWL(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.enabled = headphones.GROWL_ENABLED
|
||||
self.host = headphones.GROWL_HOST
|
||||
self.password = headphones.GROWL_PASSWORD
|
||||
self.enabled = headphones.CFG.GROWL_ENABLED
|
||||
self.host = headphones.CFG.GROWL_HOST
|
||||
self.password = headphones.CFG.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.PROWL_ENABLED
|
||||
self.keys = headphones.PROWL_KEYS
|
||||
self.priority = headphones.PROWL_PRIORITY
|
||||
self.enabled = headphones.CFG.PROWL_ENABLED
|
||||
self.keys = headphones.CFG.PROWL_KEYS
|
||||
self.priority = headphones.CFG.PROWL_PRIORITY
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('Prowl', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.PROWL_ENABLED:
|
||||
if not headphones.CFG.PROWL_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.prowlapp.com")
|
||||
|
||||
data = {'apikey': headphones.PROWL_KEYS,
|
||||
data = {'apikey': headphones.CFG.PROWL_KEYS,
|
||||
'application': 'Headphones',
|
||||
'event': event,
|
||||
'description': message.encode("utf-8"),
|
||||
'priority': headphones.PROWL_PRIORITY }
|
||||
'priority': headphones.CFG.PROWL_PRIORITY }
|
||||
|
||||
http_handler.request("POST",
|
||||
"/publicapi/add",
|
||||
@@ -197,9 +197,9 @@ class XBMC(object):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.hosts = headphones.XBMC_HOST
|
||||
self.username = headphones.XBMC_USERNAME
|
||||
self.password = headphones.XBMC_PASSWORD
|
||||
self.hosts = headphones.CFG.XBMC_HOST
|
||||
self.username = headphones.CFG.XBMC_USERNAME
|
||||
self.password = headphones.CFG.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.LMS_HOST
|
||||
self.hosts = headphones.CFG.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.PLEX_SERVER_HOST
|
||||
self.client_hosts = headphones.PLEX_CLIENT_HOST
|
||||
self.username = headphones.PLEX_USERNAME
|
||||
self.password = headphones.PLEX_PASSWORD
|
||||
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
|
||||
|
||||
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.NMA_APIKEY
|
||||
nma_priority = headphones.NMA_PRIORITY
|
||||
api = headphones.CFG.NMA_APIKEY
|
||||
nma_priority = headphones.CFG.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.PUSHBULLET_APIKEY
|
||||
self.deviceid = headphones.PUSHBULLET_DEVICEID
|
||||
self.apikey = headphones.CFG.PUSHBULLET_APIKEY
|
||||
self.deviceid = headphones.CFG.PUSHBULLET_DEVICEID
|
||||
|
||||
def conf(self, options):
|
||||
return cherrypy.config['config'].get('PUSHBULLET', options)
|
||||
|
||||
def notify(self, message, event):
|
||||
if not headphones.PUSHBULLET_ENABLED:
|
||||
if not headphones.CFG.PUSHBULLET_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.pushbullet.com")
|
||||
|
||||
data = {'device_iden': headphones.PUSHBULLET_DEVICEID,
|
||||
data = {'device_iden': headphones.CFG.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.PUSHBULLET_APIKEY + ":") },
|
||||
'Authorization' : 'Basic %s' % base64.b64encode(headphones.CFG.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.PUSHALOT_ENABLED:
|
||||
if not headphones.CFG.PUSHALOT_ENABLED:
|
||||
return
|
||||
|
||||
pushalot_authorizationtoken = headphones.PUSHALOT_APIKEY
|
||||
pushalot_authorizationtoken = headphones.CFG.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.PUSHOVER_ENABLED
|
||||
self.keys = headphones.PUSHOVER_KEYS
|
||||
self.priority = headphones.PUSHOVER_PRIORITY
|
||||
self.enabled = headphones.CFG.PUSHOVER_ENABLED
|
||||
self.keys = headphones.CFG.PUSHOVER_KEYS
|
||||
self.priority = headphones.CFG.PUSHOVER_PRIORITY
|
||||
|
||||
if headphones.PUSHOVER_APITOKEN:
|
||||
self.application_token = headphones.PUSHOVER_APITOKEN
|
||||
if headphones.CFG.PUSHOVER_APITOKEN:
|
||||
self.application_token = headphones.CFG.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.PUSHOVER_ENABLED:
|
||||
if not headphones.CFG.PUSHOVER_ENABLED:
|
||||
return
|
||||
|
||||
http_handler = HTTPSConnection("api.pushover.net")
|
||||
|
||||
data = {'token': self.application_token,
|
||||
'user': headphones.PUSHOVER_KEYS,
|
||||
'user': headphones.CFG.PUSHOVER_KEYS,
|
||||
'title': event,
|
||||
'message': message.encode("utf-8"),
|
||||
'priority': headphones.PUSHOVER_PRIORITY }
|
||||
'priority': headphones.CFG.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.TWITTER_ONSNATCH:
|
||||
if headphones.CFG.TWITTER_ONSNATCH:
|
||||
self._notifyTwitter(common.notifyStrings[common.NOTIFY_SNATCH]+': '+title+' at '+helpers.now())
|
||||
|
||||
def notify_download(self, title):
|
||||
if headphones.TWITTER_ENABLED:
|
||||
if headphones.CFG.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.TWITTER_USERNAME = request_token['oauth_token']
|
||||
headphones.TWITTER_PASSWORD = request_token['oauth_token_secret']
|
||||
headphones.CFG.TWITTER_USERNAME = request_token['oauth_token']
|
||||
headphones.CFG.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.TWITTER_USERNAME
|
||||
request_token['oauth_token_secret'] = headphones.TWITTER_PASSWORD
|
||||
request_token['oauth_token'] = headphones.CFG.TWITTER_USERNAME
|
||||
request_token['oauth_token_secret'] = headphones.CFG.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.TWITTER_USERNAME = access_token['oauth_token']
|
||||
headphones.TWITTER_PASSWORD = access_token['oauth_token_secret']
|
||||
headphones.CFG.TWITTER_USERNAME = access_token['oauth_token']
|
||||
headphones.CFG.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.TWITTER_USERNAME
|
||||
access_token_secret=headphones.TWITTER_PASSWORD
|
||||
access_token_key=headphones.CFG.TWITTER_USERNAME
|
||||
access_token_secret=headphones.CFG.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.TWITTER_PREFIX
|
||||
prefix = headphones.CFG.TWITTER_PREFIX
|
||||
|
||||
if not headphones.TWITTER_ENABLED and not force:
|
||||
if not headphones.CFG.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.BOXCAR_TOKEN,
|
||||
'user_credentials': headphones.CFG.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.SUBSONIC_HOST
|
||||
self.username = headphones.SUBSONIC_USERNAME
|
||||
self.password = headphones.SUBSONIC_PASSWORD
|
||||
self.host = headphones.CFG.SUBSONIC_HOST
|
||||
self.username = headphones.CFG.SUBSONIC_USERNAME
|
||||
self.password = headphones.CFG.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.NZBGET_HOST == None:
|
||||
if headphones.CFG.NZBGET_HOST == None:
|
||||
logger.error(u"No NZBget host found in configuration. Please configure it.")
|
||||
return False
|
||||
|
||||
if headphones.NZBGET_HOST.startswith('https://'):
|
||||
if headphones.CFG.NZBGET_HOST.startswith('https://'):
|
||||
nzbgetXMLrpc = 'https://' + nzbgetXMLrpc
|
||||
headphones.NZBGET_HOST.replace('https://','',1)
|
||||
headphones.CFG.NZBGET_HOST.replace('https://','',1)
|
||||
else:
|
||||
nzbgetXMLrpc = 'http://' + nzbgetXMLrpc
|
||||
headphones.NZBGET_HOST.replace('http://','',1)
|
||||
headphones.CFG.NZBGET_HOST.replace('http://','',1)
|
||||
|
||||
|
||||
url = nzbgetXMLrpc % {"host": headphones.NZBGET_HOST, "username": headphones.NZBGET_USERNAME, "password": headphones.NZBGET_PASSWORD}
|
||||
url = nzbgetXMLrpc % {"host": headphones.CFG.NZBGET_HOST, "username": headphones.CFG.NZBGET_USERNAME, "password": headphones.CFG.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.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.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.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, addToTop, nzbcontent64)
|
||||
elif nzbget_version == 12:
|
||||
if nzbcontent64 is not None:
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.NZBGET_CATEGORY, headphones.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbcontent64, False, dupekey, dupescore, "score")
|
||||
else:
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.NZBGET_CATEGORY, headphones.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.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.NZBGET_CATEGORY, headphones.NZBGET_PRIORITY, False, False, dupekey, dupescore,
|
||||
headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False, False, dupekey, dupescore,
|
||||
"score") > 0 else False
|
||||
else:
|
||||
if nzbcontent64 is not None:
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.NZBGET_CATEGORY, headphones.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.append(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzbcontent64)
|
||||
else:
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.NZBGET_CATEGORY, headphones.NZBGET_PRIORITY, False,
|
||||
nzbget_result = nzbGetRPC.appendurl(nzb.name + ".nzb", headphones.CFG.NZBGET_CATEGORY, headphones.CFG.NZBGET_PRIORITY, False,
|
||||
nzb.url)
|
||||
|
||||
if nzbget_result:
|
||||
|
||||
@@ -44,9 +44,9 @@ def checkFolder():
|
||||
if album['FolderName']:
|
||||
|
||||
if album['Kind'] == 'nzb':
|
||||
download_dir = headphones.DOWNLOAD_DIR
|
||||
download_dir = headphones.CFG.DOWNLOAD_DIR
|
||||
else:
|
||||
download_dir = headphones.DOWNLOAD_TORRENT_DIR
|
||||
download_dir = headphones.CFG.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.FREEZE_DB and not forced:
|
||||
if headphones.CFG.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.INCLUDE_EXTRAS:
|
||||
if headphones.CFG.INCLUDE_EXTRAS:
|
||||
newValueDict['IncludeExtras'] = 1
|
||||
newValueDict['Extras'] = headphones.EXTRAS
|
||||
newValueDict['Extras'] = headphones.CFG.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.ENCODER == 'xld' and headphones.MUSIC_ENCODER and downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list):
|
||||
if headphones.CFG.ENCODER == 'xld' and headphones.CFG.MUSIC_ENCODER and downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list):
|
||||
|
||||
import getXldProfile
|
||||
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.XLDPROFILE)
|
||||
(xldProfile, xldFormat, xldBitrate) = getXldProfile.getXldProfile(headphones.CFG.XLDPROFILE)
|
||||
if not xldFormat:
|
||||
logger.info(u'Details for xld profile "%s" not found, cannot split cue' % (xldProfile))
|
||||
else:
|
||||
if headphones.ENCODERFOLDER:
|
||||
xldencoder = os.path.join(headphones.ENCODERFOLDER, 'xld')
|
||||
if headphones.CFG.ENCODERFOLDER:
|
||||
xldencoder = os.path.join(headphones.CFG.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.KEEP_TORRENT_FILES and Kind=="torrent":
|
||||
if headphones.CFG.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.EMBED_ALBUM_ART or headphones.CLEANUP_FILES or \
|
||||
headphones.ADD_ALBUM_ART or headphones.CORRECT_METADATA or \
|
||||
headphones.EMBED_LYRICS or headphones.RENAME_FILES or \
|
||||
headphones.MOVE_FILES:
|
||||
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:
|
||||
|
||||
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.MUSIC_ENCODER:
|
||||
if headphones.CFG.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.EMBED_ALBUM_ART or headphones.ADD_ALBUM_ART:
|
||||
if headphones.CFG.EMBED_ALBUM_ART or headphones.CFG.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.EMBED_ALBUM_ART and artwork:
|
||||
if headphones.CFG.EMBED_ALBUM_ART and artwork:
|
||||
embedAlbumArt(artwork, downloaded_track_list)
|
||||
|
||||
if headphones.CLEANUP_FILES:
|
||||
if headphones.CFG.CLEANUP_FILES:
|
||||
cleanupFiles(albumpath)
|
||||
|
||||
if headphones.KEEP_NFO:
|
||||
if headphones.CFG.KEEP_NFO:
|
||||
renameNFO(albumpath)
|
||||
|
||||
if headphones.ADD_ALBUM_ART and artwork:
|
||||
if headphones.CFG.ADD_ALBUM_ART and artwork:
|
||||
addAlbumArt(artwork, albumpath, release)
|
||||
|
||||
if headphones.CORRECT_METADATA:
|
||||
if headphones.CFG.CORRECT_METADATA:
|
||||
correctMetadata(albumid, release, downloaded_track_list)
|
||||
|
||||
if headphones.EMBED_LYRICS:
|
||||
if headphones.CFG.EMBED_LYRICS:
|
||||
embedLyrics(downloaded_track_list)
|
||||
|
||||
if headphones.RENAME_FILES:
|
||||
if headphones.CFG.RENAME_FILES:
|
||||
renameFiles(albumpath, downloaded_track_list, release)
|
||||
|
||||
if headphones.MOVE_FILES and not headphones.DESTINATION_DIR:
|
||||
if headphones.CFG.MOVE_FILES and not headphones.CFG.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.MOVE_FILES and headphones.DESTINATION_DIR:
|
||||
elif headphones.CFG.MOVE_FILES and headphones.CFG.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.TORRENT_DOWNLOADER == 1 or headphones.TORRENT_DOWNLOADER == 2:
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 1 or headphones.CFG.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.TORRENT_DOWNLOADER == 1:
|
||||
if headphones.CFG.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.GROWL_ENABLED:
|
||||
if headphones.CFG.GROWL_ENABLED:
|
||||
logger.info(u"Growl request")
|
||||
growl = notifiers.GROWL()
|
||||
growl.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.PROWL_ENABLED:
|
||||
if headphones.CFG.PROWL_ENABLED:
|
||||
logger.info(u"Prowl request")
|
||||
prowl = notifiers.PROWL()
|
||||
prowl.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.XBMC_ENABLED:
|
||||
if headphones.CFG.XBMC_ENABLED:
|
||||
xbmc = notifiers.XBMC()
|
||||
if headphones.XBMC_UPDATE:
|
||||
if headphones.CFG.XBMC_UPDATE:
|
||||
xbmc.update()
|
||||
if headphones.XBMC_NOTIFY:
|
||||
if headphones.CFG.XBMC_NOTIFY:
|
||||
xbmc.notify(release['ArtistName'],
|
||||
release['AlbumTitle'],
|
||||
album_art_path)
|
||||
|
||||
if headphones.LMS_ENABLED:
|
||||
if headphones.CFG.LMS_ENABLED:
|
||||
lms = notifiers.LMS()
|
||||
lms.update()
|
||||
|
||||
if headphones.PLEX_ENABLED:
|
||||
if headphones.CFG.PLEX_ENABLED:
|
||||
plex = notifiers.Plex()
|
||||
if headphones.PLEX_UPDATE:
|
||||
if headphones.CFG.PLEX_UPDATE:
|
||||
plex.update()
|
||||
if headphones.PLEX_NOTIFY:
|
||||
if headphones.CFG.PLEX_NOTIFY:
|
||||
plex.notify(release['ArtistName'],
|
||||
release['AlbumTitle'],
|
||||
album_art_path)
|
||||
|
||||
if headphones.NMA_ENABLED:
|
||||
if headphones.CFG.NMA_ENABLED:
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(release['ArtistName'], release['AlbumTitle'])
|
||||
|
||||
if headphones.PUSHALOT_ENABLED:
|
||||
if headphones.CFG.PUSHALOT_ENABLED:
|
||||
logger.info(u"Pushalot request")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(pushmessage, statusmessage)
|
||||
|
||||
if headphones.SYNOINDEX_ENABLED:
|
||||
if headphones.CFG.SYNOINDEX_ENABLED:
|
||||
syno = notifiers.Synoindex()
|
||||
for albumpath in albumpaths:
|
||||
syno.notify(albumpath)
|
||||
|
||||
if headphones.PUSHOVER_ENABLED:
|
||||
if headphones.CFG.PUSHOVER_ENABLED:
|
||||
logger.info(u"Pushover request")
|
||||
pushover = notifiers.PUSHOVER()
|
||||
pushover.notify(pushmessage, "Headphones")
|
||||
|
||||
if headphones.PUSHBULLET_ENABLED:
|
||||
if headphones.CFG.PUSHBULLET_ENABLED:
|
||||
logger.info(u"PushBullet request")
|
||||
pushbullet = notifiers.PUSHBULLET()
|
||||
pushbullet.notify(pushmessage, "Download and Postprocessing completed")
|
||||
|
||||
if headphones.TWITTER_ENABLED:
|
||||
if headphones.CFG.TWITTER_ENABLED:
|
||||
logger.info(u"Sending Twitter notification")
|
||||
twitter = notifiers.TwitterNotifier()
|
||||
twitter.notify_download(pushmessage)
|
||||
|
||||
if headphones.OSX_NOTIFY_ENABLED:
|
||||
if headphones.CFG.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.BOXCAR_ENABLED:
|
||||
if headphones.CFG.BOXCAR_ENABLED:
|
||||
logger.info(u"Sending Boxcar2 notification")
|
||||
boxcar = notifiers.BOXCAR()
|
||||
boxcar.notify('Headphones processed: ' + pushmessage,
|
||||
statusmessage, release['AlbumID'])
|
||||
|
||||
if headphones.SUBSONIC_ENABLED:
|
||||
if headphones.CFG.SUBSONIC_ENABLED:
|
||||
logger.info(u"Sending Subsonic update")
|
||||
subsonic = notifiers.SubSonicNotifier()
|
||||
subsonic.notify(albumpaths)
|
||||
|
||||
if headphones.MPC_ENABLED:
|
||||
if headphones.CFG.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.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
||||
album_art_name = helpers.replace_all(headphones.CFG.ALBUM_ART_FORMAT.strip(), values) + ".jpg"
|
||||
|
||||
album_art_name = helpers.replace_illegal_chars(album_art_name).encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
if headphones.FILE_UNDERSCORES:
|
||||
if headphones.CFG.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.FILE_UNDERSCORES:
|
||||
if headphones.CFG.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.FOLDER_FORMAT.strip(), values, normalize=True)
|
||||
folder = helpers.replace_all(headphones.CFG.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.DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.LOSSLESS_DESTINATION_DIR, folder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
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')
|
||||
|
||||
# If they set a destination dir for lossless media, only create the lossy folder if there is lossy media
|
||||
if headphones.LOSSLESS_DESTINATION_DIR:
|
||||
if headphones.CFG.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.FOLDER_FORMAT.strip().split('/')[-1]
|
||||
last_folder = headphones.CFG.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.REPLACE_EXISTING_FOLDERS:
|
||||
if headphones.CFG.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.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
if not headphones.CFG.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.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.CFG.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.REPLACE_EXISTING_FOLDERS:
|
||||
if headphones.CFG.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.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
if not headphones.CFG.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.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.CFG.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.LOSSLESS_DESTINATION_DIR)
|
||||
temp_fs.append(headphones.CFG.LOSSLESS_DESTINATION_DIR)
|
||||
|
||||
if make_lossy_folder:
|
||||
temp_fs.append(headphones.DESTINATION_DIR)
|
||||
temp_fs.append(headphones.CFG.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.FOLDER_PERMISSIONS, 8))
|
||||
os.chmod(os.path.normpath(temp_f).encode(headphones.SYS_ENCODING, 'replace'), int(headphones.CFG.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.FILE_FORMAT.strip(), values).replace('/','_') + ext
|
||||
new_file_name = helpers.replace_all(headphones.CFG.FILE_FORMAT.strip(), values).replace('/','_') + ext
|
||||
|
||||
|
||||
new_file_name = helpers.replace_illegal_chars(new_file_name).encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
if headphones.FILE_UNDERSCORES:
|
||||
if headphones.CFG.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.FILE_PERMISSIONS, 8))
|
||||
os.chmod(full_path, int(headphones.CFG.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.DOWNLOAD_DIR and not dir:
|
||||
download_dirs.append(headphones.DOWNLOAD_DIR.encode(headphones.SYS_ENCODING, 'replace'))
|
||||
if headphones.DOWNLOAD_TORRENT_DIR and not dir:
|
||||
download_dirs.append(headphones.DOWNLOAD_TORRENT_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 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))
|
||||
@@ -1134,7 +1134,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.KEEP_TORRENT_FILES and snatched['Kind'] == 'torrent' and snatched['Status'] == 'Processed':
|
||||
if headphones.CFG.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.VERIFY_SSL_CERT
|
||||
kwargs["verify"] = headphones.CFG.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.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.SAB_USERNAME
|
||||
if headphones.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.SAB_PASSWORD
|
||||
if headphones.SAB_APIKEY:
|
||||
params['apikey'] = headphones.SAB_APIKEY
|
||||
if headphones.SAB_CATEGORY:
|
||||
params['cat'] = headphones.SAB_CATEGORY
|
||||
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 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.SAB_HOST.startswith('http'):
|
||||
headphones.SAB_HOST = 'http://' + headphones.SAB_HOST
|
||||
if not headphones.CFG.SAB_HOST.startswith('http'):
|
||||
headphones.CFG.SAB_HOST = 'http://' + headphones.CFG.SAB_HOST
|
||||
|
||||
if headphones.SAB_HOST.endswith('/'):
|
||||
headphones.SAB_HOST = headphones.SAB_HOST[0:len(headphones.SAB_HOST)-1]
|
||||
if headphones.CFG.SAB_HOST.endswith('/'):
|
||||
headphones.CFG.SAB_HOST = headphones.CFG.SAB_HOST[0:len(headphones.CFG.SAB_HOST)-1]
|
||||
|
||||
url = headphones.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
url = headphones.CFG.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.SAB_HOST)
|
||||
logger.error(u"Invalid SAB host, check your config. Current host: %s" % headphones.CFG.SAB_HOST)
|
||||
return False
|
||||
|
||||
except Exception, e:
|
||||
@@ -133,20 +133,20 @@ def checkConfig():
|
||||
'section' : 'misc'
|
||||
}
|
||||
|
||||
if headphones.SAB_USERNAME:
|
||||
params['ma_username'] = headphones.SAB_USERNAME
|
||||
if headphones.SAB_PASSWORD:
|
||||
params['ma_password'] = headphones.SAB_PASSWORD
|
||||
if headphones.SAB_APIKEY:
|
||||
params['apikey'] = headphones.SAB_APIKEY
|
||||
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 not headphones.SAB_HOST.startswith('http'):
|
||||
headphones.SAB_HOST = 'http://' + headphones.SAB_HOST
|
||||
if not headphones.CFG.SAB_HOST.startswith('http'):
|
||||
headphones.CFG.SAB_HOST = 'http://' + headphones.CFG.SAB_HOST
|
||||
|
||||
if headphones.SAB_HOST.endswith('/'):
|
||||
headphones.SAB_HOST = headphones.SAB_HOST[0:len(headphones.SAB_HOST)-1]
|
||||
if headphones.CFG.SAB_HOST.endswith('/'):
|
||||
headphones.CFG.SAB_HOST = headphones.CFG.SAB_HOST[0:len(headphones.CFG.SAB_HOST)-1]
|
||||
|
||||
url = headphones.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
url = headphones.CFG.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
|
||||
try:
|
||||
f = urllib.urlopen(url).read()
|
||||
|
||||
@@ -89,15 +89,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.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.OMGWTFNZBS)
|
||||
NZB_DOWNLOADERS = (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST)
|
||||
TORRENT_PROVIDERS = (headphones.KAT or headphones.PIRATEBAY or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD)
|
||||
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)
|
||||
|
||||
results = []
|
||||
myDB = db.DBConnection()
|
||||
albumlength = myDB.select('SELECT sum(TrackDuration) from tracks WHERE AlbumID=?', [album['AlbumID']])[0][0]
|
||||
|
||||
if headphones.PREFER_TORRENTS == 0:
|
||||
if headphones.CFG.PREFER_TORRENTS == 0:
|
||||
|
||||
if NZB_PROVIDERS and NZB_DOWNLOADERS:
|
||||
results = searchNZB(album, new, losslessOnly, albumlength)
|
||||
@@ -105,7 +105,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.PREFER_TORRENTS == 1:
|
||||
elif headphones.CFG.PREFER_TORRENTS == 1:
|
||||
|
||||
if TORRENT_PROVIDERS:
|
||||
results = searchTorrent(album, new, losslessOnly, albumlength)
|
||||
@@ -160,23 +160,23 @@ def more_filtering(results, album, albumlength, new):
|
||||
myDB = db.DBConnection()
|
||||
|
||||
# Lossless - ignore results if target size outside bitrate range
|
||||
if headphones.PREFERRED_QUALITY == 3 and albumlength and (headphones.LOSSLESS_BITRATE_FROM or headphones.LOSSLESS_BITRATE_TO):
|
||||
if headphones.LOSSLESS_BITRATE_FROM:
|
||||
low_size_limit = albumlength/1000 * int(headphones.LOSSLESS_BITRATE_FROM) * 128
|
||||
if headphones.LOSSLESS_BITRATE_TO:
|
||||
high_size_limit = albumlength/1000 * int(headphones.LOSSLESS_BITRATE_TO) * 128
|
||||
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
|
||||
|
||||
# Preferred Bitrate - ignore results if target size outside % buffer
|
||||
elif headphones.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE:
|
||||
logger.debug('Target bitrate: %s kbps' % headphones.PREFERRED_BITRATE)
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE:
|
||||
logger.debug('Target bitrate: %s kbps' % headphones.CFG.PREFERRED_BITRATE)
|
||||
if albumlength:
|
||||
targetsize = albumlength/1000 * int(headphones.PREFERRED_BITRATE) * 128
|
||||
targetsize = albumlength/1000 * int(headphones.CFG.PREFERRED_BITRATE) * 128
|
||||
logger.info('Target size: %s' % helpers.bytes_to_mb(targetsize))
|
||||
if headphones.PREFERRED_BITRATE_LOW_BUFFER:
|
||||
low_size_limit = targetsize - (targetsize * int(headphones.PREFERRED_BITRATE_LOW_BUFFER)/100)
|
||||
if headphones.PREFERRED_BITRATE_HIGH_BUFFER:
|
||||
high_size_limit = targetsize + (targetsize * int(headphones.PREFERRED_BITRATE_HIGH_BUFFER)/100)
|
||||
if headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
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:
|
||||
allow_lossless = True
|
||||
|
||||
newlist = []
|
||||
@@ -224,8 +224,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.PREFERRED_WORDS:
|
||||
preferred_words = helpers.split_string(headphones.PREFERRED_WORDS)
|
||||
if headphones.CFG.PREFERRED_WORDS:
|
||||
preferred_words = helpers.split_string(headphones.CFG.PREFERRED_WORDS)
|
||||
for result in resultlist:
|
||||
priority = 0
|
||||
if preferred_words:
|
||||
@@ -240,10 +240,10 @@ def sort_search_results(resultlist, album, new, albumlength):
|
||||
|
||||
resultlist = temp_list
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 2 and headphones.CFG.PREFERRED_BITRATE:
|
||||
|
||||
try:
|
||||
targetsize = albumlength/1000 * int(headphones.PREFERRED_BITRATE) * 128
|
||||
targetsize = albumlength/1000 * int(headphones.CFG.PREFERRED_BITRATE) * 128
|
||||
|
||||
if not targetsize:
|
||||
logger.info('No track information for %s - %s. Defaulting to highest quality' % (album['ArtistName'], album['AlbumTitle']))
|
||||
@@ -265,7 +265,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.PREFERRED_BITRATE_ALLOW_LOSSLESS:
|
||||
if not len(finallist) and len(flac_list) and headphones.CFG.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:
|
||||
@@ -323,7 +323,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.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE and headphones.PREFERRED_BITRATE_HIGH_BUFFER and headphones.PREFERRED_BITRATE_ALLOW_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:
|
||||
allow_lossless = True
|
||||
else:
|
||||
allow_lossless = False
|
||||
@@ -332,12 +332,12 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
resultlist = []
|
||||
|
||||
if headphones.HEADPHONES_INDEXER:
|
||||
if headphones.CFG.HEADPHONES_INDEXER:
|
||||
provider = "headphones"
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -354,14 +354,14 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
"t": "search",
|
||||
"cat": categories,
|
||||
"apikey": '964d601959918a578a670984bdee9357',
|
||||
"maxage": headphones.USENET_RETENTION,
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
data = request.request_feed(
|
||||
url="http://indexer.codeshy.com/api",
|
||||
params=params, headers=headers,
|
||||
auth=(headphones.HPUSER, headphones.HPPASS)
|
||||
auth=(headphones.CFG.HPUSER, headphones.CFG.HPPASS)
|
||||
)
|
||||
|
||||
# Process feed
|
||||
@@ -381,21 +381,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.NEWZNAB:
|
||||
if headphones.CFG.NEWZNAB:
|
||||
provider = "newznab"
|
||||
newznab_hosts = []
|
||||
|
||||
if headphones.NEWZNAB_HOST and headphones.NEWZNAB_ENABLED:
|
||||
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))
|
||||
|
||||
newznab_hosts.append((headphones.NEWZNAB_HOST, headphones.NEWZNAB_APIKEY, headphones.NEWZNAB_ENABLED))
|
||||
|
||||
for newznab_host in headphones.EXTRA_NEWZNABS:
|
||||
for newznab_host in headphones.CFG.get_extra_newznabs():
|
||||
if newznab_host[2] == '1' or newznab_host[2] == 1:
|
||||
newznab_hosts.append(newznab_host)
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -427,7 +426,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
"t": "search",
|
||||
"apikey": newznab_host[1],
|
||||
"cat": categories,
|
||||
"maxage": headphones.USENET_RETENTION,
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
@@ -455,11 +454,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.NZBSORG:
|
||||
if headphones.CFG.NZBSORG:
|
||||
provider = "nzbsorg"
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "3040"
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "3040,3010"
|
||||
else:
|
||||
categories = "3010"
|
||||
@@ -474,9 +473,9 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
headers = { 'User-Agent': USER_AGENT }
|
||||
params = {
|
||||
"t": "search",
|
||||
"apikey": headphones.NZBSORG_HASH,
|
||||
"apikey": headphones.CFG.NZBSORG_HASH,
|
||||
"cat": categories,
|
||||
"maxage": headphones.USENET_RETENTION,
|
||||
"maxage": headphones.CFG.USENET_RETENTION,
|
||||
"q": term
|
||||
}
|
||||
|
||||
@@ -501,12 +500,12 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.exception("Unhandled exception while parsing feed")
|
||||
|
||||
if headphones.OMGWTFNZBS:
|
||||
if headphones.CFG.OMGWTFNZBS:
|
||||
provider = "omgwtfnzbs"
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "22"
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "22,7"
|
||||
else:
|
||||
categories = "7"
|
||||
@@ -520,10 +519,10 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
headers = { 'User-Agent': USER_AGENT }
|
||||
params = {
|
||||
"user": headphones.OMGWTFNZBS_UID,
|
||||
"api": headphones.OMGWTFNZBS_APIKEY,
|
||||
"user": headphones.CFG.OMGWTFNZBS_UID,
|
||||
"api": headphones.CFG.OMGWTFNZBS_APIKEY,
|
||||
"catid": categories,
|
||||
"retention": headphones.USENET_RETENTION,
|
||||
"retention": headphones.CFG.USENET_RETENTION,
|
||||
"search": term
|
||||
}
|
||||
|
||||
@@ -573,7 +572,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if kind == 'nzb':
|
||||
folder_name = helpers.sab_sanitize_foldername(bestqual[0])
|
||||
|
||||
if headphones.NZB_DOWNLOADER == 1:
|
||||
if headphones.CFG.NZB_DOWNLOADER == 1:
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
@@ -581,7 +580,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if not nzbget.sendNZB(nzb):
|
||||
return
|
||||
|
||||
elif headphones.NZB_DOWNLOADER == 0:
|
||||
elif headphones.CFG.NZB_DOWNLOADER == 0:
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
@@ -599,7 +598,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
|
||||
else:
|
||||
nzb_name = folder_name + '.nzb'
|
||||
download_path = os.path.join(headphones.BLACKHOLE_DIR, nzb_name)
|
||||
download_path = os.path.join(headphones.CFG.BLACKHOLE_DIR, nzb_name)
|
||||
|
||||
try:
|
||||
prev = os.umask(headphones.UMASK)
|
||||
@@ -616,14 +615,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.TORRENT_DOWNLOADER == 0:
|
||||
if headphones.CFG.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.TORRENTBLACKHOLE_DIR, torrent_name)
|
||||
download_path = os.path.join(headphones.CFG.TORRENTBLACKHOLE_DIR, torrent_name)
|
||||
|
||||
if bestqual[2].startswith("magnet:"):
|
||||
if headphones.OPEN_MAGNET_LINKS:
|
||||
if headphones.CFG.OPEN_MAGNET_LINKS:
|
||||
try:
|
||||
if headphones.SYS_PLATFORM == 'win32':
|
||||
os.startfile(bestqual[2])
|
||||
@@ -645,7 +644,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
try:
|
||||
|
||||
if bestqual[3] == 'rutracker.org':
|
||||
download_path = rutracker.get_torrent(bestqual[2], headphones.TORRENTBLACKHOLE_DIR)
|
||||
download_path = rutracker.get_torrent(bestqual[2], headphones.CFG.TORRENTBLACKHOLE_DIR)
|
||||
if not download_path:
|
||||
return
|
||||
else:
|
||||
@@ -654,7 +653,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
fp.write(data)
|
||||
|
||||
try:
|
||||
os.chmod(download_path, int(headphones.FILE_PERMISSIONS, 8))
|
||||
os.chmod(download_path, int(headphones.CFG.FILE_PERMISSIONS, 8))
|
||||
except:
|
||||
logger.error("Could not change permissions for file: %s", download_path)
|
||||
|
||||
@@ -669,7 +668,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
logger.error('Couldn\'t get name from Torrent file: %s. Defaulting to torrent title' % e)
|
||||
folder_name = bestqual[0]
|
||||
|
||||
elif headphones.TORRENT_DOWNLOADER == 1:
|
||||
elif headphones.CFG.TORRENT_DOWNLOADER == 1:
|
||||
logger.info("Sending torrent to Transmission")
|
||||
|
||||
# rutracker needs cookies to be set, pass the .torrent file instead of url
|
||||
@@ -703,7 +702,7 @@ def send_to_downloader(data, bestqual, album):
|
||||
if seed_ratio != None:
|
||||
transmission.setSeedRatio(torrentid, seed_ratio)
|
||||
|
||||
else:# if headphones.TORRENT_DOWNLOADER == 2:
|
||||
else:# if headphones.CFG.TORRENT_DOWNLOADER == 2:
|
||||
logger.info("Sending torrent to uTorrent")
|
||||
|
||||
# rutracker needs cookies to be set, pass the .torrent file instead of url
|
||||
@@ -753,39 +752,39 @@ def send_to_downloader(data, bestqual, album):
|
||||
provider = provider.split("//")[1]
|
||||
name = folder_name if folder_name else None
|
||||
|
||||
if headphones.GROWL_ENABLED and headphones.GROWL_ONSNATCH:
|
||||
if headphones.CFG.GROWL_ENABLED and headphones.CFG.GROWL_ONSNATCH:
|
||||
logger.info(u"Sending Growl notification")
|
||||
growl = notifiers.GROWL()
|
||||
growl.notify(name,"Download started")
|
||||
if headphones.PROWL_ENABLED and headphones.PROWL_ONSNATCH:
|
||||
if headphones.CFG.PROWL_ENABLED and headphones.CFG.PROWL_ONSNATCH:
|
||||
logger.info(u"Sending Prowl notification")
|
||||
prowl = notifiers.PROWL()
|
||||
prowl.notify(name,"Download started")
|
||||
if headphones.PUSHOVER_ENABLED and headphones.PUSHOVER_ONSNATCH:
|
||||
if headphones.CFG.PUSHOVER_ENABLED and headphones.CFG.PUSHOVER_ONSNATCH:
|
||||
logger.info(u"Sending Pushover notification")
|
||||
prowl = notifiers.PUSHOVER()
|
||||
prowl.notify(name,"Download started")
|
||||
if headphones.PUSHBULLET_ENABLED and headphones.PUSHBULLET_ONSNATCH:
|
||||
if headphones.CFG.PUSHBULLET_ENABLED and headphones.CFG.PUSHBULLET_ONSNATCH:
|
||||
logger.info(u"Sending PushBullet notification")
|
||||
pushbullet = notifiers.PUSHBULLET()
|
||||
pushbullet.notify(name + " has been snatched!", "Download started")
|
||||
if headphones.TWITTER_ENABLED and headphones.TWITTER_ONSNATCH:
|
||||
if headphones.CFG.TWITTER_ENABLED and headphones.CFG.TWITTER_ONSNATCH:
|
||||
logger.info(u"Sending Twitter notification")
|
||||
twitter = notifiers.TwitterNotifier()
|
||||
twitter.notify_snatch(name)
|
||||
if headphones.NMA_ENABLED and headphones.NMA_ONSNATCH:
|
||||
if headphones.CFG.NMA_ENABLED and headphones.CFG.NMA_ONSNATCH:
|
||||
logger.info(u"Sending NMA notification")
|
||||
nma = notifiers.NMA()
|
||||
nma.notify(snatched=name)
|
||||
if headphones.PUSHALOT_ENABLED and headphones.PUSHALOT_ONSNATCH:
|
||||
if headphones.CFG.PUSHALOT_ENABLED and headphones.CFG.PUSHALOT_ONSNATCH:
|
||||
logger.info(u"Sending Pushalot notification")
|
||||
pushalot = notifiers.PUSHALOT()
|
||||
pushalot.notify(name,"Download started")
|
||||
if headphones.OSX_NOTIFY_ENABLED and headphones.OSX_NOTIFY_ONSNATCH:
|
||||
if headphones.CFG.OSX_NOTIFY_ENABLED and headphones.CFG.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.BOXCAR_ENABLED and headphones.BOXCAR_ONSNATCH:
|
||||
if headphones.CFG.BOXCAR_ENABLED and headphones.CFG.BOXCAR_ONSNATCH:
|
||||
logger.info(u"Sending Boxcar2 notification")
|
||||
b2msg = 'From ' + provider + '<br></br>' + name
|
||||
boxcar = notifiers.BOXCAR()
|
||||
@@ -815,18 +814,18 @@ def verifyresult(title, artistterm, term, lossless):
|
||||
return False
|
||||
|
||||
# Filter out FLAC if we're not specifically looking for it
|
||||
if headphones.PREFERRED_QUALITY == (0 or '0') and 'flac' in title.lower() and not lossless:
|
||||
if headphones.CFG.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.IGNORED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.IGNORED_WORDS):
|
||||
if headphones.CFG.IGNORED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CFG.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.REQUIRED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.REQUIRED_WORDS):
|
||||
if headphones.CFG.REQUIRED_WORDS:
|
||||
for each_word in helpers.split_string(headphones.CFG.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):
|
||||
@@ -861,8 +860,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
# rutracker login
|
||||
|
||||
if headphones.RUTRACKER and album:
|
||||
rulogin = rutracker.login(headphones.RUTRACKER_USER, headphones.RUTRACKER_PASSWORD)
|
||||
if headphones.CFG.RUTRACKER and album:
|
||||
rulogin = rutracker.login(headphones.CFG.RUTRACKER_USER, headphones.CFG.RUTRACKER_PASSWORD)
|
||||
if not rulogin:
|
||||
logger.info(u'Could not login to rutracker, search results will exclude this provider')
|
||||
|
||||
@@ -909,7 +908,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.PREFERRED_QUALITY == 2 and headphones.PREFERRED_BITRATE and headphones.PREFERRED_BITRATE_HIGH_BUFFER and headphones.PREFERRED_BITRATE_ALLOW_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:
|
||||
allow_lossless = True
|
||||
else:
|
||||
allow_lossless = False
|
||||
@@ -918,7 +917,7 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
|
||||
resultlist = []
|
||||
pre_sorted_results = False
|
||||
minimumseeders = int(headphones.NUMBEROFSEEDERS) - 1
|
||||
minimumseeders = int(headphones.CFG.NUMBEROFSEEDERS) - 1
|
||||
|
||||
def set_proxy(proxy_url):
|
||||
if not proxy_url.startswith('http'):
|
||||
@@ -929,13 +928,13 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
return proxy_url
|
||||
|
||||
|
||||
if headphones.KAT:
|
||||
if headphones.CFG.KAT:
|
||||
provider = "Kick Ass Torrents"
|
||||
ka_term = term.replace("!", "")
|
||||
|
||||
# Use proxy if specified
|
||||
if headphones.KAT_PROXY_URL:
|
||||
providerurl = url_fix(set_proxy(headphones.KAT_PROXY_URL))
|
||||
if headphones.CFG.KAT_PROXY_URL:
|
||||
providerurl = url_fix(set_proxy(headphones.CFG.KAT_PROXY_URL))
|
||||
else:
|
||||
providerurl = url_fix("https://kickass.to")
|
||||
|
||||
@@ -943,11 +942,11 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
providerurl = providerurl + "/usearch/" + ka_term
|
||||
|
||||
# Pick category for torrents
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "7" # Music
|
||||
format = "2" # FLAC
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "7" # Music
|
||||
format = "10" # MP3 and FLAC
|
||||
maxsize = 10000000000
|
||||
@@ -993,16 +992,16 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
except Exception as e:
|
||||
logger.exception("Unhandled exception in the KAT parser")
|
||||
|
||||
if headphones.WAFFLES:
|
||||
if headphones.CFG.WAFFLES:
|
||||
provider = "Waffles.fm"
|
||||
providerurl = url_fix("https://www.waffles.fm/browse.php")
|
||||
|
||||
bitrate = None
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = "FLAC"
|
||||
bitrate = "(Lossless)"
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
format = "FLAC OR MP3"
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1027,8 +1026,8 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
logger.info('Parsing results from Waffles')
|
||||
|
||||
params = {
|
||||
"uid": headphones.WAFFLES_UID,
|
||||
"passkey": headphones.WAFFLES_PASSKEY,
|
||||
"uid": headphones.CFG.WAFFLES_UID,
|
||||
"passkey": headphones.CFG.WAFFLES_PASSKEY,
|
||||
"rss": "1",
|
||||
"c0": "1",
|
||||
"s": "seeders", # sort by
|
||||
@@ -1059,7 +1058,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.RUTRACKER and rulogin:
|
||||
if headphones.CFG.RUTRACKER and rulogin:
|
||||
|
||||
provider = "rutracker.org"
|
||||
|
||||
@@ -1068,10 +1067,10 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
logger.info(u'Release date not specified, ignoring for rutracker.org')
|
||||
else:
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
format = 'lossless'
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
format = 'lossless+mp3'
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1100,19 +1099,19 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
else:
|
||||
logger.info(u"No valid results found from %s" % (provider))
|
||||
|
||||
if headphones.WHATCD:
|
||||
if headphones.CFG.WHATCD:
|
||||
provider = "What.cd"
|
||||
providerurl = "http://what.cd/"
|
||||
|
||||
bitrate = None
|
||||
bitrate_string = bitrate
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly: # Lossless Only mode
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly: # Lossless Only mode
|
||||
search_formats = [gazelleformat.FLAC]
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 2: # Preferred quality mode
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 2: # Preferred quality mode
|
||||
search_formats = [None] # should return all
|
||||
bitrate = headphones.PREFERRED_BITRATE
|
||||
bitrate = headphones.CFG.PREFERRED_BITRATE
|
||||
if bitrate:
|
||||
for encoding_string in gazelleencoding.ALL_ENCODINGS:
|
||||
if re.search(bitrate, encoding_string, flags=re.I):
|
||||
@@ -1120,7 +1119,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.PREFERRED_QUALITY == 1 or allow_lossless: # Highest quality including lossless
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless: # Highest quality including lossless
|
||||
search_formats = [gazelleformat.FLAC, gazelleformat.MP3]
|
||||
maxsize = 10000000000
|
||||
else: # Highest quality excluding lossless
|
||||
@@ -1130,7 +1129,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.WHATCD_USERNAME, headphones.WHATCD_PASSWORD)
|
||||
gazelle = gazelleapi.GazelleAPI(headphones.CFG.WHATCD_USERNAME, headphones.CFG.WHATCD_PASSWORD)
|
||||
gazelle._login()
|
||||
except Exception as e:
|
||||
gazelle = None
|
||||
@@ -1180,13 +1179,13 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None):
|
||||
'torrent'))
|
||||
|
||||
# Pirate Bay
|
||||
if headphones.PIRATEBAY:
|
||||
if headphones.CFG.PIRATEBAY:
|
||||
provider = "The Pirate Bay"
|
||||
tpb_term = term.replace("!", "")
|
||||
|
||||
# Use proxy if specified
|
||||
if headphones.PIRATEBAY_PROXY_URL:
|
||||
providerurl = url_fix(set_proxy(headphones.PIRATEBAY_PROXY_URL))
|
||||
if headphones.CFG.PIRATEBAY_PROXY_URL:
|
||||
providerurl = url_fix(set_proxy(headphones.CFG.PIRATEBAY_PROXY_URL))
|
||||
else:
|
||||
providerurl = url_fix("https://thepiratebay.se")
|
||||
|
||||
@@ -1194,10 +1193,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.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
category = '104' # FLAC
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
category = '100' # General audio category
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
@@ -1224,11 +1223,11 @@ 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.TORRENT_DOWNLOADER == 0:
|
||||
if headphones.CFG.TORRENT_DOWNLOADER == 0:
|
||||
try:
|
||||
url = item.find("a", {"title":"Download this torrent"})['href']
|
||||
except TypeError:
|
||||
if headphones.OPEN_MAGNET_LINKS:
|
||||
if headphones.CFG.OPEN_MAGNET_LINKS:
|
||||
url = item.findAll("a")[3]['href']
|
||||
else:
|
||||
logger.info('"%s" only has a magnet link, skipping' % title)
|
||||
@@ -1250,15 +1249,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.MININOVA:
|
||||
if headphones.CFG.MININOVA:
|
||||
provider = "Mininova"
|
||||
providerurl = url_fix("http://www.mininova.org/rss/" + term + "/5")
|
||||
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
if headphones.CFG.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
categories = "7" #music
|
||||
format = "2" #flac
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
elif headphones.CFG.PREFERRED_QUALITY == 1 or allow_lossless:
|
||||
categories = "7" #music
|
||||
format = "10" #mp3+flac
|
||||
maxsize = 10000000000
|
||||
@@ -1323,7 +1322,7 @@ def preprocess(resultlist):
|
||||
|
||||
if result[4] == 'torrent':
|
||||
#Get out of here if we're using Transmission
|
||||
if headphones.TORRENT_DOWNLOADER == 1: ## if not a magnet link still need the .torrent to generate hash... uTorrent support labeling
|
||||
if headphones.CFG.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':
|
||||
@@ -1348,7 +1347,7 @@ def preprocess(resultlist):
|
||||
headers = {'User-Agent': USER_AGENT}
|
||||
|
||||
if result[3] == 'headphones':
|
||||
return request.request_content(url=result[2], headers=headers, auth=(headphones.HPUSER, headphones.HPPASS)), result
|
||||
return request.request_content(url=result[2], headers=headers, auth=(headphones.CFG.HPUSER, headphones.CFG.HPPASS)), result
|
||||
else:
|
||||
return request.request_content(url=result[2], headers=headers), result
|
||||
|
||||
@@ -1369,17 +1368,17 @@ def CalculateTorrentHash(link, data):
|
||||
def getSeedRatio(provider):
|
||||
seed_ratio = ''
|
||||
if provider == 'rutracker.org':
|
||||
seed_ratio = headphones.RUTRACKER_RATIO
|
||||
seed_ratio = headphones.CFG.RUTRACKER_RATIO
|
||||
elif provider == 'Kick Ass Torrents':
|
||||
seed_ratio = headphones.KAT_RATIO
|
||||
seed_ratio = headphones.CFG.KAT_RATIO
|
||||
elif provider == 'What.cd':
|
||||
seed_ratio = headphones.WHATCD_RATIO
|
||||
seed_ratio = headphones.CFG.WHATCD_RATIO
|
||||
elif provider == 'The Pirate Bay':
|
||||
seed_ratio = headphones.PIRATEBAY_RATIO
|
||||
seed_ratio = headphones.CFG.PIRATEBAY_RATIO
|
||||
elif provider == 'Waffles.fm':
|
||||
seed_ratio = headphones.WAFFLES_RATIO
|
||||
seed_ratio = headphones.CFG.WAFFLES_RATIO
|
||||
elif provider == 'Mininova':
|
||||
seed_ratio = headphones.MININOVA_RATIO
|
||||
seed_ratio = headphones.CFG.MININOVA_RATIO
|
||||
if seed_ratio != '':
|
||||
try:
|
||||
seed_ratio_float = float(seed_ratio)
|
||||
@@ -1388,4 +1387,4 @@ def getSeedRatio(provider):
|
||||
logger.warn('Could not get Seed Ratio for %s' % provider)
|
||||
return seed_ratio_float
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@@ -294,7 +294,7 @@ class Rutracker():
|
||||
os.umask(prev)
|
||||
|
||||
# Add file to utorrent
|
||||
if headphones.TORRENT_DOWNLOADER == 2:
|
||||
if headphones.CFG.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.UTORRENT_HOST
|
||||
host = headphones.CFG.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.UTORRENT_USERNAME
|
||||
password = headphones.UTORRENT_PASSWORD
|
||||
username = headphones.CFG.UTORRENT_USERNAME
|
||||
password = headphones.CFG.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.TORRENT_DOWNLOADER == 1:
|
||||
if headphones.CFG.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.DOWNLOAD_TORRENT_DIR}
|
||||
arguments = {'metainfo': metainfo, 'download-dir':headphones.CFG.DOWNLOAD_TORRENT_DIR}
|
||||
else:
|
||||
arguments = {'filename': link, 'download-dir': headphones.DOWNLOAD_TORRENT_DIR}
|
||||
arguments = {'filename': link, 'download-dir': headphones.CFG.DOWNLOAD_TORRENT_DIR}
|
||||
|
||||
response = torrentAction(method,arguments)
|
||||
|
||||
@@ -122,9 +122,9 @@ def removeTorrent(torrentid, remove_data = False):
|
||||
|
||||
def torrentAction(method, arguments):
|
||||
|
||||
host = headphones.TRANSMISSION_HOST
|
||||
username = headphones.TRANSMISSION_USERNAME
|
||||
password = headphones.TRANSMISSION_PASSWORD
|
||||
host = headphones.CFG.TRANSMISSION_HOST
|
||||
username = headphones.CFG.TRANSMISSION_USERNAME
|
||||
password = headphones.CFG.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.UTORRENT_HOST
|
||||
host = headphones.CFG.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.UTORRENT_USERNAME
|
||||
self.password = headphones.UTORRENT_PASSWORD
|
||||
self.username = headphones.CFG.UTORRENT_USERNAME
|
||||
self.password = headphones.CFG.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.UTORRENT_LABEL
|
||||
label = headphones.CFG.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.GIT_PATH:
|
||||
git_locations = ['"'+headphones.GIT_PATH+'"']
|
||||
if headphones.CFG.GIT_PATH:
|
||||
git_locations = ['"'+headphones.CFG.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.DO_NOT_OVERRIDE_GIT_BRANCH and headphones.GIT_BRANCH:
|
||||
branch_name = headphones.GIT_BRANCH
|
||||
if headphones.CFG.DO_NOT_OVERRIDE_GIT_BRANCH and headphones.CFG.GIT_BRANCH:
|
||||
branch_name = headphones.CFG.GIT_BRANCH
|
||||
|
||||
else:
|
||||
branch_name, err = runGit('rev-parse --abbrev-ref HEAD')
|
||||
branch_name = branch_name
|
||||
|
||||
if not branch_name and headphones.GIT_BRANCH:
|
||||
logger.error('Could not retrieve branch name from git. Falling back to %s' % headphones.GIT_BRANCH)
|
||||
branch_name = headphones.GIT_BRANCH
|
||||
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:
|
||||
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.GIT_BRANCH
|
||||
return current_version, headphones.CFG.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.GIT_USER, headphones.GIT_BRANCH)
|
||||
url = 'https://api.github.com/repos/%s/headphones/commits/%s' % (headphones.CFG.GIT_USER, headphones.CFG.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.GIT_USER, headphones.LATEST_VERSION, headphones.CURRENT_VERSION)
|
||||
url = 'https://api.github.com/repos/%s/headphones/compare/%s...%s' % (headphones.CFG.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.GIT_BRANCH)
|
||||
output, err = runGit('pull origin ' + headphones.CFG.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.GIT_USER, headphones.GIT_BRANCH)
|
||||
tar_download_url = 'https://github.com/%s/headphones/tarball/%s' % (headphones.CFG.GIT_USER, headphones.CFG.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.GIT_BRANCH + '-github'
|
||||
download_name = headphones.CFG.GIT_BRANCH + '-github'
|
||||
tar_download_path = os.path.join(headphones.PROG_DIR, download_name)
|
||||
|
||||
# Save tar to disk
|
||||
|
||||
@@ -42,7 +42,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.INTERFACE)
|
||||
template_dir = os.path.join(str(interface_dir), headphones.CFG.INTERFACE)
|
||||
|
||||
_hplookup = TemplateLookup(directories=[template_dir])
|
||||
|
||||
@@ -85,7 +85,7 @@ class WebInterface(object):
|
||||
raise cherrypy.HTTPRedirect("home")
|
||||
|
||||
# Serve the extras up as a dict to make things easier for new templates (append new extras to the end)
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "djmix", "mixtape_street", "broadcast", "interview", "demo"]
|
||||
extras_list = headphones.POSSIBLE_EXTRAS
|
||||
if artist['Extras']:
|
||||
artist_extras = map(int, artist['Extras'].split(','))
|
||||
else:
|
||||
@@ -159,9 +159,8 @@ class WebInterface(object):
|
||||
extras = "1,2,3,4,5,6,7,8,9,10,11,12,13,14"
|
||||
else:
|
||||
temp_extras_list = []
|
||||
# TODO: Put these extras as a global variable
|
||||
i = 1
|
||||
for extra in ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "djmix", "mixtape_street", "broadcast", "interview", "demo"]:
|
||||
for extra in headphones.POSSIBLE_EXTRAS:
|
||||
if extra in kwargs:
|
||||
temp_extras_list.append(i)
|
||||
i += 1
|
||||
@@ -677,7 +676,7 @@ class WebInterface(object):
|
||||
markArtists.exposed = True
|
||||
|
||||
def importLastFM(self, username):
|
||||
headphones.LASTFM_USERNAME = username
|
||||
headphones.CFG.LASTFM_USERNAME = username
|
||||
headphones.config_write()
|
||||
threading.Thread(target=lastfm.getArtists).start()
|
||||
raise cherrypy.HTTPRedirect("home")
|
||||
@@ -689,7 +688,7 @@ class WebInterface(object):
|
||||
importLastFMTag.exposed = True
|
||||
|
||||
def importItunes(self, path):
|
||||
headphones.PATH_TO_XML = path
|
||||
headphones.CFG.PATH_TO_XML = path
|
||||
headphones.config_write()
|
||||
threading.Thread(target=importer.itunesImport, args=[path]).start()
|
||||
time.sleep(10)
|
||||
@@ -697,9 +696,9 @@ class WebInterface(object):
|
||||
importItunes.exposed = True
|
||||
|
||||
def musicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0):
|
||||
headphones.LIBRARYSCAN = libraryscan
|
||||
headphones.ADD_ARTISTS = autoadd
|
||||
headphones.MUSIC_DIR = path
|
||||
headphones.CFG.LIBRARYSCAN = libraryscan
|
||||
headphones.CFG.AUTO_ADD_ARTISTS = autoadd
|
||||
headphones.CFG.MUSIC_DIR = path
|
||||
headphones.config_write()
|
||||
if scan:
|
||||
try:
|
||||
@@ -955,212 +954,212 @@ 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.HTTP_HOST,
|
||||
"http_user" : headphones.HTTP_USERNAME,
|
||||
"http_port" : headphones.HTTP_PORT,
|
||||
"http_pass" : headphones.HTTP_PASSWORD,
|
||||
"launch_browser" : checked(headphones.LAUNCH_BROWSER),
|
||||
"enable_https" : checked(headphones.ENABLE_HTTPS),
|
||||
"https_cert" : headphones.HTTPS_CERT,
|
||||
"https_key" : headphones.HTTPS_KEY,
|
||||
"api_enabled" : checked(headphones.API_ENABLED),
|
||||
"api_key" : headphones.API_KEY,
|
||||
"download_scan_interval" : headphones.DOWNLOAD_SCAN_INTERVAL,
|
||||
"update_db_interval" : headphones.UPDATE_DB_INTERVAL,
|
||||
"mb_ignore_age" : headphones.MB_IGNORE_AGE,
|
||||
"search_interval" : headphones.SEARCH_INTERVAL,
|
||||
"libraryscan_interval" : headphones.LIBRARYSCAN_INTERVAL,
|
||||
"sab_host" : headphones.SAB_HOST,
|
||||
"sab_user" : headphones.SAB_USERNAME,
|
||||
"sab_api" : headphones.SAB_APIKEY,
|
||||
"sab_pass" : headphones.SAB_PASSWORD,
|
||||
"sab_cat" : headphones.SAB_CATEGORY,
|
||||
"nzbget_host" : headphones.NZBGET_HOST,
|
||||
"nzbget_user" : headphones.NZBGET_USERNAME,
|
||||
"nzbget_pass" : headphones.NZBGET_PASSWORD,
|
||||
"nzbget_cat" : headphones.NZBGET_CATEGORY,
|
||||
"nzbget_priority" : headphones.NZBGET_PRIORITY,
|
||||
"transmission_host" : headphones.TRANSMISSION_HOST,
|
||||
"transmission_user" : headphones.TRANSMISSION_USERNAME,
|
||||
"transmission_pass" : headphones.TRANSMISSION_PASSWORD,
|
||||
"utorrent_host" : headphones.UTORRENT_HOST,
|
||||
"utorrent_user" : headphones.UTORRENT_USERNAME,
|
||||
"utorrent_pass" : headphones.UTORRENT_PASSWORD,
|
||||
"utorrent_label" : headphones.UTORRENT_LABEL,
|
||||
"nzb_downloader_sabnzbd" : radio(headphones.NZB_DOWNLOADER, 0),
|
||||
"nzb_downloader_nzbget" : radio(headphones.NZB_DOWNLOADER, 1),
|
||||
"nzb_downloader_blackhole" : radio(headphones.NZB_DOWNLOADER, 2),
|
||||
"torrent_downloader_blackhole" : radio(headphones.TORRENT_DOWNLOADER, 0),
|
||||
"torrent_downloader_transmission" : radio(headphones.TORRENT_DOWNLOADER, 1),
|
||||
"torrent_downloader_utorrent" : radio(headphones.TORRENT_DOWNLOADER, 2),
|
||||
"download_dir" : headphones.DOWNLOAD_DIR,
|
||||
"use_blackhole" : checked(headphones.BLACKHOLE),
|
||||
"blackhole_dir" : headphones.BLACKHOLE_DIR,
|
||||
"usenet_retention" : headphones.USENET_RETENTION,
|
||||
"use_headphones_indexer" : checked(headphones.HEADPHONES_INDEXER),
|
||||
"use_newznab" : checked(headphones.NEWZNAB),
|
||||
"newznab_host" : headphones.NEWZNAB_HOST,
|
||||
"newznab_api" : headphones.NEWZNAB_APIKEY,
|
||||
"newznab_enabled" : checked(headphones.NEWZNAB_ENABLED),
|
||||
"extra_newznabs" : headphones.EXTRA_NEWZNABS,
|
||||
"use_nzbsorg" : checked(headphones.NZBSORG),
|
||||
"nzbsorg_uid" : headphones.NZBSORG_UID,
|
||||
"nzbsorg_hash" : headphones.NZBSORG_HASH,
|
||||
"use_omgwtfnzbs" : checked(headphones.OMGWTFNZBS),
|
||||
"omgwtfnzbs_uid" : headphones.OMGWTFNZBS_UID,
|
||||
"omgwtfnzbs_apikey" : headphones.OMGWTFNZBS_APIKEY,
|
||||
"preferred_words" : headphones.PREFERRED_WORDS,
|
||||
"ignored_words" : headphones.IGNORED_WORDS,
|
||||
"required_words" : headphones.REQUIRED_WORDS,
|
||||
"torrentblackhole_dir" : headphones.TORRENTBLACKHOLE_DIR,
|
||||
"download_torrent_dir" : headphones.DOWNLOAD_TORRENT_DIR,
|
||||
"numberofseeders" : headphones.NUMBEROFSEEDERS,
|
||||
"use_kat" : checked(headphones.KAT),
|
||||
"kat_proxy_url" : headphones.KAT_PROXY_URL,
|
||||
"kat_ratio": headphones.KAT_RATIO,
|
||||
"use_piratebay" : checked(headphones.PIRATEBAY),
|
||||
"piratebay_proxy_url" : headphones.PIRATEBAY_PROXY_URL,
|
||||
"piratebay_ratio": headphones.PIRATEBAY_RATIO,
|
||||
"use_mininova" : checked(headphones.MININOVA),
|
||||
"mininova_ratio": headphones.MININOVA_RATIO,
|
||||
"use_waffles" : checked(headphones.WAFFLES),
|
||||
"waffles_uid" : headphones.WAFFLES_UID,
|
||||
"waffles_passkey": headphones.WAFFLES_PASSKEY,
|
||||
"waffles_ratio": headphones.WAFFLES_RATIO,
|
||||
"use_rutracker" : checked(headphones.RUTRACKER),
|
||||
"rutracker_user" : headphones.RUTRACKER_USER,
|
||||
"rutracker_password": headphones.RUTRACKER_PASSWORD,
|
||||
"rutracker_ratio": headphones.RUTRACKER_RATIO,
|
||||
"use_whatcd" : checked(headphones.WHATCD),
|
||||
"whatcd_username" : headphones.WHATCD_USERNAME,
|
||||
"whatcd_password": headphones.WHATCD_PASSWORD,
|
||||
"whatcd_ratio": headphones.WHATCD_RATIO,
|
||||
"pref_qual_0" : radio(headphones.PREFERRED_QUALITY, 0),
|
||||
"pref_qual_1" : radio(headphones.PREFERRED_QUALITY, 1),
|
||||
"pref_qual_3" : radio(headphones.PREFERRED_QUALITY, 3),
|
||||
"pref_qual_2" : radio(headphones.PREFERRED_QUALITY, 2),
|
||||
"pref_bitrate" : headphones.PREFERRED_BITRATE,
|
||||
"pref_bitrate_high" : headphones.PREFERRED_BITRATE_HIGH_BUFFER,
|
||||
"pref_bitrate_low" : headphones.PREFERRED_BITRATE_LOW_BUFFER,
|
||||
"pref_bitrate_allow_lossless" : checked(headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
||||
"detect_bitrate" : checked(headphones.DETECT_BITRATE),
|
||||
"lossless_bitrate_from" : headphones.LOSSLESS_BITRATE_FROM,
|
||||
"lossless_bitrate_to" : headphones.LOSSLESS_BITRATE_TO,
|
||||
"freeze_db" : checked(headphones.FREEZE_DB),
|
||||
"move_files" : checked(headphones.MOVE_FILES),
|
||||
"rename_files" : checked(headphones.RENAME_FILES),
|
||||
"correct_metadata" : checked(headphones.CORRECT_METADATA),
|
||||
"cleanup_files" : checked(headphones.CLEANUP_FILES),
|
||||
"keep_nfo" : checked(headphones.KEEP_NFO),
|
||||
"add_album_art" : checked(headphones.ADD_ALBUM_ART),
|
||||
"album_art_format" : headphones.ALBUM_ART_FORMAT,
|
||||
"embed_album_art" : checked(headphones.EMBED_ALBUM_ART),
|
||||
"embed_lyrics" : checked(headphones.EMBED_LYRICS),
|
||||
"replace_existing_folders" : checked(headphones.REPLACE_EXISTING_FOLDERS),
|
||||
"dest_dir" : headphones.DESTINATION_DIR,
|
||||
"lossless_dest_dir" : headphones.LOSSLESS_DESTINATION_DIR,
|
||||
"folder_format" : headphones.FOLDER_FORMAT,
|
||||
"file_format" : headphones.FILE_FORMAT,
|
||||
"file_underscores" : checked(headphones.FILE_UNDERSCORES),
|
||||
"include_extras" : checked(headphones.INCLUDE_EXTRAS),
|
||||
"autowant_upcoming" : checked(headphones.AUTOWANT_UPCOMING),
|
||||
"autowant_all" : checked(headphones.AUTOWANT_ALL),
|
||||
"autowant_manually_added" : checked(headphones.AUTOWANT_MANUALLY_ADDED),
|
||||
"keep_torrent_files" : checked(headphones.KEEP_TORRENT_FILES),
|
||||
"prefer_torrents_0" : radio(headphones.PREFER_TORRENTS, 0),
|
||||
"prefer_torrents_1" : radio(headphones.PREFER_TORRENTS, 1),
|
||||
"prefer_torrents_2" : radio(headphones.PREFER_TORRENTS, 2),
|
||||
"open_magnet_links" : checked(headphones.OPEN_MAGNET_LINKS),
|
||||
"log_dir" : headphones.LOG_DIR,
|
||||
"cache_dir" : headphones.CACHE_DIR,
|
||||
"interface_list" : interface_list,
|
||||
"music_encoder": checked(headphones.MUSIC_ENCODER),
|
||||
"encoder": headphones.ENCODER,
|
||||
"xldprofile": headphones.XLDPROFILE,
|
||||
"bitrate": int(headphones.BITRATE),
|
||||
"encoderfolder": headphones.ENCODER_PATH,
|
||||
"advancedencoder": headphones.ADVANCEDENCODER,
|
||||
"encoderoutputformat": headphones.ENCODEROUTPUTFORMAT,
|
||||
"samplingfrequency": headphones.SAMPLINGFREQUENCY,
|
||||
"encodervbrcbr": headphones.ENCODERVBRCBR,
|
||||
"encoderquality": headphones.ENCODERQUALITY,
|
||||
"encoderlossless": checked(headphones.ENCODERLOSSLESS),
|
||||
"encoder_multicore": checked(headphones.ENCODER_MULTICORE),
|
||||
"encoder_multicore_count": int(headphones.ENCODER_MULTICORE_COUNT),
|
||||
"delete_lossless_files": checked(headphones.DELETE_LOSSLESS_FILES),
|
||||
"growl_enabled": checked(headphones.GROWL_ENABLED),
|
||||
"growl_onsnatch": checked(headphones.GROWL_ONSNATCH),
|
||||
"growl_host": headphones.GROWL_HOST,
|
||||
"growl_password": headphones.GROWL_PASSWORD,
|
||||
"prowl_enabled": checked(headphones.PROWL_ENABLED),
|
||||
"prowl_onsnatch": checked(headphones.PROWL_ONSNATCH),
|
||||
"prowl_keys": headphones.PROWL_KEYS,
|
||||
"prowl_priority": headphones.PROWL_PRIORITY,
|
||||
"xbmc_enabled": checked(headphones.XBMC_ENABLED),
|
||||
"xbmc_host": headphones.XBMC_HOST,
|
||||
"xbmc_username": headphones.XBMC_USERNAME,
|
||||
"xbmc_password": headphones.XBMC_PASSWORD,
|
||||
"xbmc_update": checked(headphones.XBMC_UPDATE),
|
||||
"xbmc_notify": checked(headphones.XBMC_NOTIFY),
|
||||
"lms_enabled": checked(headphones.LMS_ENABLED),
|
||||
"lms_host": headphones.LMS_HOST,
|
||||
"plex_enabled": checked(headphones.PLEX_ENABLED),
|
||||
"plex_server_host": headphones.PLEX_SERVER_HOST,
|
||||
"plex_client_host": headphones.PLEX_CLIENT_HOST,
|
||||
"plex_username": headphones.PLEX_USERNAME,
|
||||
"plex_password": headphones.PLEX_PASSWORD,
|
||||
"plex_update": checked(headphones.PLEX_UPDATE),
|
||||
"plex_notify": checked(headphones.PLEX_NOTIFY),
|
||||
"nma_enabled": checked(headphones.NMA_ENABLED),
|
||||
"nma_apikey": headphones.NMA_APIKEY,
|
||||
"nma_priority": int(headphones.NMA_PRIORITY),
|
||||
"nma_onsnatch": checked(headphones.NMA_ONSNATCH),
|
||||
"pushalot_enabled": checked(headphones.PUSHALOT_ENABLED),
|
||||
"pushalot_apikey": headphones.PUSHALOT_APIKEY,
|
||||
"pushalot_onsnatch": checked(headphones.PUSHALOT_ONSNATCH),
|
||||
"synoindex_enabled": checked(headphones.SYNOINDEX_ENABLED),
|
||||
"pushover_enabled": checked(headphones.PUSHOVER_ENABLED),
|
||||
"pushover_onsnatch": checked(headphones.PUSHOVER_ONSNATCH),
|
||||
"pushover_keys": headphones.PUSHOVER_KEYS,
|
||||
"pushover_apitoken": headphones.PUSHOVER_APITOKEN,
|
||||
"pushover_priority": headphones.PUSHOVER_PRIORITY,
|
||||
"pushbullet_enabled": checked(headphones.PUSHBULLET_ENABLED),
|
||||
"pushbullet_onsnatch": checked(headphones.PUSHBULLET_ONSNATCH),
|
||||
"pushbullet_apikey": headphones.PUSHBULLET_APIKEY,
|
||||
"pushbullet_deviceid": headphones.PUSHBULLET_DEVICEID,
|
||||
"subsonic_enabled": checked(headphones.SUBSONIC_ENABLED),
|
||||
"subsonic_host": headphones.SUBSONIC_HOST,
|
||||
"subsonic_username": headphones.SUBSONIC_USERNAME,
|
||||
"subsonic_password": headphones.SUBSONIC_PASSWORD,
|
||||
"twitter_enabled": checked(headphones.TWITTER_ENABLED),
|
||||
"twitter_onsnatch": checked(headphones.TWITTER_ONSNATCH),
|
||||
"osx_notify_enabled": checked(headphones.OSX_NOTIFY_ENABLED),
|
||||
"osx_notify_onsnatch": checked(headphones.OSX_NOTIFY_ONSNATCH),
|
||||
"osx_notify_app": headphones.OSX_NOTIFY_APP,
|
||||
"boxcar_enabled": checked(headphones.BOXCAR_ENABLED),
|
||||
"boxcar_onsnatch": checked(headphones.BOXCAR_ONSNATCH),
|
||||
"boxcar_token": headphones.BOXCAR_TOKEN,
|
||||
"mirror_list": headphones.MIRRORLIST,
|
||||
"mirror": headphones.MIRROR,
|
||||
"customhost": headphones.CUSTOMHOST,
|
||||
"customport": headphones.CUSTOMPORT,
|
||||
"customsleep": headphones.CUSTOMSLEEP,
|
||||
"hpuser": headphones.HPUSER,
|
||||
"hppass": headphones.HPPASS,
|
||||
"songkick_enabled": checked(headphones.SONGKICK_ENABLED),
|
||||
"songkick_apikey": headphones.SONGKICK_APIKEY,
|
||||
"songkick_location": headphones.SONGKICK_LOCATION,
|
||||
"songkick_filter_enabled": checked(headphones.SONGKICK_FILTER_ENABLED),
|
||||
"cache_sizemb": headphones.CACHE_SIZEMB,
|
||||
"file_permissions": headphones.FILE_PERMISSIONS,
|
||||
"folder_permissions": headphones.FOLDER_PERMISSIONS,
|
||||
"mpc_enabled": checked(headphones.MPC_ENABLED)
|
||||
}
|
||||
"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_3" : radio(headphones.CFG.PREFERRED_QUALITY, 3),
|
||||
"pref_qual_2" : radio(headphones.CFG.PREFERRED_QUALITY, 2),
|
||||
"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),
|
||||
"open_magnet_links" : checked(headphones.CFG.OPEN_MAGNET_LINKS),
|
||||
"log_dir" : headphones.CFG.LOG_DIR,
|
||||
"cache_dir" : headphones.CFG.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,
|
||||
"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)
|
||||
}
|
||||
|
||||
# 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)
|
||||
extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook", "other", "djmix", "mixtape_street", "broadcast", "interview", "demo"]
|
||||
if headphones.EXTRAS:
|
||||
extras = map(int, headphones.EXTRAS.split(','))
|
||||
extras_list = headphones.POSSIBLE_EXTRAS
|
||||
if headphones.CFG.EXTRAS:
|
||||
extras = map(int, headphones.CFG.EXTRAS.split(','))
|
||||
else:
|
||||
extras = []
|
||||
|
||||
@@ -1179,237 +1178,25 @@ class WebInterface(object):
|
||||
return serve_template(templatename="config.html", title="Settings", config=config)
|
||||
config.exposed = True
|
||||
|
||||
def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, api_enabled=0, api_key=None,
|
||||
download_scan_interval=None, update_db_interval=None, mb_ignore_age=None, search_interval=None, libraryscan_interval=None, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None,
|
||||
sab_category=None, nzbget_host=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_priority=0, transmission_host=None, transmission_username=None, transmission_password=None,
|
||||
utorrent_host=None, utorrent_username=None, utorrent_password=None, utorrent_label=None,nzb_downloader=0, torrent_downloader=0, download_dir=None, blackhole_dir=None, usenet_retention=None,
|
||||
use_headphones_indexer=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, omgwtfnzbs=0, omgwtfnzbs_uid=None, omgwtfnzbs_apikey=None,
|
||||
preferred_words=None, required_words=None, ignored_words=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, freeze_db=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
|
||||
numberofseeders=None, use_piratebay=0, piratebay_proxy_url=None, piratebay_ratio=None, use_kat=0, kat_proxy_url=None, kat_ratio=None, use_mininova=0, mininova_ratio=None, waffles=0, waffles_uid=None, waffles_passkey=None, waffles_ratio=None, whatcd=0, whatcd_username=None, whatcd_password=None, whatcd_ratio=None,
|
||||
rutracker=0, rutracker_user=None, rutracker_password=None, rutracker_ratio=None, rename_files=0, correct_metadata=0, cleanup_files=0, keep_nfo=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0, replace_existing_folders=False,
|
||||
destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, file_underscores=0, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, other=0, djmix=0, mixtape_street=0, broadcast=0, interview=0, demo=0,
|
||||
autowant_upcoming=False, autowant_all=False, autowant_manually_added=False, keep_torrent_files=False, prefer_torrents=0, open_magnet_links=0, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None,
|
||||
bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, subsonic_enabled=False, subsonic_host=None, subsonic_username=None, subsonic_password=None,
|
||||
delete_lossless_files=0, growl_enabled=0, growl_onsnatch=0, growl_host=None, growl_password=None, prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, pushalot_enabled=False, pushalot_apikey=None, pushalot_onsnatch=0, synoindex_enabled=False, lms_enabled=0, lms_host=None,
|
||||
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, pushover_apitoken=None, pushbullet_enabled=0, pushbullet_onsnatch=0, pushbullet_apikey=None, pushbullet_deviceid=None, twitter_enabled=0, twitter_onsnatch=0,
|
||||
osx_notify_enabled=0, osx_notify_onsnatch=0, osx_notify_app=None, boxcar_enabled=0, boxcar_onsnatch=0, boxcar_token=None, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None,
|
||||
preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, lossless_bitrate_from=None, lossless_bitrate_to=None, cache_sizemb=None, enable_https=0, https_cert=None, https_key=None,
|
||||
file_permissions=None, folder_permissions=None, plex_enabled=0, plex_server_host=None, plex_client_host=None, plex_username=None, plex_password=None, plex_update=0, plex_notify=0,
|
||||
songkick_enabled=0, songkick_apikey=None, songkick_location=None, songkick_filter_enabled=0, encoder_multicore=False, encoder_multicore_count=0, mpc_enabled=False, **kwargs ):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
headphones.HTTP_PORT = http_port
|
||||
headphones.HTTP_USERNAME = http_username
|
||||
headphones.HTTP_PASSWORD = http_password
|
||||
headphones.LAUNCH_BROWSER = launch_browser
|
||||
headphones.ENABLE_HTTPS = enable_https
|
||||
headphones.HTTPS_CERT = https_cert
|
||||
headphones.HTTPS_KEY = https_key
|
||||
headphones.API_ENABLED = api_enabled
|
||||
headphones.API_KEY = api_key
|
||||
headphones.DOWNLOAD_SCAN_INTERVAL = download_scan_interval
|
||||
headphones.UPDATE_DB_INTERVAL = update_db_interval
|
||||
headphones.MB_IGNORE_AGE = mb_ignore_age
|
||||
headphones.SEARCH_INTERVAL = search_interval
|
||||
headphones.LIBRARYSCAN_INTERVAL = libraryscan_interval
|
||||
headphones.SAB_HOST = sab_host
|
||||
headphones.SAB_USERNAME = sab_username
|
||||
headphones.SAB_PASSWORD = sab_password
|
||||
headphones.SAB_APIKEY = sab_apikey
|
||||
headphones.SAB_CATEGORY = sab_category
|
||||
headphones.NZBGET_HOST = nzbget_host
|
||||
headphones.NZBGET_USERNAME = nzbget_username
|
||||
headphones.NZBGET_PASSWORD = nzbget_password
|
||||
headphones.NZBGET_CATEGORY = nzbget_category
|
||||
headphones.NZBGET_PRIORITY = int(nzbget_priority)
|
||||
headphones.TRANSMISSION_HOST = transmission_host
|
||||
headphones.TRANSMISSION_USERNAME = transmission_username
|
||||
headphones.TRANSMISSION_PASSWORD = transmission_password
|
||||
headphones.UTORRENT_HOST = utorrent_host
|
||||
headphones.UTORRENT_USERNAME = utorrent_username
|
||||
headphones.UTORRENT_PASSWORD = utorrent_password
|
||||
headphones.UTORRENT_LABEL = utorrent_label
|
||||
headphones.NZB_DOWNLOADER = int(nzb_downloader)
|
||||
headphones.TORRENT_DOWNLOADER = int(torrent_downloader)
|
||||
headphones.DOWNLOAD_DIR = download_dir
|
||||
headphones.BLACKHOLE_DIR = blackhole_dir
|
||||
headphones.USENET_RETENTION = usenet_retention
|
||||
headphones.HEADPHONES_INDEXER = use_headphones_indexer
|
||||
headphones.NEWZNAB = newznab
|
||||
headphones.NEWZNAB_HOST = newznab_host
|
||||
headphones.NEWZNAB_APIKEY = newznab_apikey
|
||||
headphones.NEWZNAB_ENABLED = newznab_enabled
|
||||
headphones.NZBSORG = nzbsorg
|
||||
headphones.NZBSORG_UID = nzbsorg_uid
|
||||
headphones.NZBSORG_HASH = nzbsorg_hash
|
||||
headphones.OMGWTFNZBS = omgwtfnzbs
|
||||
headphones.OMGWTFNZBS_UID = omgwtfnzbs_uid
|
||||
headphones.OMGWTFNZBS_APIKEY = omgwtfnzbs_apikey
|
||||
headphones.PREFERRED_WORDS = preferred_words
|
||||
headphones.IGNORED_WORDS = ignored_words
|
||||
headphones.REQUIRED_WORDS = required_words
|
||||
headphones.TORRENTBLACKHOLE_DIR = torrentblackhole_dir
|
||||
headphones.NUMBEROFSEEDERS = numberofseeders
|
||||
headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir
|
||||
headphones.KAT = use_kat
|
||||
headphones.KAT_PROXY_URL = kat_proxy_url
|
||||
headphones.KAT_RATIO = kat_ratio
|
||||
headphones.PIRATEBAY = use_piratebay
|
||||
headphones.PIRATEBAY_PROXY_URL = piratebay_proxy_url
|
||||
headphones.PIRATEBAY_RATIO = piratebay_ratio
|
||||
headphones.MININOVA = use_mininova
|
||||
headphones.MININOVA_RATIO = mininova_ratio
|
||||
headphones.WAFFLES = waffles
|
||||
headphones.WAFFLES_UID = waffles_uid
|
||||
headphones.WAFFLES_PASSKEY = waffles_passkey
|
||||
headphones.WAFFLES_RATIO = waffles_ratio
|
||||
headphones.RUTRACKER = rutracker
|
||||
headphones.RUTRACKER_USER = rutracker_user
|
||||
headphones.RUTRACKER_PASSWORD = rutracker_password
|
||||
headphones.RUTRACKER_RATIO = rutracker_ratio
|
||||
headphones.WHATCD = whatcd
|
||||
headphones.WHATCD_USERNAME = whatcd_username
|
||||
headphones.WHATCD_PASSWORD = whatcd_password
|
||||
headphones.WHATCD_RATIO = whatcd_ratio
|
||||
headphones.PREFERRED_QUALITY = int(preferred_quality)
|
||||
headphones.PREFERRED_BITRATE = preferred_bitrate
|
||||
headphones.PREFERRED_BITRATE_HIGH_BUFFER = preferred_bitrate_high_buffer
|
||||
headphones.PREFERRED_BITRATE_LOW_BUFFER = preferred_bitrate_low_buffer
|
||||
headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS = preferred_bitrate_allow_lossless
|
||||
headphones.DETECT_BITRATE = detect_bitrate
|
||||
headphones.LOSSLESS_BITRATE_FROM = lossless_bitrate_from
|
||||
headphones.LOSSLESS_BITRATE_TO = lossless_bitrate_to
|
||||
headphones.FREEZE_DB = freeze_db
|
||||
headphones.MOVE_FILES = move_files
|
||||
headphones.CORRECT_METADATA = correct_metadata
|
||||
headphones.RENAME_FILES = rename_files
|
||||
headphones.CLEANUP_FILES = cleanup_files
|
||||
headphones.KEEP_NFO = keep_nfo
|
||||
headphones.ADD_ALBUM_ART = add_album_art
|
||||
headphones.ALBUM_ART_FORMAT = album_art_format
|
||||
headphones.EMBED_ALBUM_ART = embed_album_art
|
||||
headphones.EMBED_LYRICS = embed_lyrics
|
||||
headphones.REPLACE_EXISTING_FOLDERS = replace_existing_folders
|
||||
headphones.DESTINATION_DIR = destination_dir
|
||||
headphones.LOSSLESS_DESTINATION_DIR = lossless_destination_dir
|
||||
headphones.FOLDER_FORMAT = folder_format
|
||||
headphones.FILE_FORMAT = file_format
|
||||
headphones.FILE_UNDERSCORES = file_underscores
|
||||
headphones.INCLUDE_EXTRAS = include_extras
|
||||
headphones.AUTOWANT_UPCOMING = autowant_upcoming
|
||||
headphones.AUTOWANT_ALL = autowant_all
|
||||
headphones.AUTOWANT_MANUALLY_ADDED = autowant_manually_added
|
||||
headphones.KEEP_TORRENT_FILES = keep_torrent_files
|
||||
headphones.PREFER_TORRENTS = int(prefer_torrents)
|
||||
headphones.OPEN_MAGNET_LINKS = open_magnet_links
|
||||
headphones.INTERFACE = interface
|
||||
headphones.LOG_DIR = log_dir
|
||||
headphones.CACHE_DIR = cache_dir
|
||||
headphones.MUSIC_ENCODER = music_encoder
|
||||
headphones.ENCODER = encoder
|
||||
headphones.XLDPROFILE = xldprofile
|
||||
headphones.BITRATE = int(bitrate)
|
||||
headphones.SAMPLINGFREQUENCY = int(samplingfrequency)
|
||||
headphones.ENCODER_PATH = encoderfolder
|
||||
headphones.ADVANCEDENCODER = advancedencoder
|
||||
headphones.ENCODEROUTPUTFORMAT = encoderoutputformat
|
||||
headphones.ENCODERVBRCBR = encodervbrcbr
|
||||
headphones.ENCODERQUALITY = int(encoderquality)
|
||||
headphones.ENCODERLOSSLESS = int(encoderlossless)
|
||||
headphones.ENCODER_MULTICORE = encoder_multicore
|
||||
headphones.ENCODER_MULTICORE_COUNT = max(0, int(encoder_multicore_count))
|
||||
headphones.DELETE_LOSSLESS_FILES = int(delete_lossless_files)
|
||||
headphones.GROWL_ENABLED = growl_enabled
|
||||
headphones.GROWL_ONSNATCH = growl_onsnatch
|
||||
headphones.GROWL_HOST = growl_host
|
||||
headphones.GROWL_PASSWORD = growl_password
|
||||
headphones.PROWL_ENABLED = prowl_enabled
|
||||
headphones.PROWL_ONSNATCH = prowl_onsnatch
|
||||
headphones.PROWL_KEYS = prowl_keys
|
||||
headphones.PROWL_PRIORITY = prowl_priority
|
||||
headphones.XBMC_ENABLED = xbmc_enabled
|
||||
headphones.XBMC_HOST = xbmc_host
|
||||
headphones.XBMC_USERNAME = xbmc_username
|
||||
headphones.XBMC_PASSWORD = xbmc_password
|
||||
headphones.XBMC_UPDATE = xbmc_update
|
||||
headphones.XBMC_NOTIFY = xbmc_notify
|
||||
headphones.LMS_ENABLED = lms_enabled
|
||||
headphones.LMS_HOST = lms_host
|
||||
headphones.PLEX_ENABLED = plex_enabled
|
||||
headphones.PLEX_SERVER_HOST = plex_server_host
|
||||
headphones.PLEX_CLIENT_HOST = plex_client_host
|
||||
headphones.PLEX_USERNAME = plex_username
|
||||
headphones.PLEX_PASSWORD = plex_password
|
||||
headphones.PLEX_UPDATE = plex_update
|
||||
headphones.PLEX_NOTIFY = plex_notify
|
||||
headphones.NMA_ENABLED = nma_enabled
|
||||
headphones.NMA_APIKEY = nma_apikey
|
||||
headphones.NMA_PRIORITY = nma_priority
|
||||
headphones.NMA_ONSNATCH = nma_onsnatch
|
||||
headphones.PUSHALOT_ENABLED = pushalot_enabled
|
||||
headphones.PUSHALOT_APIKEY = pushalot_apikey
|
||||
headphones.PUSHALOT_ONSNATCH = pushalot_onsnatch
|
||||
headphones.SYNOINDEX_ENABLED = synoindex_enabled
|
||||
headphones.PUSHOVER_ENABLED = pushover_enabled
|
||||
headphones.PUSHOVER_ONSNATCH = pushover_onsnatch
|
||||
headphones.PUSHOVER_KEYS = pushover_keys
|
||||
headphones.PUSHOVER_PRIORITY = pushover_priority
|
||||
headphones.PUSHOVER_APITOKEN = pushover_apitoken
|
||||
headphones.PUSHBULLET_ENABLED = pushbullet_enabled
|
||||
headphones.PUSHBULLET_ONSNATCH = pushbullet_onsnatch
|
||||
headphones.PUSHBULLET_APIKEY = pushbullet_apikey
|
||||
headphones.PUSHBULLET_DEVICEID = pushbullet_deviceid
|
||||
headphones.SUBSONIC_ENABLED = subsonic_enabled
|
||||
headphones.SUBSONIC_HOST = subsonic_host
|
||||
headphones.SUBSONIC_USERNAME = subsonic_username
|
||||
headphones.SUBSONIC_PASSWORD = subsonic_password
|
||||
headphones.SONGKICK_ENABLED = songkick_enabled
|
||||
headphones.SONGKICK_APIKEY = songkick_apikey
|
||||
headphones.SONGKICK_LOCATION = songkick_location
|
||||
headphones.SONGKICK_FILTER_ENABLED = songkick_filter_enabled
|
||||
headphones.TWITTER_ENABLED = twitter_enabled
|
||||
headphones.TWITTER_ONSNATCH = twitter_onsnatch
|
||||
|
||||
headphones.OSX_NOTIFY_ENABLED = osx_notify_enabled
|
||||
headphones.OSX_NOTIFY_ONSNATCH = osx_notify_onsnatch
|
||||
headphones.OSX_NOTIFY_APP = osx_notify_app
|
||||
|
||||
headphones.BOXCAR_ENABLED = boxcar_enabled
|
||||
headphones.BOXCAR_ONSNATCH = boxcar_onsnatch
|
||||
headphones.BOXCAR_TOKEN = boxcar_token
|
||||
|
||||
headphones.MPC_ENABLED = mpc_enabled
|
||||
|
||||
headphones.MIRROR = mirror
|
||||
headphones.CUSTOMHOST = customhost
|
||||
headphones.CUSTOMPORT = customport
|
||||
headphones.CUSTOMSLEEP = customsleep
|
||||
headphones.HPUSER = hpuser
|
||||
headphones.HPPASS = hppass
|
||||
headphones.CACHE_SIZEMB = int(cache_sizemb)
|
||||
headphones.FILE_PERMISSIONS = file_permissions
|
||||
headphones.FOLDER_PERMISSIONS = folder_permissions
|
||||
|
||||
def configUpdate(self, **kwargs):
|
||||
# Handle the variable config options. Note - keys with False values aren't getting passed
|
||||
|
||||
headphones.EXTRA_NEWZNABS = []
|
||||
|
||||
headphones.CFG.clear_extra_newznabs()
|
||||
for kwarg in kwargs:
|
||||
if kwarg.startswith('newznab_host'):
|
||||
newznab_number = kwarg[12:]
|
||||
newznab_host = kwargs['newznab_host' + newznab_number]
|
||||
newznab_api = kwargs['newznab_api' + newznab_number]
|
||||
try:
|
||||
newznab_enabled = int(kwargs['newznab_enabled' + newznab_number])
|
||||
except KeyError:
|
||||
newznab_enabled = 0
|
||||
|
||||
headphones.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled))
|
||||
if len(newznab_number):
|
||||
newznab_host = kwargs.get('newznab_host' + newznab_number)
|
||||
newznab_api = kwargs.get('newznab_api' + newznab_number)
|
||||
try:
|
||||
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))
|
||||
|
||||
# Convert the extras to list then string. Coming in as 0 or 1 (append new extras to the end)
|
||||
temp_extras_list = []
|
||||
extras_list = [single, ep, compilation, soundtrack, live, remix, spokenword, audiobook, other, djmix, mixtape_street, broadcast, interview, demo]
|
||||
expected_extras = headphones.POSSIBLE_EXTRAS
|
||||
extras_list = [kwargs.get(x, 0) for x in expected_extras]
|
||||
|
||||
i = 1
|
||||
for extra in extras_list:
|
||||
@@ -1417,15 +1204,24 @@ class WebInterface(object):
|
||||
temp_extras_list.append(i)
|
||||
i+=1
|
||||
|
||||
headphones.EXTRAS = ','.join(str(n) for n in temp_extras_list)
|
||||
for extra in expected_extras:
|
||||
temp = '%s_temp' % extra
|
||||
if temp in kwargs:
|
||||
del kwargs[temp]
|
||||
if extra in kwargs:
|
||||
del kwargs[extra]
|
||||
|
||||
headphones.CFG.EXTRAS = ','.join(str(n) for n in temp_extras_list)
|
||||
|
||||
headphones.CFG.process_kwargs(kwargs)
|
||||
|
||||
# Sanity checking
|
||||
if headphones.SEARCH_INTERVAL < 360:
|
||||
if headphones.CFG.SEARCH_INTERVAL < 360:
|
||||
logger.info("Search interval too low. Resetting to 6 hour minimum")
|
||||
headphones.SEARCH_INTERVAL = 360
|
||||
headphones.CFG.SEARCH_INTERVAL = 360
|
||||
|
||||
# Write the config
|
||||
headphones.config_write()
|
||||
headphones.CFG.write()
|
||||
|
||||
#reconfigure musicbrainz database connection with the new values
|
||||
mb.startmb()
|
||||
@@ -1456,7 +1252,6 @@ class WebInterface(object):
|
||||
myDB = db.DBConnection()
|
||||
cloudlist = myDB.select('SELECT * from lastfmcloud')
|
||||
return serve_template(templatename="extras.html", title="Extras", cloudlist=cloudlist)
|
||||
return page
|
||||
extras.exposed = True
|
||||
|
||||
def addReleaseById(self, rid, rgid=None):
|
||||
@@ -1596,7 +1391,7 @@ class Artwork(object):
|
||||
cherrypy.response.headers['Cache-Control'] = 'no-cache'
|
||||
else:
|
||||
relpath = relpath.replace('cache/','',1)
|
||||
path = os.path.join(headphones.CACHE_DIR,relpath)
|
||||
path = os.path.join(headphones.CFG.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'
|
||||
@@ -1629,7 +1424,7 @@ class Artwork(object):
|
||||
cherrypy.response.headers['Cache-Control'] = 'no-cache'
|
||||
else:
|
||||
relpath = relpath.replace('cache/','',1)
|
||||
path = os.path.join(headphones.CACHE_DIR,relpath)
|
||||
path = os.path.join(headphones.CFG.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.ENABLE_HTTPS = False
|
||||
headphones.CFG.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.ENABLE_HTTPS = False
|
||||
headphones.CFG.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.CACHE_DIR
|
||||
'tools.staticdir.dir': headphones.CFG.CACHE_DIR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user