First significant cut at refactoring the library sync function to optimize time/CPU usage.

Headphones now keeps all local file information persistent, and affords many new
opportunities that weren't available before.  There may be a bug here and there.  Please report.
This commit is contained in:
theguardian
2013-10-08 23:32:18 -07:00
parent 7a19d08ab2
commit fc00567191
11 changed files with 499 additions and 347 deletions
+1 -1
View File
@@ -138,7 +138,7 @@
</tr>
%endfor
<%
unmatched = myDB.select('SELECT * from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ?', [album['ArtistName'], album['AlbumTitle']])
unmatched_temp = myDB.select('SELECT * from have WHERE ArtistName LIKE ? AND AlbumTitle LIKE ? AND Matched is null ORDER BY CAST(TrackNumber AS INTEGER)', [album['ArtistName'], album['AlbumTitle']])
%>
%if unmatched:
%for track in unmatched:
+1 -1
View File
@@ -93,7 +93,7 @@
myDB = db.DBConnection()
totaltracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=?', [album['AlbumID']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=? AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle LIKE ?', [album['ArtistName'], album['AlbumTitle']]))
havetracks = len(myDB.select('SELECT TrackTitle from tracks WHERE AlbumID=? AND Location IS NOT NULL', [album['AlbumID']])) + len(myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle LIKE ? AND Matched IS NULL', [album['ArtistName'], album['AlbumTitle']]))
try:
percent = (havetracks*100.0)/totaltracks
+1 -1
View File
@@ -69,7 +69,7 @@
}
if (artist['ReleaseInFuture'] === 'True')
{
grade = 'gradeA';
grade = 'gradeA';6666666666666666
}
else
{
+19 -1
View File
@@ -22,6 +22,7 @@
%if not headphones.ADD_ARTISTS:
<a class="menu_link_edit" href="manageNew">Manage New Artists</a>
%endif
<a class="menu_link_edit" href="manageUnmatched">Manage Unmatched</a>
</div>
</div>
</%def>
@@ -35,6 +36,7 @@
<li><a href="#tabs-1">Scan Music Library</a></li>
<li><a href="#tabs-2">Imports</a></li>
<li><a href="#tabs-3">Force Actions</a></li>
<li><a href="#tabs-4">Force Legacy</a></li>
</ul>
<div id="tabs-1" class="configtable">
<fieldset>
@@ -120,7 +122,6 @@
<div class="links">
<a href="#" onclick="doAjaxCall('forceSearch',$(this))" data-success="Checking for wanted albums successful" data-error="Error checking wanted albums"><span class="ui-icon ui-icon-search"></span>Force Check for Wanted Albums</a>
<a href="#" onclick="doAjaxCall('forceUpdate',$(this))" data-success="Update active artists successful" data-error="Error forcing update artists"><span class="ui-icon ui-icon-heart"></span>Force Update Active Artists [Fast]</a>
<a href="#" onclick="doAjaxCall('forceFullUpdate',$(this))" data-success="Update active artists successful" data-error="Error forcing update artists"><span class="ui-icon ui-icon-heart"></span>Force Update Active Artists [Comprehensive]</a>
<a href="#" onclick="doAjaxCall('forcePostProcess',$(this))" data-success="Post-Processor is being loaded" data-error="Error during Post-Processing"><span class="ui-icon ui-icon-wrench"></span>Force Post-Process Albums in Download Folder</a>
<a href="#" onclick="doAjaxCall('checkGithub',$(this))" data-success="Checking for update successful" data-error="Error checking for update"><span class="ui-icon ui-icon-refresh"></span>Check for Headphones Updates</a>
<a href="#" id="delete_empty_artists"><span class="ui-icon ui-icon-trash"></span>Delete empty Artists</a>
@@ -140,6 +141,23 @@
</fieldset>
</div>
<div id="tabs-4" class="configtable">
<fieldset>
<legend>Force Legacy</legend>
<p><strong>Comprehensive Updating</strong></p>
<p>Please note that these functions will take a significant amount of time to complete.</p>
<div class="links">
<a href="#" onclick="doAjaxCall('forceFullUpdate',$(this))" data-success="Update active artists successful" data-error="Error forcing update artists"><span class="ui-icon ui-icon-heart"></span>Force Update Active Artists [Comprehensive]</a>
<a href="#" onclick="doAjaxCall('forceScan',$(this))" data-success="Library scan successful" data-error="Error forcing library scan"><span class="ui-icon ui-icon-refresh"></span>Force Re-scan Library [Comprehensive]</a>
</div>
</fieldset>
</div>
</div>
</%def>
<%def name="javascriptIncludes()">
+4 -1
View File
@@ -20,7 +20,10 @@
</div>
<form action="addArtists" method="get">
<div id="markalbum">
Add selected artists
<select name="action">
<option value="add">(+) ADD Selected Artists</option>
<option value="ignore">(-) IGNORE Selected Artists</option>
</select>
<input type="submit" value="Go">
</div>
<table class="display" id="artist_table">
@@ -0,0 +1,157 @@
<%inherit file="base.html" />
<%!
import headphones
import json
from headphones import db, helpers
myDB = db.DBConnection()
artist_json = {}
counter = 0
artist_list = myDB.action("SELECT ArtistName from artists ORDER BY ArtistName COLLATE NOCASE")
for artist in artist_list:
artist_json[counter] = artist['ArtistName']
counter+=1
json_artists = json.dumps(artist_json)
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<div id="subhead_menu">
</div>
</div>
<a href="manage" class="back">&laquo; Back to manage overview</a>
</%def>
<%def name="body()">
<div class="table_wrapper">
<div id="manageheader" class="title">
<h1 class="clearfix"><img src="interfaces/default/images/icon_manage.png" alt="manage"/>Manage Unmatched Albums</h1>
</div>
<table class="display" id="artist_table">
<thead>
<tr>
<th id="artist" align="center">Local Artist</th>
<th id="album" align="center">Local Album</th>
<th id="matchartist" align="center">Match Artist</th>
<th id="matchalbum" align="center">Match Album</th>
</tr>
</thead>
<tbody>
<% count_albums=0 %>
%for album in unmatchedalbums:
<tr class="gradeZ">
<td id="artist" align="center">${album['ArtistName']}
<form action="markUnmatched" method="get">
<input type="hidden" name="action" value="ignoreArtist">
<input type="hidden" name="existing_artist" value="${album['ArtistName']}">
<input type="submit" value="(-) Ignore Artist">
</form>
</td>
<td id="album" align="center">${album['AlbumTitle']}
<form action="markUnmatched" method="get">
<input type="hidden" name="action" value="ignoreAlbum">
<input type="hidden" name="existing_artist" value="${album['ArtistName']}">
<input type="hidden" name="existing_album" value="${album['AlbumTitle']}">
<input type="submit" value="(-) Ignore Album">
</form>
</td>
<td id="matchartist" align="center">
<button id="LoadArtists${count_albums}" onClick="click_Artist(this.id)">Load Artist List</button>
<form id="matchArtist_form${count_albums}" action="markUnmatched" method="get">
<input type="hidden" name="action" value="matchArtist">
<input type="hidden" name="existing_artist" value="${album['ArtistName']}">
<select id="artist_options${count_albums}" name="new_artist">
<option value="Null/None" selected="selected">Click "Load Artists" For List</option>
</select>
<input type="submit" value="(->) Match Artist">
</form>
</td>
<td id="matchalbum" align="center">
<button id="LoadAlbumArtists${count_albums}" onClick="click_AlbumArtist(this.id)">Load Artist List</button>
<form id="matchAlbumArtist_form${count_albums}" action="markUnmatched" method="get">
<input type="hidden" name="action" value="matchAlbum">
<input type="hidden" name="existing_artist" value="${album['ArtistName']}">
<input type="hidden" name="existing_album" value="${album['AlbumTitle']}">
<select id="album_artist_options${count_albums}" name="new_artist">
<option value="Null/None" selected="selected">Click "Load Artists" For List</option>
</select>
<select id="album_options${count_albums}" name="new_album">
<option value="Null/None" selected="selected">Select an Artist to View</option>
</select>
<input type="submit" value="(->) Match Album">
</form>
</td>
</tr>
<% count_albums+=1 %>
%endfor
</tbody>
</table>
</div>
</%def>
<%def name="headIncludes()">
<link rel="stylesheet" href="interfaces/default/css/data_table.css">
</%def>
<%def name="javascriptIncludes()">
<script src="js/libs/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function()
{
$('#artist_table').dataTable(
{
"bStateSave": true,
"bPaginate": true,
"oLanguage": {
"sSearch": "",
"sLengthMenu":"Show _MENU_ albums per page",
"sInfo":"Showing _START_ to _END_ of _TOTAL_ albums",
"sInfoEmpty":"Showing 0 to 0 of 0 albums",
"sInfoFiltered":"(filtered from _MAX_ total albums)",
"sEmptyTable": " ",
},
"sPaginationType": "full_numbers",
});
initActions();
});
function click_Artist(clicked_id) {
n=clicked_id.replace("LoadArtists","");
$('#artist_options'+n).html('');
$.each(${json_artists}, function(key, value) {
$('#artist_options'+n).append($("<option/>", {
value: value,
text: value
}));
});
}
function click_AlbumArtist(clicked_id) {
n=clicked_id.replace("LoadAlbumArtists","");
$('#album_artist_options'+n).html('');
$.each(${json_artists}, function(key, value) {
$('#album_artist_options'+n).append($("<option/>", {
value: value,
text: value
}));
});
update_albums(n)
}
function update_albums(n) {
$("#album_artist_options"+n).change(function(){
var selected_artist = $("#album_artist_options"+n).find("option:selected").text();
$('#album_options'+n).html('')
$.getJSON("getAlbumsByArtist_json?artist="+selected_artist, function( data ) {
$.each( data, function( key, value ) {
$('#album_options'+n).append($("<option/>", {
value: value,
text: value
}));
});
});
});
}
</script>
</%def>