From d414b24f07bd1a30755903e02e5432a013ae2ee2 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Wed, 15 Aug 2012 13:59:37 +0530 Subject: [PATCH] Port over the existing track information (location, bit rate, format) from the tracks table to the alltracks table - based on TrackID. Updated album.html to use jquery and autoreload the track table, fixed the 'There was a error' typo in script.s --- data/interfaces/default/album.html | 2 +- data/interfaces/default/js/script.js | 2 +- headphones/importer.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/data/interfaces/default/album.html b/data/interfaces/default/album.html index 298e1cd8..5b6f1460 100644 --- a/data/interfaces/default/album.html +++ b/data/interfaces/default/album.html @@ -33,7 +33,7 @@ else: alternate_album_name = alternate_album['AlbumTitle'] + " (" + alternate_album['ReleaseCountry'] + ", " + alternate_album['ReleaseFormat'] + ")" %> - ${alternate_album_name}
+ ${alternate_album_name}
%endfor %endif diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 3ac9c342..e021074b 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -257,7 +257,7 @@ function doAjaxCall(url,elem,reload,form) { var dataError = $(elem).data('error'); if (typeof dataError === "undefined") { // Standard Message when variable is not set - var dataError = "There was a error"; + var dataError = "There was an error"; } // Get Success & Error message from inline data, else use standard message var succesMsg = $("
" + dataSucces + "
"); diff --git a/headphones/importer.py b/headphones/importer.py index e4f46a0a..473ef59c 100644 --- a/headphones/importer.py +++ b/headphones/importer.py @@ -173,6 +173,9 @@ def addArtisttoDB(artistid, extrasonly=False): fullreleaselist = [] for release in releaselist: + # What we're doing here now is first updating the allalbums & alltracks table to the most + # current info, then moving the appropriate release into the album table and its associated + # tracks into the tracks table releaseid = release['id'] @@ -296,6 +299,20 @@ def addArtisttoDB(artistid, extrasonly=False): if not rg_exists: releaseid = rg['id'] elif rg_exists and not rg_exists['ReleaseID']: + # Need to do some importing here - to transition the old format of using the release group + # only to using releasegroup & releaseid. These are the albums that are missing a ReleaseID + # so we'll need to move over the locations, bitrates & formats from the tracks table to the new + # alltracks table. Thankfully we can just use TrackIDs since they span releases/releasegroups + logger.info("Copying current track information to alternate releases") + tracks = myDB.action('SELECT * from tracks WHERE AlbumID=?', [rg['id']]).fetchall() + for track in tracks: + if track['Location']: + controlValueDict = {"TrackID": track['TrackID']} + newValueDict = {"Location": track['Location'], + "BitRate": track['BitRate'], + "Format": track['Format'], + } + myDB.upsert("alltracks", newValueDict, controlValueDict) releaseid = rg['id'] else: releaseid = rg_exists['ReleaseID']