+ %for extra in config['extras']:
+ ${string.capwords(extra)}
+ %endfor
+
+
+ %for extra in config['extras']:
+ ${string.capwords(extra)}
+ %endfor
+
+
@@ -707,6 +729,13 @@ m<%inherit file="base.html"/>
}
};
+ function openExtrasDialog() {
+ $("#dialog").dialog({ close: function(){
+ var elem = '';
+ doAjaxCall('configUpdate', elem,'tabs',true);
+ }}).dialog("open");
+ };
+
function initThisPage()
{
@@ -830,6 +859,25 @@ m<%inherit file="base.html"/>
$(this).parent().parent().remove();
deletedNewznabs = deletedNewznabs + 1;
});
+
+ $("#modify_extras").click(openExtrasDialog);
+
+ $("#include_extras").click(function(){
+ if ($("#include_extras").is(":checked")){
+ openExtrasDialog();
+ }
+ });
+
+ %for extra in config['extras']:
+ $("#${extra}_temp").click(function(){
+ if ($(this).is(":checked")){
+ $("#${extra}").attr("checked", true);
+ }
+ else {
+ $("#${extra}").attr("checked", false);
+ }
+ });
+ %endfor
$("#add_newznab").click(function() {
var intId = $("#newznab_providers > div").size() + deletedNewznabs + 1;
diff --git a/data/interfaces/default/css/style.css b/data/interfaces/default/css/style.css
index 54a2bc7c..771d4db3 100644
--- a/data/interfaces/default/css/style.css
+++ b/data/interfaces/default/css/style.css
@@ -674,6 +674,13 @@ footer {
position: relative;
margin-right: 3px;
}
+#dialog {
+ padding: 40px;
+}
+#dialog input#submit {
+ margin-left: 50px;
+ margin-right: auto;
+}
#subhead .back {
float: left;
margin-top: -25px;
diff --git a/headphones/__init__.py b/headphones/__init__.py
index 2b938e02..129d37f7 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -104,6 +104,7 @@ BLACKHOLE = None
BLACKHOLE_DIR = None
USENET_RETENTION = None
INCLUDE_EXTRAS = False
+EXTRAS = None
AUTOWANT_UPCOMING = False
AUTOWANT_ALL = False
@@ -241,17 +242,17 @@ def initialize():
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, \
HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, HTTP_PROXY, LAUNCH_BROWSER, API_ENABLED, API_KEY, GIT_PATH, \
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \
- LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \
- ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, \
+ LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \
+ RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, \
ADD_ALBUM_ART, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, DOWNLOAD_TORRENT_DIR, \
LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
- ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
- ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, MIRROR, CUSTOMHOST, CUSTOMPORT, \
- CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, SYNOINDEX_ENABLED, \
- ALBUM_COMPLETION_PCT
+ ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \
+ ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, \
+ MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
+ XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT
if __INITIALIZED__:
return False
@@ -317,6 +318,7 @@ def initialize():
BLACKHOLE_DIR = check_setting_str(CFG, 'General', 'blackhole_dir', '')
USENET_RETENTION = check_setting_int(CFG, 'General', 'usenet_retention', '1500')
INCLUDE_EXTRAS = bool(check_setting_int(CFG, 'General', 'include_extras', 0))
+ EXTRAS = check_setting_str(CFG, 'General', 'extras', '')
AUTOWANT_UPCOMING = bool(check_setting_int(CFG, 'General', 'autowant_upcoming', 1))
AUTOWANT_ALL = bool(check_setting_int(CFG, 'General', 'autowant_all', 0))
@@ -594,6 +596,7 @@ def config_write():
new_config['General']['blackhole_dir'] = BLACKHOLE_DIR
new_config['General']['usenet_retention'] = USENET_RETENTION
new_config['General']['include_extras'] = int(INCLUDE_EXTRAS)
+ new_config['General']['extras'] = EXTRAS
new_config['General']['autowant_upcoming'] = int(AUTOWANT_UPCOMING)
new_config['General']['autowant_all'] = int(AUTOWANT_ALL)
@@ -725,7 +728,7 @@ def dbcheck():
conn=sqlite3.connect(DB_FILE)
c=conn.cursor()
- c.execute('CREATE TABLE IF NOT EXISTS artists (ArtistID TEXT UNIQUE, ArtistName TEXT, ArtistSortName TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, LatestAlbum TEXT, ReleaseDate TEXT, AlbumID TEXT, HaveTracks INTEGER, TotalTracks INTEGER, LastUpdated TEXT, ArtworkURL TEXT, ThumbURL TEXT)')
+ c.execute('CREATE TABLE IF NOT EXISTS artists (ArtistID TEXT UNIQUE, ArtistName TEXT, ArtistSortName TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, LatestAlbum TEXT, ReleaseDate TEXT, AlbumID TEXT, HaveTracks INTEGER, TotalTracks INTEGER, LastUpdated TEXT, ArtworkURL TEXT, ThumbURL TEXT, Extras TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS albums (ArtistID TEXT, ArtistName TEXT, AlbumTitle TEXT, AlbumASIN TEXT, ReleaseDate TEXT, DateAdded TEXT, AlbumID TEXT UNIQUE, Status TEXT, Type TEXT, ArtworkURL TEXT, ThumbURL TEXT, ReleaseID TEXT, ReleaseCountry TEXT, ReleaseFormat TEXT)') # ReleaseFormat here means CD,Digital,Vinyl, etc. If using the default Headphones hybrid release, ReleaseID will equal AlbumID (AlbumID is releasegroup id)
c.execute('CREATE TABLE IF NOT EXISTS tracks (ArtistID TEXT, ArtistName TEXT, AlbumTitle TEXT, AlbumASIN TEXT, AlbumID TEXT, TrackTitle TEXT, TrackDuration, TrackID TEXT, TrackNumber INTEGER, Location TEXT, BitRate INTEGER, CleanName TEXT, Format TEXT, ReleaseID TEXT)') # Format here means mp3, flac, etc.
c.execute('CREATE TABLE IF NOT EXISTS allalbums (ArtistID TEXT, ArtistName TEXT, AlbumTitle TEXT, AlbumASIN TEXT, ReleaseDate TEXT, AlbumID TEXT, Type TEXT, ReleaseID TEXT, ReleaseCountry TEXT, ReleaseFormat TEXT)')
@@ -880,6 +883,19 @@ def dbcheck():
c.execute('SELECT Matched from have')
except sqlite3.OperationalError:
c.execute('ALTER TABLE have ADD COLUMN Matched TEXT DEFAULT NULL')
+
+ try:
+ c.execute('SELECT Extras from artists')
+ except sqlite3.OperationalError:
+ c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL')
+ # Need to update some stuff when people are upgrading and have 'include extras' set globally/for an artist
+ if INCLUDE_EXTRAS:
+ EXTRAS = "1,2,3,4,5,6,7,8"
+ logger.info("Copying over current artist IncludeExtras information")
+ artists = c.execute('SELECT ArtistID, IncludeExtras from artists').fetchall()
+ for artist in artists:
+ if artist['IncludeExtras']:
+ c.execute('INSERT into artists Extras="1,2,3,4,5,6,7,8" WHERE ArtistID=' + artist['ArtistID'])
conn.commit()
c.close()
diff --git a/headphones/importer.py b/headphones/importer.py
index ecf74a1f..a186f304 100644
--- a/headphones/importer.py
+++ b/headphones/importer.py
@@ -116,9 +116,13 @@ def addArtisttoDB(artistid, extrasonly=False):
# Don't replace a known artist name with an "Artist ID" placeholder
dbartist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [artistid]).fetchone()
- if dbartist is None:
+
+ # Only modify the Include Extras stuff if it's a new artist. We need it early so we know what to fetch
+ if not dbartist:
newValueDict = {"ArtistName": "Artist ID: %s" % (artistid),
- "Status": "Loading"}
+ "Status": "Loading",
+ "IncludeExtras": headphones.INCLUDE_EXTRAS,
+ "Extras": headphones.EXTRAS }
else:
newValueDict = {"Status": "Loading"}
@@ -149,9 +153,6 @@ def addArtisttoDB(artistid, extrasonly=False):
"DateAdded": helpers.today(),
"Status": "Loading"}
- if headphones.INCLUDE_EXTRAS:
- newValueDict['IncludeExtras'] = 1
-
myDB.upsert("artists", newValueDict, controlValueDict)
for rg in artist['releasegroups']:
diff --git a/headphones/mb.py b/headphones/mb.py
index 5f9d168d..29b5bb8a 100644
--- a/headphones/mb.py
+++ b/headphones/mb.py
@@ -229,16 +229,29 @@ def getArtist(artistid, extrasonly=False):
'type': unicode(rg['type'])
})
- # See if we need to grab extras
+ # See if we need to grab extras. Artist specific extras take precedence over global option
+ # Global options are set when adding a new artist
myDB = db.DBConnection()
try:
- includeExtras = myDB.select('SELECT IncludeExtras from artists WHERE ArtistID=?', [artistid])[0][0]
+ db_artist = myDB.action('SELECT IncludeExtras, Extras from artists WHERE ArtistID=?', [artistid]).fetchone()
+ includeExtras = db_artist['IncludeExtras']
except IndexError:
includeExtras = False
- if includeExtras or headphones.INCLUDE_EXTRAS:
- includes = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"]
+ if includeExtras:
+
+ # Need to convert extras string from something like '2,5.6' to ['ep','live','remix']
+ extras = db_artist['Extras']
+ extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"]
+ includes = []
+
+ i = 1
+ for extra in extras_list:
+ if str(i) in extras:
+ includes.append(extra)
+ i += 1
+
for include in includes:
artist = None
diff --git a/headphones/webserve.py b/headphones/webserve.py
index d00c1f86..ca4a70a9 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -61,9 +61,27 @@ class WebInterface(object):
myDB = db.DBConnection()
artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [ArtistID]).fetchone()
albums = myDB.select('SELECT * from albums WHERE ArtistID=? order by ReleaseDate DESC', [ArtistID])
+
+ # Serve the extras up as a dict to make things easier for new templates
+ extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"]
+ extras_dict = {}
+
+ if not artist['Extras']:
+ artist_extras = ""
+ else:
+ artist_extras = artist['Extras']
+
+ i = 1
+ for extra in extras_list:
+ if str(i) in artist_extras:
+ extras_dict[extra] = "checked"
+ else:
+ extras_dict[extra] = ""
+ i+=1
+
if artist is None:
raise cherrypy.HTTPRedirect("home")
- return serve_template(templatename="artist.html", title=artist['ArtistName'], artist=artist, albums=albums)
+ return serve_template(templatename="artist.html", title=artist['ArtistName'], artist=artist, albums=albums, extras=extras_dict)
artistPage.exposed = True
@@ -93,10 +111,27 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % artistid)
addArtist.exposed = True
- def getExtras(self, ArtistID):
+ def getExtras(self, ArtistID, newstyle=False, **kwargs):
+ # if calling this function without the newstyle, they're using the old format
+ # which doesn't separate extras, so we'll grab all of them
+ #
+ # If they are, we need to convert kwargs to string format
+ if not newstyle:
+ extras = "1,2,3,4,5,6,7,8"
+ 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"]:
+ if extra in kwargs:
+ temp_extras_list.append(i)
+ i += 1
+ extras = ','.join(str(n) for n in temp_extras_list)
+
myDB = db.DBConnection()
controlValueDict = {'ArtistID': ArtistID}
- newValueDict = {'IncludeExtras': 1}
+ newValueDict = {'IncludeExtras': 1,
+ 'Extras': extras}
myDB.upsert("artists", newValueDict, controlValueDict)
threading.Thread(target=importer.addArtisttoDB, args=[ArtistID, True]).start()
raise cherrypy.HTTPRedirect("artistPage?ArtistID=%s" % ArtistID)
@@ -470,19 +505,37 @@ class WebInterface(object):
"hpuser": headphones.HPUSER,
"hppass": headphones.HPPASS
}
+
+ # 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
+ extras_list = ["single", "ep", "compilation", "soundtrack", "live", "remix", "spokenword", "audiobook"]
+ extras_dict = {}
+
+ i = 1
+ for extra in extras_list:
+ if str(i) in headphones.EXTRAS:
+ extras_dict[extra] = "checked"
+ else:
+ extras_dict[extra] = ""
+ i+=1
+
+ config["extras"] = extras_dict
+
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, nzb_search_interval=None, libraryscan_interval=None,
- sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None,
- usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0,
- nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
- torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None,
- rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, include_extras=0, autowant_upcoming=False, autowant_all=False, interface=None, log_dir=None,
- music_encoder=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, delete_lossless_files=0,
- 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, synoindex_enabled=False, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None, **kwargs):
+ 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, nzb_search_interval=None, libraryscan_interval=None, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None,
+ sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None, usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None,
+ newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None,
+ newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
+ numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, rename_files=0, correct_metadata=0,
+ cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None,
+ include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False,
+ interface=None, log_dir=None, music_encoder=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None,
+ encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, delete_lossless_files=0, 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, synoindex_enabled=False, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None, **kwargs):
headphones.HTTP_HOST = http_host
headphones.HTTP_PORT = http_port
@@ -591,7 +644,20 @@ class WebInterface(object):
newznab_enabled = 0
headphones.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled))
+
+ # Convert the extras to list then string. Coming in as 0 or 1
+ temp_extras_list = []
+ extras_list = [single, ep, compilation, soundtrack, live, remix, spokenword, audiobook]
+ i = 1
+ for extra in extras_list:
+ if extra:
+ temp_extras_list.append(i)
+ i+=1
+
+ headphones.EXTRAS = ','.join(str(n) for n in temp_extras_list)
+
+ # Write the config
headphones.config_write()
raise cherrypy.HTTPRedirect("config")