mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-11 06:09:29 +01:00
Merge branch 'unicode' into develop
This commit is contained in:
@@ -84,7 +84,7 @@ def main():
|
||||
# Put the database in the DATA_DIR
|
||||
headphones.DB_FILE = os.path.join(headphones.DATA_DIR, 'headphones.db')
|
||||
|
||||
headphones.CFG = ConfigObj(headphones.CONFIG_FILE)
|
||||
headphones.CFG = ConfigObj(headphones.CONFIG_FILE, encoding='utf-8')
|
||||
|
||||
# Read config & start logging
|
||||
headphones.initialize()
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
<td>
|
||||
<h2>Re-Encoding Options:</h2>
|
||||
<br>
|
||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/>Convert Lossless to mp3</h3>
|
||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/> Re-encode downloads during postprocessing</h3>
|
||||
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
||||
<br><br>
|
||||
<%
|
||||
@@ -269,14 +269,52 @@
|
||||
ffmpegselect = ''
|
||||
else:
|
||||
lameselect = ''
|
||||
ffmpegselect = 'selected="selected"'
|
||||
ffmpegselect = 'selected="selected"'
|
||||
%>
|
||||
<h3>Encoder: <select name="encoder">
|
||||
<h4>Encoder: <select name="encoder">
|
||||
<option value="lame" ${lameselect}>lame</option>
|
||||
<option value="ffmpeg" ${ffmpegselect}>ffmpeg</option>
|
||||
</select>
|
||||
Bitrate: <input type="text" name="bitrate" value="${config['bitrate']}" size="3" maxlength="5" />kbps <br>
|
||||
|
||||
Format: <select name="encoderoutputformat">
|
||||
%for x in ['mp3', 'ogg', 'm4a']:
|
||||
<%
|
||||
if config['encoderoutputformat'] == x:
|
||||
outputselect = 'selected'
|
||||
else:
|
||||
outputselect = ''
|
||||
%>
|
||||
<option value=${x} ${outputselect}>${x}</option>
|
||||
%endfor
|
||||
</select></h4>
|
||||
|
||||
<br>
|
||||
<h4>Bitrate: <select name="bitrate">
|
||||
%for x in [64, 128, 192, 256, 320]:
|
||||
<%
|
||||
if config["bitrate"] == x:
|
||||
bitrateselected = "selected"
|
||||
else:
|
||||
bitrateselected = ''
|
||||
%>
|
||||
<option value=${x} ${bitrateselected}> ${x} kbps</option>
|
||||
%endfor
|
||||
</select>
|
||||
|
||||
<%
|
||||
if config["samplingfrequency"] == 44100:
|
||||
freq44100 = 'selected="selected"'
|
||||
freq48000 = ''
|
||||
else:
|
||||
freq44100 = ''
|
||||
freq48000 = 'selected="selected"'
|
||||
%>
|
||||
Sampling: <select name="samplingfrequency">
|
||||
<option value=44100 ${freq44100}>44.1 kHz</option>
|
||||
<option value=48000 ${freq48000}>48.0 kHz</option>
|
||||
</select></h4>
|
||||
<br>
|
||||
<br>
|
||||
<h3>Advance Encode Options:</h3><input type="text" name="advancedencoder" value="${config['advancedencoder']}" size="43">
|
||||
<br>
|
||||
<h3>Path to Encoder:</h3><input type="text" name="encoderfolder" value="${config['encoderfolder']}" size="43">
|
||||
@@ -287,5 +325,5 @@
|
||||
|
||||
<p class="center"><input type="submit" value="Save Changes"><br>
|
||||
(Web Interface changes require a restart to take effect)</h3>
|
||||
</form>
|
||||
</form>
|
||||
</%def>
|
||||
|
||||
@@ -260,8 +260,8 @@
|
||||
<td>
|
||||
<h2>Re-Encoding Options:</h2>
|
||||
<br>
|
||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/>Convert Lossless to mp3</h3>
|
||||
<i class="smalltext">Note: this option requires the lame or ffdshow encoder</i>
|
||||
<h3><input type="checkbox" name="encode" value="1" ${config['encode']}/>Re-encode Postprocessed Albuns</h3>
|
||||
<i class="smalltext">Note: this option requires the lame or ffmpeg encoder</i>
|
||||
<br><br>
|
||||
<%
|
||||
if config['encoder'] == 'lame':
|
||||
@@ -269,14 +269,88 @@
|
||||
ffmpegselect = ''
|
||||
else:
|
||||
lameselect = ''
|
||||
ffmpegselect = 'selected="selected"'
|
||||
ffmpegselect = 'selected="selected"'
|
||||
%>
|
||||
<h3>Encoder: <select name="encoder">
|
||||
<h4>Encoder: <select name="encoder">
|
||||
<option value="lame" ${lameselect}>lame</option>
|
||||
<option value="ffmpeg" ${ffmpegselect}>ffmpeg</option>
|
||||
</select>
|
||||
Bitrate: <input type="text" name="bitrate" value="${config['bitrate']}" size="3" maxlength="5" />kbps <br>
|
||||
|
||||
<%
|
||||
if config['encoderoutputformat'] == 'ogg':
|
||||
oggselect = 'selected="selected"'
|
||||
mp3select = ''
|
||||
m4aselect = ''
|
||||
elif config['encoderoutputformat'] == 'm4a':
|
||||
oggselect = ''
|
||||
m4aselect = 'selected="selected"'
|
||||
mp3select = ''
|
||||
else:
|
||||
oggselect = ''
|
||||
m4aselect = ''
|
||||
mp3select = 'selected="selected"'
|
||||
%>
|
||||
Format: <select name="encoderoutputformat">
|
||||
<option value="mp3" ${mp3select}>mp3</option>
|
||||
<option value="ogg" ${oggselect}>ogg</option>
|
||||
<option value="m4a" ${m4aselect}>m4a</option>
|
||||
</select></h4>
|
||||
|
||||
<br>
|
||||
<%
|
||||
if config["bitrate"] == 64:
|
||||
bitrate64select = 'selected="selected"'
|
||||
bitrate128select = ''
|
||||
bitrate192select = ''
|
||||
bitrate256select = ''
|
||||
bitrate320select = ''
|
||||
elif config["bitrate"] == 128:
|
||||
bitrate64select = ''
|
||||
bitrate128select = 'selected="selected"'
|
||||
bitrate192select = ''
|
||||
bitrate256select = ''
|
||||
bitrate320select = ''
|
||||
elif config["bitrate"] == 192:
|
||||
bitrate64select = ''
|
||||
bitrate128select = ''
|
||||
bitrate192select = 'selected="selected"'
|
||||
bitrate256select = ''
|
||||
bitrate320select = ''
|
||||
elif config["bitrate"] == 256:
|
||||
bitrate64select = ''
|
||||
bitrate128select = ''
|
||||
bitrate192select = ''
|
||||
bitrate256select = 'selected="selected"'
|
||||
bitrate320select = ''
|
||||
else:
|
||||
bitrate64select = ''
|
||||
bitrate128select = ''
|
||||
bitrate192select = ''
|
||||
bitrate256select = ''
|
||||
bitrate320select = 'selected="selected"'
|
||||
%>
|
||||
<h4>Bitrate: <select name="bitrate">
|
||||
<option value=64 ${bitrate64select}> 64 kbps</option>
|
||||
<option value=128 ${bitrate128select}>128 kbps</option>
|
||||
<option value=192 ${bitrate192select}>192 kbps</option>
|
||||
<option value=256 ${bitrate256select}>256 kbps</option>
|
||||
<option value=320 ${bitrate320select}>320 kbps</option>
|
||||
</select>
|
||||
|
||||
<%
|
||||
if config["samplingfrequency"] == 44100:
|
||||
freq44100 = 'selected="selected"'
|
||||
freq48000 = ''
|
||||
else:
|
||||
freq44100 = ''
|
||||
freq48000 = 'selected="selected"'
|
||||
%>
|
||||
Sampling: <select name="samplingfrequency">
|
||||
<option value=44100 ${freq44100}>44.1 kHz</option>
|
||||
<option value=48000 ${freq48000}>48.0 kHz</option>
|
||||
</select></h4>
|
||||
<br>
|
||||
<br>
|
||||
<h3>Advance Encode Options:</h3><input type="text" name="advancedencoder" value="${config['advancedencoder']}" size="43">
|
||||
<br>
|
||||
<h3>Path to Encoder:</h3><input type="text" name="encoderfolder" value="${config['encoderfolder']}" size="43">
|
||||
@@ -288,4 +362,4 @@
|
||||
<p class="center"><input type="submit" value="Save Changes"><br>
|
||||
(Web Interface changes require a restart to take effect)</h3>
|
||||
</form>
|
||||
</%def>
|
||||
</%def>
|
||||
@@ -308,7 +308,10 @@ def initialize():
|
||||
CURRENT_VERSION = versioncheck.getVersion()
|
||||
|
||||
# Check for new versions
|
||||
LATEST_VERSION = versioncheck.checkGithub()
|
||||
try:
|
||||
LATEST_VERSION = versioncheck.checkGithub()
|
||||
except:
|
||||
LATEST_VERSION = CURRENT_VERSION
|
||||
|
||||
__INITIALIZED__ = True
|
||||
return True
|
||||
@@ -444,8 +447,8 @@ def config_write():
|
||||
|
||||
new_config['General']['encode'] = int(ENCODE)
|
||||
new_config['General']['encoder'] = ENCODER
|
||||
new_config['General']['bitrate'] = BITRATE
|
||||
new_config['General']['samplingfrequency'] = SAMPLINGFREQUENCY
|
||||
new_config['General']['bitrate'] = int(BITRATE)
|
||||
new_config['General']['samplingfrequency'] = int(SAMPLINGFREQUENCY)
|
||||
new_config['General']['encoderfolder'] = ENCODERFOLDER
|
||||
new_config['General']['advancedencoder'] = ADVANCEDENCODER
|
||||
new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT
|
||||
|
||||
@@ -55,8 +55,8 @@ def encode(albumPath):
|
||||
logger.warn('Can not reencode .ogg music "%s"' % (music))
|
||||
else:
|
||||
command(encoder,music,musicTempFiles[i],albumPath)
|
||||
elif (headphones.ENCODEROUTPUTFORMAT=='mp3'):
|
||||
if (music.endswith('.mp3') and (infoMusic.bitrate/1000<=headphones.BITRATE)):
|
||||
elif (headphones.ENCODEROUTPUTFORMAT=='mp3' or headphones.ENCODEROUTPUTFORMAT=='m4a'):
|
||||
if (music.endswith('.'+headphones.ENCODEROUTPUTFORMAT) and (infoMusic.bitrate/1000<=headphones.BITRATE)):
|
||||
logger.warn('Music "%s" has bitrate<="%skbit" will not be reencoded' % (music,headphones.BITRATE))
|
||||
else:
|
||||
command(encoder,music,musicTempFiles[i],albumPath)
|
||||
@@ -83,8 +83,10 @@ def command(encoder,musicSource,musicDest,albumPath):
|
||||
cmd=encoder+ ' -i'
|
||||
cmd=cmd+ ' "' + musicSource + '"'
|
||||
if headphones.ENCODEROUTPUTFORMAT=='ogg':
|
||||
cmd=cmd+ ' -acodec vorbis -strict experimental'
|
||||
cmd=cmd+ ' -ac 2 -map_metadata 0:0,s0 -vn -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k'
|
||||
cmd=cmd+ ' -acodec libvorbis'
|
||||
if headphones.ENCODEROUTPUTFORMAT=='m4a':
|
||||
cmd=cmd+ ' -strict experimental'
|
||||
cmd=cmd+ ' -y -ac 2 -map_metadata 0:0,s0 -vn -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k'
|
||||
cmd=cmd+ ' ' + headphones.ADVANCEDENCODER
|
||||
cmd=cmd+ ' "' + musicDest + '"'
|
||||
return_code = call(cmd, shell=True)
|
||||
|
||||
@@ -8,6 +8,13 @@ from headphones import db, logger, helpers, importer
|
||||
|
||||
def libraryScan(dir=None):
|
||||
|
||||
# Clean up bad filepaths
|
||||
tracks = myDB.select('SELECT Location, TrackID from tracks WHERE Location IS NOT NULL')
|
||||
|
||||
for track in tracks:
|
||||
if not os.path.isfile(track['Location']):
|
||||
myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [None, track['TrackID']])
|
||||
|
||||
if not dir:
|
||||
dir = headphones.MUSIC_DIR
|
||||
|
||||
@@ -162,14 +169,6 @@ def libraryScan(dir=None):
|
||||
continue
|
||||
|
||||
logger.info('Done checking empty filepaths')
|
||||
|
||||
# Clean up bad filepaths
|
||||
tracks = myDB.select('SELECT Location, TrackID from tracks WHERE Location IS NOT NULL')
|
||||
|
||||
for track in tracks:
|
||||
if not os.path.isfile(track['Location']):
|
||||
myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [None, track['TrackID']])
|
||||
|
||||
logger.info('Done syncing library with directory: %s' % dir)
|
||||
|
||||
# Clean up the new artist list
|
||||
|
||||
@@ -110,6 +110,11 @@ def verify(albumid, albumpath):
|
||||
release = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
|
||||
tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [albumid])
|
||||
|
||||
try:
|
||||
albumpath = str(albumpath)
|
||||
except UnicodeEncodeError:
|
||||
albumpath = unicode(albumpath).encode('unicode_escape')
|
||||
|
||||
downloaded_track_list = []
|
||||
|
||||
for r,d,f in os.walk(albumpath):
|
||||
@@ -324,7 +329,7 @@ def moveFiles(albumpath, release, tracks):
|
||||
folder = newfolder
|
||||
break
|
||||
|
||||
logger.info('Moving files from %s to %s' % (albumpath, destination_path))
|
||||
logger.info('Moving files from %s to %s' % (albumpath, destination_path.encode('utf-8')))
|
||||
|
||||
try:
|
||||
os.makedirs(destination_path)
|
||||
@@ -416,7 +421,7 @@ def renameFiles(albumpath, downloaded_track_list, release):
|
||||
|
||||
new_file = os.path.join(albumpath, new_file_name)
|
||||
|
||||
logger.debug('Renaming %s ---> %s' % (downloaded_track, new_file_name))
|
||||
logger.debug('Renaming %s ---> %s' % (downloaded_track, new_file_name.encode('utf-8')))
|
||||
try:
|
||||
os.rename(downloaded_track, new_file)
|
||||
except Exception, e:
|
||||
|
||||
@@ -65,7 +65,7 @@ def sendNZB(nzb):
|
||||
params['mode'] = 'addfile'
|
||||
multiPartParams = {"nzbfile": (nzb.name+".nzb", nzb.extraInfo[0])}
|
||||
|
||||
if not headphones.SAB_HOST.startswith('http://') or headphones.SAB_HOST.startswith('https://'):
|
||||
if not headphones.SAB_HOST.startswith('http'):
|
||||
headphones.SAB_HOST = 'http://' + headphones.SAB_HOST
|
||||
|
||||
url = headphones.SAB_HOST + "/" + "api?" + urllib.urlencode(params)
|
||||
|
||||
@@ -352,9 +352,11 @@ class WebInterface(object):
|
||||
"interface_list" : interface_list,
|
||||
"encode": checked(headphones.ENCODE),
|
||||
"encoder": headphones.ENCODER,
|
||||
"bitrate": headphones.BITRATE,
|
||||
"bitrate": int(headphones.BITRATE),
|
||||
"encoderfolder": headphones.ENCODERFOLDER,
|
||||
"advancedencoder": headphones.ADVANCEDENCODER
|
||||
"advancedencoder": headphones.ADVANCEDENCODER,
|
||||
"encoderoutputformat": headphones.ENCODEROUTPUTFORMAT,
|
||||
"samplingfrequency": int(headphones.SAMPLINGFREQUENCY)
|
||||
}
|
||||
return serve_template(templatename="config.html", title="Settings", config=config)
|
||||
config.exposed = True
|
||||
@@ -365,7 +367,7 @@ class WebInterface(object):
|
||||
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
||||
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
||||
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
|
||||
encode=0, encoder=None, bitrate=None, encoderfolder=None, advancedencoder=None):
|
||||
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
headphones.HTTP_PORT = http_port
|
||||
@@ -410,9 +412,11 @@ class WebInterface(object):
|
||||
headphones.LOG_DIR = log_dir
|
||||
headphones.ENCODE = encode
|
||||
headphones.ENCODER = encoder
|
||||
headphones.BITRATE = bitrate
|
||||
headphones.BITRATE = int(bitrate)
|
||||
headphones.SAMPLINGFREQUENCY = int(samplingfrequency)
|
||||
headphones.ENCODERFOLDER = encoderfolder
|
||||
headphones.ADVANCEDENCODER = advancedencoder
|
||||
headphones.ENCODEROUTPUTFORMAT = encoderoutputformat
|
||||
|
||||
headphones.config_write()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user