mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-19 23:44:01 +01:00
Added album-chooser to the interface, fixed some backend bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<%inherit file="base.html" />
|
<%inherit file="base.html" />
|
||||||
<%!
|
<%!
|
||||||
from headphones import db, helpers
|
from headphones import db, helpers
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
%>
|
%>
|
||||||
@@ -16,7 +16,28 @@
|
|||||||
%else:
|
%else:
|
||||||
<a id="menu_link_retry" href="#" onclick="doAjaxCall('queueAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}&new=False', $(this),true);" data-success="Retrying the same version of '${album['AlbumTitle']}'">Retry Download</a>
|
<a id="menu_link_retry" href="#" onclick="doAjaxCall('queueAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}&new=False', $(this),true);" data-success="Retrying the same version of '${album['AlbumTitle']}'">Retry Download</a>
|
||||||
<a id="menu_link_new" href="#" onclick="doAjaxCall('queueAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}&new=True', $(this),true);" data-success="Looking for a new version of '${album['AlbumTitle']}'">Try New Version</a>
|
<a id="menu_link_new" href="#" onclick="doAjaxCall('queueAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}&new=True', $(this),true);" data-success="Looking for a new version of '${album['AlbumTitle']}'">Try New Version</a>
|
||||||
%endif
|
%endif
|
||||||
|
<a class="menu_link_edit" id="album_chooser" href="#">Choose Alternate Version</a>
|
||||||
|
<div id="dialog" title="Choose an Alternate Release" style="display:none" class="configtable">
|
||||||
|
<div class="links">
|
||||||
|
<%
|
||||||
|
alternate_albums = myDB.select("SELECT * from allalbums WHERE AlbumID=?", [album['AlbumID']])
|
||||||
|
%>
|
||||||
|
%if not alternate_albums:
|
||||||
|
<p>No alternate versions found. Try refreshing the artist</p>
|
||||||
|
%else:
|
||||||
|
%for alternate_album in alternate_albums:
|
||||||
|
<%
|
||||||
|
if alternate_album['AlbumID'] == alternate_album['ReleaseID']:
|
||||||
|
alternate_album_name = "Headphones Default Release"
|
||||||
|
else:
|
||||||
|
alternate_album_name = alternate_album['AlbumTitle'] + " (" + alternate_album['ReleaseCountry'] + ", " + alternate_album['ReleaseFormat'] + ")"
|
||||||
|
%>
|
||||||
|
<a href="switchAlbum?AlbumID=${album['AlbumID']}&ReleaseID=${alternate_albums['ReleaseID']}">${alternate_album_name}</a><br>
|
||||||
|
%endfor
|
||||||
|
%endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="artistPage?ArtistID=${album['ArtistID']}" class="back">« Back to ${album['ArtistName']}</a>
|
<a href="artistPage?ArtistID=${album['ArtistID']}" class="back">« Back to ${album['ArtistName']}</a>
|
||||||
@@ -144,6 +165,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$('#album_chooser').click(function() {
|
||||||
|
$('#dialog').dialog();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
getAlbumInfo();
|
getAlbumInfo();
|
||||||
getAlbumArt();
|
getAlbumArt();
|
||||||
initActions();
|
initActions();
|
||||||
|
|||||||
@@ -853,7 +853,6 @@ def dbcheck():
|
|||||||
c.execute('SELECT ReleaseID from albums')
|
c.execute('SELECT ReleaseID from albums')
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
c.execute('ALTER TABLE albums ADD COLUMN ReleaseID TEXT DEFAULT NULL')
|
c.execute('ALTER TABLE albums ADD COLUMN ReleaseID TEXT DEFAULT NULL')
|
||||||
c.execute('UPDATE TABLE albums SET ReleaseID = AlbumID')
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
c.execute('SELECT ReleaseFormat from albums')
|
c.execute('SELECT ReleaseFormat from albums')
|
||||||
|
|||||||
@@ -293,6 +293,8 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
# If there is a release, check the ReleaseID against the AlbumID to see if they differ (user updated)
|
# If there is a release, check the ReleaseID against the AlbumID to see if they differ (user updated)
|
||||||
if not rg_exists:
|
if not rg_exists:
|
||||||
releaseid = rg['id']
|
releaseid = rg['id']
|
||||||
|
elif rg_exists and not rg_exists['ReleaseID']:
|
||||||
|
releaseid = rg['id']
|
||||||
else:
|
else:
|
||||||
releaseid = rg_exists['ReleaseID']
|
releaseid = rg_exists['ReleaseID']
|
||||||
|
|
||||||
@@ -300,9 +302,9 @@ def addArtisttoDB(artistid, extrasonly=False):
|
|||||||
|
|
||||||
controlValueDict = {"AlbumID": rg['id']}
|
controlValueDict = {"AlbumID": rg['id']}
|
||||||
|
|
||||||
newValueDict = {"ArtistID": artistid,
|
newValueDict = {"ArtistID": album['ArtistID'],
|
||||||
"ArtistName": artist['artist_name'],
|
"ArtistName": album['ArtistName'],
|
||||||
"AlbumTitle": rg['title'],
|
"AlbumTitle": album['AlbumTitle'],
|
||||||
"ReleaseID": album['ReleaseID'],
|
"ReleaseID": album['ReleaseID'],
|
||||||
"AlbumASIN": album['AlbumASIN'],
|
"AlbumASIN": album['AlbumASIN'],
|
||||||
"ReleaseDate": album['ReleaseDate'],
|
"ReleaseDate": album['ReleaseDate'],
|
||||||
@@ -572,8 +574,8 @@ def getHybridRelease(fullreleaselist):
|
|||||||
|
|
||||||
release_dict = {
|
release_dict = {
|
||||||
'hasasin': bool(release['AlbumASIN']),
|
'hasasin': bool(release['AlbumASIN']),
|
||||||
'asin': release['AlbumASIN']
|
'asin': release['AlbumASIN'],
|
||||||
'trackscount': len(release['Tracks'],
|
'trackscount': len(release['Tracks']),
|
||||||
'releaseid': release['ReleaseID'],
|
'releaseid': release['ReleaseID'],
|
||||||
'releasedate': release['ReleaseDate'],
|
'releasedate': release['ReleaseDate'],
|
||||||
'format': format,
|
'format': format,
|
||||||
@@ -597,7 +599,7 @@ def getHybridRelease(fullreleaselist):
|
|||||||
|
|
||||||
sortable_release_list.sort(key=lambda x:getSortableReleaseDate(x['releasedate']))
|
sortable_release_list.sort(key=lambda x:getSortableReleaseDate(x['releasedate']))
|
||||||
|
|
||||||
average_tracks = sum(x['trackscount'] for x in releaselist) / float(len(releaselist))
|
average_tracks = sum(x['trackscount'] for x in sortable_release_list) / float(len(sortable_release_list))
|
||||||
for item in sortable_release_list:
|
for item in sortable_release_list:
|
||||||
item['trackscount_delta'] = abs(average_tracks - item['trackscount'])
|
item['trackscount_delta'] = abs(average_tracks - item['trackscount'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user