From 5c35a57c33d9c23439b920e50e70e1da93fec865 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sat, 18 Aug 2012 22:57:38 +0530 Subject: [PATCH 1/6] Initial backend stuff to get splitting up extras working --- headphones/__init__.py | 27 +++++++++++++++++------ headphones/webserve.py | 49 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 2b938e02..318607a0 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,16 @@ 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: + # Need to update some stuff when people are upgrading and have the 'INCLUDE_EXTRAS' options selected + if INCLUDE_EXTRAS: + EXTRAS = "1,2,3,4,5,6,7,8" + c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT "1,2,3,4,5,6,7,8"') + else: + c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL') conn.commit() c.close() diff --git a/headphones/webserve.py b/headphones/webserve.py index d00c1f86..944c51bd 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -470,19 +470,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 +609,20 @@ class WebInterface(object): newznab_enabled = 0 headphones.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled)) + + # Convert the extras to list then string + 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") From c19354b0f9655c47754adae9c2aa0fdf78b8f440 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 19 Aug 2012 01:45:53 +0530 Subject: [PATCH 2/6] Couple of fixes to get the config to read the right variables, added global extras selection to config page --- data/interfaces/default/config.html | 54 +++++++++++++++++++++++++++-- headphones/webserve.py | 5 +-- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 3dfa2420..b2cb59d9 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -1,6 +1,7 @@ m<%inherit file="base.html"/> <%! import headphones + import string %> <%def name="headerIncludes()"> @@ -505,9 +506,30 @@ m<%inherit file="base.html"/>
Miscellaneous
- - -
+ + +
+ %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/headphones/webserve.py b/headphones/webserve.py index 944c51bd..38e61e9d 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -610,12 +610,13 @@ class WebInterface(object): headphones.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled)) - # Convert the extras to list then string + # 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] + extras_list = [single, ep, compilation, soundtrack, live, remix, spokenword, audiobook] i = 1 for extra in extras_list: + print repr(extra) if extra: temp_extras_list.append(i) i+=1 From 2cc9685877b391587a10761637de430eb5d1f609 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 19 Aug 2012 12:44:39 +0530 Subject: [PATCH 3/6] Fixed deselection on config page, removed 'print repr(extra)' used for testing --- data/interfaces/default/config.html | 2 +- headphones/webserve.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index b2cb59d9..6f709ebc 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -874,7 +874,7 @@ m<%inherit file="base.html"/> $("#${extra}").attr("checked", true); } else { - $("${extra}").attr("checked", false); + $("#${extra}").attr("checked", false); } }); %endfor diff --git a/headphones/webserve.py b/headphones/webserve.py index 38e61e9d..e69ab664 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -616,7 +616,6 @@ class WebInterface(object): i = 1 for extra in extras_list: - print repr(extra) if extra: temp_extras_list.append(i) i+=1 From d1b5d2a96054d35658f452426cf730855ea3794c Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 19 Aug 2012 13:28:50 +0530 Subject: [PATCH 4/6] Backend stuff in mb & importer to use the new IncludeExtras & Extras format --- headphones/importer.py | 11 ++++++----- headphones/mb.py | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) 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..83767d84 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -229,16 +229,28 @@ 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 myDB = db.DBConnection() try: - includeExtras = myDB.select('SELECT IncludeExtras from artists WHERE ArtistID=?', [artistid])[0][0] + db_artist = myDB.select('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 From ecb5395c2275b7b0aad0a4fc7ce8ba608939ef74 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 19 Aug 2012 13:44:16 +0530 Subject: [PATCH 5/6] Better logic when upgrading from the old extras format to the new --- headphones/__init__.py | 11 +++++++---- headphones/mb.py | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/headphones/__init__.py b/headphones/__init__.py index 318607a0..129d37f7 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -887,12 +887,15 @@ def dbcheck(): try: c.execute('SELECT Extras from artists') except sqlite3.OperationalError: - # Need to update some stuff when people are upgrading and have the 'INCLUDE_EXTRAS' options selected + 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" - c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT "1,2,3,4,5,6,7,8"') - else: - c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL') + 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/mb.py b/headphones/mb.py index 83767d84..f81b7057 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -230,6 +230,7 @@ def getArtist(artistid, extrasonly=False): }) # 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: From af2b0515eeccaac313d1cc2a4601ff551c47dace Mon Sep 17 00:00:00 2001 From: rembo10 Date: Sun, 19 Aug 2012 15:37:09 +0530 Subject: [PATCH 6/6] Added selective extras fetching to the artist page - had to make some backend changes to get this working: changed DB.select to DB.action in mb.py, added newstyle variable to getExtras --- data/interfaces/default/album.html | 2 +- data/interfaces/default/artist.html | 23 ++++++++++++++- data/interfaces/default/css/style.css | 7 +++++ headphones/mb.py | 2 +- headphones/webserve.py | 41 +++++++++++++++++++++++++-- 5 files changed, 69 insertions(+), 6 deletions(-) diff --git a/data/interfaces/default/album.html b/data/interfaces/default/album.html index 6af0459d..c3609d07 100644 --- a/data/interfaces/default/album.html +++ b/data/interfaces/default/album.html @@ -170,7 +170,7 @@ function initThisPage() { $('#album_chooser').click(function() { - $('#dialog').dialog(); + $('#dialog').dialog({ width: "500px" }); return false; }); $('#refresh_artist').click(function() { diff --git a/data/interfaces/default/artist.html b/data/interfaces/default/artist.html index b0d8af05..49acbef7 100644 --- a/data/interfaces/default/artist.html +++ b/data/interfaces/default/artist.html @@ -2,6 +2,7 @@ <%! from headphones import db import headphones + import string %> <%def name="headerIncludes()"> @@ -16,9 +17,21 @@ %endif %if artist['IncludeExtras']: Remove Extras + Modify Extras %else: - Get Extras + Get Extras %endif +
« Back to overview @@ -178,6 +191,14 @@ function initThisPage() { + $('#menu_link_getextra').click(function() { + $('#dialog').dialog(); + return false; + }); + $('#menu_link_modifyextra').click(function() { + $('#dialog').dialog(); + }); + %if artist['Status'] == 'Loading': showMsg("Getting artist information",true); %endif 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/mb.py b/headphones/mb.py index f81b7057..29b5bb8a 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -234,7 +234,7 @@ def getArtist(artistid, extrasonly=False): myDB = db.DBConnection() try: - db_artist = myDB.select('SELECT IncludeExtras, Extras from artists WHERE ArtistID=?', [artistid]).fetchone() + db_artist = myDB.action('SELECT IncludeExtras, Extras from artists WHERE ArtistID=?', [artistid]).fetchone() includeExtras = db_artist['IncludeExtras'] except IndexError: includeExtras = False diff --git a/headphones/webserve.py b/headphones/webserve.py index e69ab664..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)