Release v0.5.7

This commit is contained in:
rembo10
2015-07-01 02:18:01 -07:00
12 changed files with 211 additions and 87 deletions
+14
View File
@@ -1,5 +1,19 @@
# Changelog # Changelog
## v0.5.7
Released 01 July 2015
Highlights:
* Improved: Moved pushover to use requests lib
* Improved: Plex tokens with Plex Home
* Improved: Added getLogs & clearLogs to api
* Improved: Cache MetaCritic scores. Added user-agent header to fix 403 errors
* Improved: Specify whether to delete folders when force post-processing
* Improved: Convert target bitrate to vbr preset for what.cd searching
* Improved: Switched Pushover to requests lib
The full list of commits can be found [here](https://github.com/rembo10/headphones/compare/v0.5.6...v0.5.7).
## v0.5.6 ## v0.5.6
Released 08 June 2015 Released 08 June 2015
+10
View File
@@ -753,6 +753,12 @@
<input type="checkbox" name="replace_existing_folders" value="1" ${config['replace_existing_folders']}> <input type="checkbox" name="replace_existing_folders" value="1" ${config['replace_existing_folders']}>
</label> </label>
</div> </div>
<div class="row indent">
<label>
Keep original folder?
<input type="checkbox" name="keep_original_folder" value="1" ${config['keep_original_folder']}>
</label>
</div>
</div> </div>
<label> <label>
Rename files Rename files
@@ -901,6 +907,10 @@
<label>Plex Password</label><input type="password" name="plex_password" value="${config['plex_password']}" size="30"> <label>Plex Password</label><input type="password" name="plex_password" value="${config['plex_password']}" size="30">
<small>Password of your Plex client API (blank for none)</small> <small>Password of your Plex client API (blank for none)</small>
</div> </div>
<div class="row">
<label>Plex Token</label><input type="text" name="plex_token" value="${config['plex_token']}" size="30">
<small>Plex Token (for use with Plex Home)</small>
</div>
<div class="checkbox row"> <div class="checkbox row">
<input type="checkbox" name="plex_update" value="1" ${config['plex_update']} /><label>Update Plex Library</label> <input type="checkbox" name="plex_update" value="1" ${config['plex_update']} /><label>Update Plex Library</label>
</div> </div>
+67 -20
View File
@@ -137,27 +137,26 @@
No empty artists found. No empty artists found.
%endif %endif
</div> </div>
<a href="#" onclick="doAjaxCall('forcePostProcess',$(this))" data-success="Post-Processor is being loaded" data-error="Error during Post-Processing"><i class="fa fa-wrench fa-fw"></i> Force Post-Process Albums in Download Folder</a> <div id="post_process">
<a href="#" class="btnOpenDialog"><i class="fa fa-wrench fa-fw"></i> Force Post-Process Albums in Download Folder</a>
</div>
</div> </div>
</fieldset> </fieldset>
<form action="forcePostProcess" method="GET"> <fieldset>
<fieldset> <div class="row" id="post_process_alternate">
<div class="row"> <label>Force Post-Process Albums in Alternate Folder</label>
<label>Force Post-Process Albums in Alternate Folder</label> <input type="text" value="" name="dir" id="dir" size="50" />
<input type="text" value="" name="dir" id="dir" size="50" /><input type="submit" /> <input type="button" class="btnOpenDialog" value="Submit" />
</div> </div>
</fieldset> </fieldset>
</form> <fieldset>
<form action="forcePostProcess" method="GET"> <div class="row" id="post_process_single">
<fieldset> <label>Post-Process Single Folder</label>
<div class="row"> <input type="text" value="" name="album_dir" id="album_dir" size="50" />
<label>Post-Process Single Folder</label> <input type="button" class="btnOpenDialog" value="Submit" />
<input type="text" value="" name="album_dir" id="album_dir" size="50" /><input type="submit" /> </div>
</div> </fieldset>
</fieldset>
</form>
</div> </div>
@@ -177,8 +176,7 @@
</fieldset> </fieldset>
</div> </div>
<div id="dialog-confirm"></div>
</div> </div>
</%def> </%def>
@@ -188,6 +186,55 @@
$('#autoadd').append('<input type="hidden" name="scan" value=1 />'); $('#autoadd').append('<input type="hidden" name="scan" value=1 />');
}; };
function fnOpenNormalDialog(id) {
if (id === "post_process"){
var url = "forcePostProcess?"
}
if (id === "post_process_alternate"){
var dir = $('#dir').val();
var url = "forcePostProcess?dir=" + dir + "&"
}
if (id === "post_process_single"){
var dir = $('#album_dir').val();
var url = "forcePostProcess?album_dir=" + dir + "&"
}
var t = $('<a data-success="Post-Processor is being loaded" data-error="Error during Post-Processing">');
$("#dialog-confirm").html("Do you want to keep the original folder(s) after post-processing? If you click no, the folders still might be kept depending on your global settings");
// Define the Dialog and its properties.
$("#dialog-confirm").dialog({
resizable: false,
modal: true,
title: "Keep original folder(s)?",
height: 170,
width: 400,
buttons: {
"Yes": function () {
$(this).dialog('close');
doAjaxCall(url + "keep_original_folder=True", t);
},
"No": function () {
$(this).dialog('close');
doAjaxCall(url + "keep_original_folder=False", t);
}
}
});
}
$('.btnOpenDialog').click(function(e){
e.preventDefault();
var parentId = $(this).closest('div').prop('id');
fnOpenNormalDialog(parentId);
});
function callback(value) {
if (value) {
alert("Confirmed");
} else {
alert("Rejected");
}
}
function initThisPage() { function initThisPage() {
$('#manage_albums').click(function() { $('#manage_albums').click(function() {
$('#dialog').dialog(); $('#dialog').dialog();
+6 -1
View File
@@ -353,7 +353,7 @@ def dbcheck():
conn = sqlite3.connect(DB_FILE) conn = sqlite3.connect(DB_FILE)
c = conn.cursor() c = conn.cursor()
c.execute( 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, Type TEXT)') '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, Type TEXT, MetaCritic TEXT)')
# ReleaseFormat here means CD,Digital,Vinyl, etc. If using the default # ReleaseFormat here means CD,Digital,Vinyl, etc. If using the default
# Headphones hybrid release, ReleaseID will equal AlbumID (AlbumID is # Headphones hybrid release, ReleaseID will equal AlbumID (AlbumID is
# releasegroup id) # releasegroup id)
@@ -599,6 +599,11 @@ def dbcheck():
except sqlite3.OperationalError: except sqlite3.OperationalError:
c.execute('ALTER TABLE artists ADD COLUMN Type TEXT DEFAULT NULL') c.execute('ALTER TABLE artists ADD COLUMN Type TEXT DEFAULT NULL')
try:
c.execute('SELECT MetaCritic from artists')
except sqlite3.OperationalError:
c.execute('ALTER TABLE artists ADD COLUMN MetaCritic TEXT DEFAULT NULL')
conn.commit() conn.commit()
c.close() c.close()
+9 -3
View File
@@ -21,8 +21,8 @@ import json
cmd_list = ['getIndex', 'getArtist', 'getAlbum', 'getUpcoming', 'getWanted', 'getSnatched', 'getSimilar', 'getHistory', 'getLogs', cmd_list = ['getIndex', 'getArtist', 'getAlbum', 'getUpcoming', 'getWanted', 'getSnatched', 'getSimilar', 'getHistory', 'getLogs',
'findArtist', 'findAlbum', 'addArtist', 'delArtist', 'pauseArtist', 'resumeArtist', 'refreshArtist', 'findArtist', 'findAlbum', 'addArtist', 'delArtist', 'pauseArtist', 'resumeArtist', 'refreshArtist',
'addAlbum', 'queueAlbum', 'unqueueAlbum', 'forceSearch', 'forceProcess', 'forceActiveArtistsUpdate', 'addAlbum', 'queueAlbum', 'unqueueAlbum', 'forceSearch', 'forceProcess', 'forceActiveArtistsUpdate',
'getVersion', 'checkGithub','shutdown', 'restart', 'update', 'getArtistArt', 'getAlbumArt', 'getVersion', 'checkGithub', 'shutdown', 'restart', 'update', 'getArtistArt', 'getAlbumArt',
'getArtistInfo', 'getAlbumInfo', 'getArtistThumb', 'getAlbumThumb', 'getArtistInfo', 'getAlbumInfo', 'getArtistThumb', 'getAlbumThumb', 'clearLogs',
'choose_specific_download', 'download_specific_release'] 'choose_specific_download', 'download_specific_release']
@@ -176,7 +176,13 @@ class Api(object):
return return
def _getLogs(self, **kwargs): def _getLogs(self, **kwargs):
pass self.data = headphones.LOG_LIST
return
def _clearLogs(self, **kwargs):
headphones.LOG_LIST = []
self.data = 'Cleared log'
return
def _findArtist(self, **kwargs): def _findArtist(self, **kwargs):
if 'name' not in kwargs: if 'name' not in kwargs:
+2
View File
@@ -175,6 +175,7 @@ _CONFIG_DEFINITIONS = {
'PLEX_SERVER_HOST': (str, 'Plex', ''), 'PLEX_SERVER_HOST': (str, 'Plex', ''),
'PLEX_UPDATE': (int, 'Plex', 0), 'PLEX_UPDATE': (int, 'Plex', 0),
'PLEX_USERNAME': (str, 'Plex', ''), 'PLEX_USERNAME': (str, 'Plex', ''),
'PLEX_TOKEN': (str, 'Plex', ''),
'PREFERRED_BITRATE': (str, 'General', ''), 'PREFERRED_BITRATE': (str, 'General', ''),
'PREFERRED_BITRATE_ALLOW_LOSSLESS': (int, 'General', 0), 'PREFERRED_BITRATE_ALLOW_LOSSLESS': (int, 'General', 0),
'PREFERRED_BITRATE_HIGH_BUFFER': (int, 'General', 0), 'PREFERRED_BITRATE_HIGH_BUFFER': (int, 'General', 0),
@@ -200,6 +201,7 @@ _CONFIG_DEFINITIONS = {
'PUSHOVER_PRIORITY': (int, 'Pushover', 0), 'PUSHOVER_PRIORITY': (int, 'Pushover', 0),
'RENAME_FILES': (int, 'General', 0), 'RENAME_FILES': (int, 'General', 0),
'REPLACE_EXISTING_FOLDERS': (int, 'General', 0), 'REPLACE_EXISTING_FOLDERS': (int, 'General', 0),
'KEEP_ORIGINAL_FOLDER': (int, 'General', 0),
'REQUIRED_WORDS': (str, 'General', ''), 'REQUIRED_WORDS': (str, 'General', ''),
'RUTRACKER': (int, 'Rutracker', 0), 'RUTRACKER': (int, 'Rutracker', 0),
'RUTRACKER_PASSWORD': (str, 'Rutracker', ''), 'RUTRACKER_PASSWORD': (str, 'Rutracker', ''),
+1 -1
View File
@@ -496,7 +496,7 @@ def addArtisttoDB(artistid, extrasonly=False, forcefull=False, type="artist"):
cache.getThumb(ArtistID=artistid) cache.getThumb(ArtistID=artistid)
logger.info(u"Fetching Metacritic reviews for: %s" % artist['artist_name']) logger.info(u"Fetching Metacritic reviews for: %s" % artist['artist_name'])
metacritic.update(artist['artist_name'], artist['releasegroups']) metacritic.update(artistid, artist['artist_name'], artist['releasegroups'])
if errors: if errors:
logger.info("[%s] Finished updating artist: %s but with errors, so not marking it as updated in the database" % (artist['artist_name'], artist['artist_name'])) logger.info("[%s] Finished updating artist: %s but with errors, so not marking it as updated in the database" % (artist['artist_name'], artist['artist_name']))
+40 -11
View File
@@ -14,11 +14,13 @@
# along with Headphones. If not, see <http://www.gnu.org/licenses/>. # along with Headphones. If not, see <http://www.gnu.org/licenses/>.
import re import re
import json
import headphones import headphones
from headphones import db, helpers, logger, request from headphones import db, helpers, logger, request
from headphones.common import USER_AGENT
def update(artist_name,release_groups): def update(artistid, artist_name,release_groups):
""" Pretty simple and crude function to find the artist page on metacritic, """ Pretty simple and crude function to find the artist page on metacritic,
then parse that page to get critic & user scores for albums""" then parse that page to get critic & user scores for albums"""
@@ -31,28 +33,55 @@ def update(artist_name,release_groups):
mc_artist_name = mc_artist_name.replace(" ","-") mc_artist_name = mc_artist_name.replace(" ","-")
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2243.2 Safari/537.36'}
url = "http://www.metacritic.com/person/" + mc_artist_name + "?filter-options=music&sort_options=date&num_items=100" url = "http://www.metacritic.com/person/" + mc_artist_name + "?filter-options=music&sort_options=date&num_items=100"
res = request.request_soup(url, parser='html.parser') res = request.request_soup(url, headers=headers, parser='html.parser')
rows = None
try: try:
rows = res.tbody.find_all('tr') rows = res.tbody.find_all('tr')
except: except:
logger.info("Unable to get metacritic scores for: %s" % artist_name) logger.info("Unable to get metacritic scores for: %s" % artist_name)
return
myDB = db.DBConnection() myDB = db.DBConnection()
artist = myDB.action('SELECT * FROM artists WHERE ArtistID=?', [artistid]).fetchone()
for row in rows: score_list = []
title = row.a.string
# If we couldn't get anything from MetaCritic for whatever reason,
# let's try to load scores from the db
if not rows:
if artist['MetaCritic']:
score_list = json.loads(artist['MetaCritic'])
else:
return
# If we did get scores, let's update the db with them
else:
for row in rows:
title = row.a.string
scores = row.find_all("span")
critic_score = scores[0].string
user_score = scores[1].string
score_dict = {'title':title,'critic_score':critic_score,'user_score':user_score}
score_list.append(score_dict)
# Save scores to the database
controlValueDict = {"ArtistID": artistid}
newValueDict = {'MetaCritic':json.dumps(score_list)}
myDB.upsert("artists", newValueDict, controlValueDict)
for score in score_list:
title = score['title']
# Iterate through the release groups we got passed to see if we can find
# a match
for rg in release_groups: for rg in release_groups:
if rg['title'].lower() == title.lower(): if rg['title'].lower() == title.lower():
scores = row.find_all("span") critic_score = score['critic_score']
critic_score = scores[0].string user_score = score['user_score']
user_score = scores[1].string
controlValueDict = {"AlbumID": rg['id']} controlValueDict = {"AlbumID": rg['id']}
newValueDict = {'CriticScore':critic_score,'UserScore':user_score} newValueDict = {'CriticScore':critic_score,'UserScore':user_score}
myDB.upsert("albums", newValueDict, controlValueDict) myDB.upsert("albums", newValueDict, controlValueDict)
+19 -29
View File
@@ -316,6 +316,7 @@ class Plex(object):
self.client_hosts = headphones.CONFIG.PLEX_CLIENT_HOST self.client_hosts = headphones.CONFIG.PLEX_CLIENT_HOST
self.username = headphones.CONFIG.PLEX_USERNAME self.username = headphones.CONFIG.PLEX_USERNAME
self.password = headphones.CONFIG.PLEX_PASSWORD self.password = headphones.CONFIG.PLEX_PASSWORD
self.token = headphones.CONFIG.PLEX_TOKEN
def _sendhttp(self, host, command): def _sendhttp(self, host, command):
@@ -354,13 +355,15 @@ class Plex(object):
for host in hosts: for host in hosts:
logger.info('Sending library update command to Plex Media Server@ ' + host) logger.info('Sending library update command to Plex Media Server@ ' + host)
url = "%s/library/sections" % host url = "%s/library/sections" % host
try: if self.token:
xml_sections = minidom.parse(urllib.urlopen(url)) params = {'X-Plex-Token': self.token}
except IOError, e: else:
logger.warn("Error while trying to contact Plex Media Server: %s" % e) params = False
return False
r = request.request_minidom(url, params=params)
sections = r.getElementsByTagName('Directory')
sections = xml_sections.getElementsByTagName('Directory')
if not sections: if not sections:
logger.info(u"Plex Media Server not running on: " + host) logger.info(u"Plex Media Server not running on: " + host)
return False return False
@@ -368,11 +371,7 @@ class Plex(object):
for s in sections: for s in sections:
if s.getAttribute('type') == "artist": if s.getAttribute('type') == "artist":
url = "%s/library/sections/%s/refresh" % (host, s.getAttribute('key')) url = "%s/library/sections/%s/refresh" % (host, s.getAttribute('key'))
try: request.request_response(url, params=params)
urllib.urlopen(url)
except Exception as e:
logger.warn("Error updating library section for Plex Media Server: %s" % e)
return False
def notify(self, artist, album, albumartpath): def notify(self, artist, album, albumartpath):
@@ -583,7 +582,7 @@ class PUSHOVER(object):
if not headphones.CONFIG.PUSHOVER_ENABLED: if not headphones.CONFIG.PUSHOVER_ENABLED:
return return
http_handler = HTTPSConnection("api.pushover.net") url = "https://api.pushover.net/1/messages.json"
data = {'token': self.application_token, data = {'token': self.application_token,
'user': headphones.CONFIG.PUSHOVER_KEYS, 'user': headphones.CONFIG.PUSHOVER_KEYS,
@@ -591,25 +590,16 @@ class PUSHOVER(object):
'message': message.encode("utf-8"), 'message': message.encode("utf-8"),
'priority': headphones.CONFIG.PUSHOVER_PRIORITY} 'priority': headphones.CONFIG.PUSHOVER_PRIORITY}
http_handler.request("POST", headers = {'Content-type': "application/x-www-form-urlencoded"}
"/1/messages.json",
headers={'Content-type': "application/x-www-form-urlencoded"},
body=urlencode(data))
response = http_handler.getresponse()
request_status = response.status
logger.debug(u"Pushover response status: %r" % request_status)
logger.debug(u"Pushover response headers: %r" % response.getheaders())
logger.debug(u"Pushover response body: %r" % response.read())
if request_status == 200: response = request.request_response(url, method="POST", headers=headers, data=data)
logger.info(u"Pushover notifications sent.")
return True if response:
elif request_status >= 400 and request_status < 500: logger.info(u"Pushover notifications sent.")
logger.info(u"Pushover request failed: %s" % response.reason) return True
return False
else: else:
logger.info(u"Pushover notification failed.") logger.error(u"Pushover notification failed.")
return False return False
def updateLibrary(self): def updateLibrary(self):
#For uniformity reasons not removed #For uniformity reasons not removed
+15 -15
View File
@@ -59,7 +59,7 @@ def checkFolder():
logger.debug("Checking download folder finished.") logger.debug("Checking download folder finished.")
def verify(albumid, albumpath, Kind=None, forced=False): def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=False):
myDB = db.DBConnection() myDB = db.DBConnection()
release = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone() release = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
@@ -216,7 +216,7 @@ def verify(albumid, albumpath, Kind=None, forced=False):
logger.debug('Matching metadata album: %s with album name: %s' % (metaalbum, dbalbum)) logger.debug('Matching metadata album: %s with album name: %s' % (metaalbum, dbalbum))
if metaartist == dbartist and metaalbum == dbalbum: if metaartist == dbartist and metaalbum == dbalbum:
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind) doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind, keep_original_folder)
return return
# test #2: filenames # test #2: filenames
@@ -234,7 +234,7 @@ def verify(albumid, albumpath, Kind=None, forced=False):
logger.debug('Checking if track title: %s is in file name: %s' % (dbtrack, filetrack)) logger.debug('Checking if track title: %s is in file name: %s' % (dbtrack, filetrack))
if dbtrack in filetrack: if dbtrack in filetrack:
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind) doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind, keep_original_folder)
return return
# test #3: number of songs and duration # test #3: number of songs and duration
@@ -266,7 +266,7 @@ def verify(albumid, albumpath, Kind=None, forced=False):
logger.debug('Database track duration: %i' % db_track_duration) logger.debug('Database track duration: %i' % db_track_duration)
delta = abs(downloaded_track_duration - db_track_duration) delta = abs(downloaded_track_duration - db_track_duration)
if delta < 240: if delta < 240:
doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind) doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind, keep_original_folder)
return return
logger.warn(u'Could not identify album: %s. It may not be the intended album.' % albumpath.decode(headphones.SYS_ENCODING, 'replace')) logger.warn(u'Could not identify album: %s. It may not be the intended album.' % albumpath.decode(headphones.SYS_ENCODING, 'replace'))
@@ -276,11 +276,11 @@ def verify(albumid, albumpath, Kind=None, forced=False):
renameUnprocessedFolder(albumpath, tag="Unprocessed") renameUnprocessedFolder(albumpath, tag="Unprocessed")
def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind=None): def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind=None, keep_original_folder=False):
logger.info('Starting post-processing for: %s - %s' % (release['ArtistName'], release['AlbumTitle'])) logger.info('Starting post-processing for: %s - %s' % (release['ArtistName'], release['AlbumTitle']))
# Check to see if we're preserving the torrent dir # Check to see if we're preserving the torrent dir
if headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent" and 'headphones-modified' not in albumpath: if (headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent" and 'headphones-modified' not in albumpath) or headphones.CONFIG.KEEP_ORIGINAL_FOLDER or keep_original_folder:
new_folder = os.path.join(albumpath, 'headphones-modified'.encode(headphones.SYS_ENCODING, 'replace')) new_folder = os.path.join(albumpath, 'headphones-modified'.encode(headphones.SYS_ENCODING, 'replace'))
logger.info("Copying files to 'headphones-modified' subfolder to preserve downloaded files for seeding") logger.info("Copying files to 'headphones-modified' subfolder to preserve downloaded files for seeding")
try: try:
@@ -1060,7 +1060,7 @@ def renameUnprocessedFolder(path, tag):
return return
def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None): def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None, keep_original_folder=False):
logger.info('Force checking download folder for completed downloads') logger.info('Force checking download folder for completed downloads')
@@ -1136,7 +1136,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
continue continue
else: else:
logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album', snatched['Title']) logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album', snatched['Title'])
verify(snatched['AlbumID'], folder, snatched['Kind']) verify(snatched['AlbumID'], folder, snatched['Kind'], keep_original_folder=keep_original_folder)
continue continue
# Attempt 2: strip release group id from filename # Attempt 2: strip release group id from filename
@@ -1153,7 +1153,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
release = myDB.action('SELECT ArtistName, AlbumTitle, AlbumID from albums WHERE AlbumID=?', [rgid]).fetchone() release = myDB.action('SELECT ArtistName, AlbumTitle, AlbumID from albums WHERE AlbumID=?', [rgid]).fetchone()
if release: if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle']) logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle'])
verify(release['AlbumID'], folder, forced=True) verify(release['AlbumID'], folder, forced=True, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('Found a (possibly) valid Musicbrainz realse group id in album folder name.') logger.info('Found a (possibly) valid Musicbrainz realse group id in album folder name.')
@@ -1172,7 +1172,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName LIKE ? and AlbumTitle LIKE ?', [name, album]).fetchone() release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName LIKE ? and AlbumTitle LIKE ?', [name, album]).fetchone()
if release: if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle']) logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle'])
verify(release['AlbumID'], folder) verify(release['AlbumID'], folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('Querying MusicBrainz for the release group id for: %s - %s', name, album) logger.info('Querying MusicBrainz for the release group id for: %s - %s', name, album)
@@ -1183,7 +1183,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
rgid = None rgid = None
if rgid: if rgid:
verify(rgid, folder) verify(rgid, folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('No match found on MusicBrainz for: %s - %s', name, album) logger.info('No match found on MusicBrainz for: %s - %s', name, album)
@@ -1207,7 +1207,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName LIKE ? and AlbumTitle LIKE ?', [name, album]).fetchone() release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE ArtistName LIKE ? and AlbumTitle LIKE ?', [name, album]).fetchone()
if release: if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle']) logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle'])
verify(release['AlbumID'], folder) verify(release['AlbumID'], folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('Querying MusicBrainz for the release group id for: %s - %s', name, album) logger.info('Querying MusicBrainz for the release group id for: %s - %s', name, album)
@@ -1218,7 +1218,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
rgid = None rgid = None
if rgid: if rgid:
verify(rgid, folder) verify(rgid, folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('No match found on MusicBrainz for: %s - %s', name, album) logger.info('No match found on MusicBrainz for: %s - %s', name, album)
@@ -1231,7 +1231,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE AlbumTitle LIKE ?', [folder_basename]).fetchone() release = myDB.action('SELECT AlbumID, ArtistName, AlbumTitle from albums WHERE AlbumTitle LIKE ?', [folder_basename]).fetchone()
if release: if release:
logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle']) logger.info('Found a match in the database: %s - %s. Verifying to make sure it is the correct album', release['ArtistName'], release['AlbumTitle'])
verify(release['AlbumID'], folder) verify(release['AlbumID'], folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('Querying MusicBrainz for the release group id for: %s', folder_basename) logger.info('Querying MusicBrainz for the release group id for: %s', folder_basename)
@@ -1242,7 +1242,7 @@ def forcePostProcess(dir=None, expand_subfolders=True, album_dir=None):
rgid = None rgid = None
if rgid: if rgid:
verify(rgid, folder) verify(rgid, folder, keep_original_folder=keep_original_folder)
continue continue
else: else:
logger.info('No match found on MusicBrainz for: %s - %s', name, album) logger.info('No match found on MusicBrainz for: %s - %s', name, album)
+6
View File
@@ -1280,6 +1280,12 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, choose
search_formats = [None] # should return all search_formats = [None] # should return all
bitrate = headphones.CONFIG.PREFERRED_BITRATE bitrate = headphones.CONFIG.PREFERRED_BITRATE
if bitrate: if bitrate:
if 225 <= int(bitrate) < 256:
bitrate = 'V0'
elif 200 <= int(bitrate) < 225:
bitrate = 'V1'
elif 175 <= int(bitrate) < 200:
bitrate = 'V2'
for encoding_string in gazelleencoding.ALL_ENCODINGS: for encoding_string in gazelleencoding.ALL_ENCODINGS:
if re.search(bitrate, encoding_string, flags=re.I): if re.search(bitrate, encoding_string, flags=re.I):
bitrate_string = encoding_string bitrate_string = encoding_string
+18 -3
View File
@@ -740,9 +740,9 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("home") raise cherrypy.HTTPRedirect("home")
@cherrypy.expose @cherrypy.expose
def forcePostProcess(self, dir=None, album_dir=None): def forcePostProcess(self, dir=None, album_dir=None, keep_original_folder=False):
from headphones import postprocessor from headphones import postprocessor
threading.Thread(target=postprocessor.forcePostProcess, kwargs={'dir': dir, 'album_dir': album_dir}).start() threading.Thread(target=postprocessor.forcePostProcess, kwargs={'dir': dir, 'album_dir': album_dir, 'keep_original_folder':keep_original_folder}).start()
raise cherrypy.HTTPRedirect("home") raise cherrypy.HTTPRedirect("home")
@cherrypy.expose @cherrypy.expose
@@ -1066,6 +1066,7 @@ class WebInterface(object):
"embed_album_art": checked(headphones.CONFIG.EMBED_ALBUM_ART), "embed_album_art": checked(headphones.CONFIG.EMBED_ALBUM_ART),
"embed_lyrics": checked(headphones.CONFIG.EMBED_LYRICS), "embed_lyrics": checked(headphones.CONFIG.EMBED_LYRICS),
"replace_existing_folders": checked(headphones.CONFIG.REPLACE_EXISTING_FOLDERS), "replace_existing_folders": checked(headphones.CONFIG.REPLACE_EXISTING_FOLDERS),
"keep_original_folder" : checked(headphones.CONFIG.KEEP_ORIGINAL_FOLDER),
"destination_dir": headphones.CONFIG.DESTINATION_DIR, "destination_dir": headphones.CONFIG.DESTINATION_DIR,
"lossless_destination_dir": headphones.CONFIG.LOSSLESS_DESTINATION_DIR, "lossless_destination_dir": headphones.CONFIG.LOSSLESS_DESTINATION_DIR,
"folder_format": headphones.CONFIG.FOLDER_FORMAT, "folder_format": headphones.CONFIG.FOLDER_FORMAT,
@@ -1120,6 +1121,7 @@ class WebInterface(object):
"plex_client_host": headphones.CONFIG.PLEX_CLIENT_HOST, "plex_client_host": headphones.CONFIG.PLEX_CLIENT_HOST,
"plex_username": headphones.CONFIG.PLEX_USERNAME, "plex_username": headphones.CONFIG.PLEX_USERNAME,
"plex_password": headphones.CONFIG.PLEX_PASSWORD, "plex_password": headphones.CONFIG.PLEX_PASSWORD,
"plex_token": headphones.CONFIG.PLEX_TOKEN,
"plex_update": checked(headphones.CONFIG.PLEX_UPDATE), "plex_update": checked(headphones.CONFIG.PLEX_UPDATE),
"plex_notify": checked(headphones.CONFIG.PLEX_NOTIFY), "plex_notify": checked(headphones.CONFIG.PLEX_NOTIFY),
"nma_enabled": checked(headphones.CONFIG.NMA_ENABLED), "nma_enabled": checked(headphones.CONFIG.NMA_ENABLED),
@@ -1217,7 +1219,7 @@ class WebInterface(object):
"launch_browser", "enable_https", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled", "launch_browser", "enable_https", "api_enabled", "use_blackhole", "headphones_indexer", "use_newznab", "newznab_enabled",
"use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay", "use_mininova", "use_waffles", "use_rutracker", "use_nzbsorg", "use_omgwtfnzbs", "use_kat", "use_piratebay", "use_oldpiratebay", "use_mininova", "use_waffles", "use_rutracker",
"use_whatcd", "preferred_bitrate_allow_lossless", "detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files", "rename_files", "use_whatcd", "preferred_bitrate_allow_lossless", "detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files", "rename_files",
"correct_metadata", "cleanup_files", "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics", "replace_existing_folders", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics", "replace_existing_folders", "keep_original_folder",
"file_underscores", "include_extras", "autowant_upcoming", "autowant_all", "autowant_manually_added", "keep_torrent_files", "music_encoder", "file_underscores", "include_extras", "autowant_upcoming", "autowant_all", "autowant_manually_added", "keep_torrent_files", "music_encoder",
"encoderlossless", "encoder_multicore", "delete_lossless_files", "growl_enabled", "growl_onsnatch", "prowl_enabled", "encoderlossless", "encoder_multicore", "delete_lossless_files", "growl_enabled", "growl_onsnatch", "prowl_enabled",
"prowl_onsnatch", "xbmc_enabled", "xbmc_update", "xbmc_notify", "lms_enabled", "plex_enabled", "plex_update", "plex_notify", "prowl_onsnatch", "xbmc_enabled", "xbmc_update", "xbmc_notify", "lms_enabled", "plex_enabled", "plex_update", "plex_notify",
@@ -1424,6 +1426,19 @@ class WebInterface(object):
logger.warn(msg) logger.warn(msg)
return msg return msg
@cherrypy.expose
def testPushover(self):
logger.info(u"Sending Pushover notification")
pushover = notifiers.PUSHOVER()
result = pushover.notify("hooray!", "This is a test")
return str(result)
@cherrypy.expose
def testPlex(self):
logger.info(u"Testing plex updates")
plex = notifiers.Plex()
plex.update()
class Artwork(object): class Artwork(object):
@cherrypy.expose @cherrypy.expose
def index(self): def index(self):