mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-16 00:25:31 +01:00
Most work done to get the ability to choose which release you want
This commit is contained in:
@@ -5,8 +5,13 @@
|
||||
%>
|
||||
|
||||
<%def name="headerIncludes()">
|
||||
|
||||
<div id="subhead_container">
|
||||
<div id="back_to_previous_link">
|
||||
<a href="artistPage?ArtistID=${album['ArtistID']}" class="back">« Back to ${album['ArtistName']}</a>
|
||||
</div>
|
||||
<div id="subhead_menu">
|
||||
|
||||
<a id="menu_link_delete" href="deleteAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}"><i class="fa fa-trash-o"></i> Delete Album</a>
|
||||
%if album['Status'] == 'Skipped':
|
||||
<a id="menu_link_wanted" href="#" onclick="doAjaxCall('queueAlbum?AlbumID=${album['AlbumID']}&ArtistID=${album['ArtistID']}&new=False', $(this),true)" data-success="'${album['AlbumTitle']}' added to queue"><i class="fa fa-heart"></i> Mark Album as Wanted</a>
|
||||
@@ -59,9 +64,23 @@
|
||||
<input type="button" value="Save changes" onclick="doAjaxCall('editSearchTerm',$(this),'tabs',true);return false;" data-success="Search term updated"/>
|
||||
</form>
|
||||
</div>
|
||||
<a class="menu_link_edit" id="choose_specific_download" href="#" onclick="getAvailableDownloads()"><i class="fa fa-search"></i> Choose Specific Download</a>
|
||||
<div id="choose_specific_download_dialog" title="Choose a specific download for this album" style="display:none" class="configtable">
|
||||
<table class="display" id="downloads_table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th id="title">Title</th>
|
||||
<th id="size">Size</th>
|
||||
<th id="provider">Provider</th>
|
||||
<th id="kind">Kind</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="downloads_table_body">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<a href="artistPage?ArtistID=${album['ArtistID']}" class="back">« Back to ${album['ArtistName']}</a>
|
||||
</%def>
|
||||
|
||||
<%def name="body()">
|
||||
@@ -197,8 +216,32 @@
|
||||
"bInfo": false,
|
||||
"bPaginate": false,
|
||||
"bDestroy": true
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function getAvailableDownloads() {
|
||||
$.getJSON("choose_specific_download?AlbumID=${album['AlbumID']}", function(data) {
|
||||
for( var i = 0, len = data.length; i < len; i++ ) {
|
||||
$('#downloads_table_body').append('<tr><td id="title"><a href="download_specific_release?AlbumID=${album['AlbumID']}&title='+data[i].title+'&size='+data[i].size+'&url='+data[i].url+'&provider='+data[i].provider+'&kind='+data[i].kind+'">'+data[i].title+'</a></td><td id="size"><span title='+data[i].size+'></span>'+(data[i].size / (1024*1024)).toFixed(2)+' MB</td><td id="provider">'+data[i].provider+'</td><td id="kind">'+data[i].kind+'</td></tr>');
|
||||
}
|
||||
$('#downloads_table').dataTable({
|
||||
"aoColumns": [
|
||||
null,
|
||||
{ "sType": "title-numeric"},
|
||||
null,
|
||||
null
|
||||
],
|
||||
"aaSorting": [],
|
||||
"bFilter": false,
|
||||
"bInfo": false,
|
||||
"bPaginate": false,
|
||||
"bDestroy": true
|
||||
});
|
||||
$("#choose_specific_download_dialog").dialog({ width: "1000px" });
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
getAlbumInfo();
|
||||
|
||||
@@ -691,7 +691,7 @@ footer {
|
||||
}
|
||||
#subhead #subhead_container #subhead_menu {
|
||||
float: right;
|
||||
margin-top: 5px;
|
||||
margin-top: 0px;
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
}
|
||||
@@ -716,6 +716,11 @@ footer {
|
||||
color: #FFF;
|
||||
border-color: #518CC6 #518CC6 #2A65A0;
|
||||
}
|
||||
#subhead #subhead_container #back_to_previous_link {
|
||||
margin-top: 20px;
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
}
|
||||
div#searchbar {
|
||||
border-left: 1px solid #FAFAFA;
|
||||
-moz-box-shadow: -1px 0 0 #e0e0e0;
|
||||
@@ -772,7 +777,7 @@ div#searchbar .mini-icon {
|
||||
_height: 302px;
|
||||
background-color: #FFF;
|
||||
clear: both;
|
||||
margin: 30px auto 0;
|
||||
margin: 60px auto 0;
|
||||
min-height: 100px;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
@@ -1054,6 +1059,22 @@ div#artistheader h2 a {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#downloads_table th#title {
|
||||
text-align: center;
|
||||
min-width: 500px;
|
||||
}
|
||||
#downloads_table th#size {
|
||||
text-align: center;
|
||||
min-width: 80px;
|
||||
}
|
||||
#downloads_table th#provider {
|
||||
text-align: center;
|
||||
min-width: 100px;
|
||||
}
|
||||
#downloads_table th#kind {
|
||||
text-align: center;
|
||||
min-width: 80px;
|
||||
}
|
||||
#history_table {
|
||||
background-color: #FFF;
|
||||
font-size: 13px;
|
||||
|
||||
@@ -108,7 +108,7 @@ def patch_http_response_read(func):
|
||||
httplib.HTTPResponse.read = patch_http_response_read(httplib.HTTPResponse.read)
|
||||
|
||||
|
||||
def searchforalbum(albumid=None, new=False, losslessOnly=False):
|
||||
def searchforalbum(albumid=None, new=False, losslessOnly=False, choose_specific_download=False):
|
||||
|
||||
myDB = db.DBConnection()
|
||||
|
||||
@@ -127,17 +127,25 @@ def searchforalbum(albumid=None, new=False, losslessOnly=False):
|
||||
if album['Status'] == "Wanted Lossless":
|
||||
losslessOnly = True
|
||||
|
||||
logger.info('Searching for "%s - %s" since it is marked as wanted' % (album['ArtistName'], album['AlbumTitle']))
|
||||
do_sorted_search(album, new, losslessOnly)
|
||||
|
||||
elif albumid and choose_specific_download:
|
||||
|
||||
album = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
|
||||
logger.info('Searching for "%s - %s"' % (album['ArtistName'], album['AlbumTitle']))
|
||||
results = do_sorted_search(album, new, losslessOnly, choose_specific_download=True)
|
||||
return results
|
||||
|
||||
else:
|
||||
|
||||
album = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
|
||||
logger.info('Searching for %s' % album['AlbumTitle'])
|
||||
logger.info('Searching for "%s - %s" since it was marked as wanted' % (album['ArtistName'], album['AlbumTitle']))
|
||||
do_sorted_search(album, new, losslessOnly)
|
||||
|
||||
logger.info('Search for Wanted albums complete')
|
||||
|
||||
def do_sorted_search(album, new, losslessOnly):
|
||||
def do_sorted_search(album, new, losslessOnly, choose_specific_download):
|
||||
|
||||
NZB_PROVIDERS = (headphones.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBSRUS or headphones.OMGWTFNZBS)
|
||||
NZB_DOWNLOADERS = (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST)
|
||||
@@ -179,6 +187,10 @@ def do_sorted_search(album, new, losslessOnly):
|
||||
torrent_results = []
|
||||
|
||||
results = nzb_results + torrent_results
|
||||
|
||||
|
||||
if choose_specific_download:
|
||||
return results
|
||||
|
||||
sorted_search_results = sort_search_results(results, album, new)
|
||||
|
||||
@@ -331,7 +343,7 @@ def searchNZB(album, new=False, losslessOnly=False):
|
||||
term = re.sub('[\.\-\/]', ' ', term).encode('utf-8')
|
||||
artistterm = re.sub('[\.\-\/]', ' ', cleanartist).encode('utf-8')
|
||||
|
||||
logger.info("Searching for %s since it was marked as wanted" % term)
|
||||
logger.debug("Using search term: %s" % term)
|
||||
|
||||
resultlist = []
|
||||
|
||||
@@ -912,7 +924,7 @@ def searchTorrent(album, new=False, losslessOnly=False):
|
||||
artistterm = re.sub('[\.\-\/]', ' ', cleanartist).encode('utf-8', 'replace')
|
||||
albumterm = re.sub('[\.\-\/]', ' ', cleanalbum).encode('utf-8', 'replace')
|
||||
|
||||
logger.info("Searching torrents for %s since it was marked as wanted" % term)
|
||||
logger.debug("Using search term: %s" % term)
|
||||
|
||||
resultlist = []
|
||||
pre_sorted_results = False
|
||||
@@ -1408,6 +1420,7 @@ def searchTorrent(album, new=False, losslessOnly=False):
|
||||
|
||||
# THIS IS KIND OF A MESS AND PROBABLY NEEDS TO BE CLEANED UP
|
||||
def preprocess(resultlist):
|
||||
|
||||
for result in resultlist:
|
||||
|
||||
if result[4] == 'torrent':
|
||||
|
||||
@@ -304,6 +304,41 @@ class WebInterface(object):
|
||||
raise cherrypy.HTTPRedirect(redirect)
|
||||
queueAlbum.exposed = True
|
||||
|
||||
def choose_specific_download(self, AlbumID):
|
||||
results = searcher.searchforalbum(AlbumID, choose_specific_download=True)
|
||||
|
||||
results_as_dicts = []
|
||||
|
||||
for result in results:
|
||||
|
||||
result_dict = {
|
||||
'title':result[0],
|
||||
'size':result[1],
|
||||
'url':result[2],
|
||||
'provider':result[3],
|
||||
'kind':result[4]
|
||||
}
|
||||
results_as_dicts.append(result_dict)
|
||||
|
||||
s = simplejson.dumps(results_as_dicts)
|
||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||
return s
|
||||
|
||||
choose_specific_download.exposed = True
|
||||
|
||||
def download_specific_release(self, AlbumID, title, size, url, provider, kind):
|
||||
|
||||
result = [(title,int(size),url,provider,kind)]
|
||||
logger.info(u"Making sure we can download the chosen result")
|
||||
(data, bestqual) = searcher.preprocess(result)
|
||||
|
||||
if data and bestqual:
|
||||
myDB = db.DBConnection()
|
||||
album = myDB.action('SELECT * from albums WHERE AlbumID=?', [AlbumID]).fetchone()
|
||||
searcher.send_to_downloader(data, bestqual, album)
|
||||
|
||||
download_specific_release.exposed = True
|
||||
|
||||
def unqueueAlbum(self, AlbumID, ArtistID):
|
||||
logger.info(u"Marking album: " + AlbumID + "as skipped...")
|
||||
myDB = db.DBConnection()
|
||||
|
||||
Reference in New Issue
Block a user