From 9db1d03aedfa946f9bf4edd709bbd27fd0bd787b Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 04:31:56 +0800 Subject: [PATCH 01/11] Took out utf-8 encoding in cherrypy webstart, merged pablos changes --- headphones/webstart.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/headphones/webstart.py b/headphones/webstart.py index 4b6c95f1..89f6a8d6 100644 --- a/headphones/webstart.py +++ b/headphones/webstart.py @@ -20,9 +20,7 @@ def initialize(options={}): conf = { '/': { - 'tools.staticdir.root': os.path.join(headphones.PROG_DIR, 'data'), - 'tools.encode.on': True, - 'tools.encode.encoding': 'utf-8' + 'tools.staticdir.root': os.path.join(headphones.PROG_DIR, 'data') }, '/interfaces':{ 'tools.staticdir.on': True, From 94aa377e43281b999c2119f8e195f0062ab511f9 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 05:46:00 +0800 Subject: [PATCH 02/11] Updated version.py --- headphones/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/version.py b/headphones/version.py index 0dda129e..b6c5af53 100644 --- a/headphones/version.py +++ b/headphones/version.py @@ -1 +1 @@ -HEADPHONES_VERSION = "master" \ No newline at end of file +HEADPHONES_VERSION = "develop" \ No newline at end of file From ec6779083f17124e2acee37039d8db00aa533490 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 00:45:24 -0700 Subject: [PATCH 03/11] Fixed https sab host bug --- headphones/sab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/sab.py b/headphones/sab.py index 8c20d717..6174aca6 100644 --- a/headphones/sab.py +++ b/headphones/sab.py @@ -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) From 50c2f173942c44e7b4d419bfdf76a935e4b76f68 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 00:46:49 -0700 Subject: [PATCH 04/11] Changed configobj to utf-8 --- Headphones.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Headphones.py b/Headphones.py index ba494c51..7f9139fe 100755 --- a/Headphones.py +++ b/Headphones.py @@ -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() From 678f919b7ceff6966e9da6b705bd5b97cd29be76 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 15:45:24 +0800 Subject: [PATCH 05/11] Fixed https sab host bug --- headphones/sab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/sab.py b/headphones/sab.py index 8c20d717..6174aca6 100644 --- a/headphones/sab.py +++ b/headphones/sab.py @@ -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) From b95e9eaf4c209db3f86d289b7972a5d37be08a81 Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 15:46:49 +0800 Subject: [PATCH 06/11] Changed configobj to utf-8 --- Headphones.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Headphones.py b/Headphones.py index ba494c51..7f9139fe 100755 --- a/Headphones.py +++ b/Headphones.py @@ -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() From a2cb87e141eb2fe30c23dbee7a1358b2854e7974 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Fri, 19 Aug 2011 13:50:43 -0300 Subject: [PATCH 07/11] changed bitrate config from text to combo box changed Sampling Frequency config from text to combo box Add options from final encode to config --- data/interfaces/default/config.html | 73 ++++++++++++++++++++++++++++- headphones/__init__.py | 4 +- headphones/webserve.py | 12 +++-- 3 files changed, 81 insertions(+), 8 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 1a5c113c..2752a69f 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -260,7 +260,7 @@

Re-Encoding Options:


-

Convert Lossless to mp3

+

Re-encode Postprocessed Albuns

Note: this option requires the lame or ffmpeg encoder

<% @@ -275,8 +275,77 @@ - Bitrate: kbps

+
+ <% + if config['encoderoutputformat'] == 'mp3': + mp3select = 'selected="selected"' + oggselect = '' + else: + mp3select = '' + oggselect = 'selected="selected"' + %> +

Format: +
+
+ <% + 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"' + %> +

Bitrate: +
+
+ <% + if config["samplingfrequency"] == 44100: + freq44100 = 'selected="selected"' + freq48000 = '' + else: + freq44100 = '' + freq48000 = 'selected="selected"' + %> +

Sampling: +
+

Advance Encode Options:


Path to Encoder:

diff --git a/headphones/__init__.py b/headphones/__init__.py index ab59ae4d..e46f8c0e 100755 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -444,8 +444,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 diff --git a/headphones/webserve.py b/headphones/webserve.py index 42db5f84..17c4f5aa 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -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() From 11e6484c931084d3b06b9227d0d19598a6b7bfd1 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Fri, 19 Aug 2011 14:36:47 -0300 Subject: [PATCH 08/11] Add m4a options to reencode --- data/interfaces/default/config.html | 35 +++++++++++++++++------------ headphones/encode.py | 10 +++++---- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 2752a69f..7d6ae975 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -269,7 +269,7 @@ ffmpegselect = '' else: lameselect = '' - ffmpegselect = 'selected="selected"' + ffmpegselect = 'selected="selected"' %>

Encoder: +

@@ -324,11 +331,11 @@ bitrate320select = 'selected="selected"' %>

Bitrate:

@@ -338,11 +345,11 @@ freq48000 = '' else: freq44100 = '' - freq48000 = 'selected="selected"' + freq48000 = 'selected="selected"' %>

Sampling:

diff --git a/headphones/encode.py b/headphones/encode.py index 77a435b4..27ec44b3 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -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) From 5b57d6294fef677bae30feb2d1fed6dce8583656 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Fri, 19 Aug 2011 15:30:29 -0300 Subject: [PATCH 09/11] Changed some laytou for config options for reencode --- data/interfaces/default/config.html | 24 ++++---- data/interfaces/remix/config.html | 86 +++++++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 7d6ae975..0d46458e 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -271,12 +271,11 @@ lameselect = '' ffmpegselect = 'selected="selected"' %> -

Encoder: -
-
+ <% if config['encoderoutputformat'] == 'ogg': oggselect = 'selected="selected"' @@ -291,12 +290,12 @@ m4aselect = '' mp3select = 'selected="selected"' %> -

Format: - -
+

+
<% if config["bitrate"] == 64: @@ -330,15 +329,14 @@ bitrate256select = '' bitrate320select = 'selected="selected"' %> -

Bitrate: + -
-
+ <% if config["samplingfrequency"] == 44100: freq44100 = 'selected="selected"' @@ -347,10 +345,10 @@ freq44100 = '' freq48000 = 'selected="selected"' %> -

Sampling: - +



Advance Encode Options:

@@ -363,5 +361,5 @@


(Web Interface changes require a restart to take effect)

- +  diff --git a/data/interfaces/remix/config.html b/data/interfaces/remix/config.html index 07763d08..f9aab2cc 100644 --- a/data/interfaces/remix/config.html +++ b/data/interfaces/remix/config.html @@ -260,8 +260,8 @@

Re-Encoding Options:


-

Convert Lossless to mp3

- Note: this option requires the lame or ffdshow encoder +

Re-encode Postprocessed Albuns

+ Note: this option requires the lame or ffmpeg encoder

<% if config['encoder'] == 'lame': @@ -269,14 +269,88 @@ ffmpegselect = '' else: lameselect = '' - ffmpegselect = 'selected="selected"' + ffmpegselect = 'selected="selected"' %> -

Encoder: - Bitrate: kbps
+ + <% + 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:

+
+ <% + 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"' + %> +

Bitrate: + + <% + if config["samplingfrequency"] == 44100: + freq44100 = 'selected="selected"' + freq48000 = '' + else: + freq44100 = '' + freq48000 = 'selected="selected"' + %> + Sampling:

+
+

Advance Encode Options:


Path to Encoder:

@@ -288,4 +362,4 @@


(Web Interface changes require a restart to take effect) - + \ No newline at end of file From b869f4a0176adb885ed59cb5bae7eff274e701bd Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 13:51:57 -0700 Subject: [PATCH 10/11] Cleaned up some config stuff, changed version back to master, added try/except clause to github check --- data/interfaces/default/config.html | 76 ++++++++--------------------- headphones/__init__.py | 5 +- headphones/version.py | 2 +- 3 files changed, 25 insertions(+), 58 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 0d46458e..31d0f4b4 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -260,7 +260,7 @@

Re-Encoding Options:


-

Re-encode Postprocessed Albuns

+

Re-encode downloads during postprocessing

Note: this option requires the lame or ffmpeg encoder

<% @@ -275,66 +275,30 @@ - - <% - 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:
- <% - 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"' - %>

Bitrate: <% diff --git a/headphones/__init__.py b/headphones/__init__.py index e46f8c0e..30b6917f 100755 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -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 diff --git a/headphones/version.py b/headphones/version.py index b6c5af53..0dda129e 100644 --- a/headphones/version.py +++ b/headphones/version.py @@ -1 +1 @@ -HEADPHONES_VERSION = "develop" \ No newline at end of file +HEADPHONES_VERSION = "master" \ No newline at end of file From 1d362bcd5eeccdd3e8f86ecf98b5fcad0128431f Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 19 Aug 2011 15:32:30 -0700 Subject: [PATCH 11/11] Unicode changes --- headphones/librarysync.py | 15 +++++++-------- headphones/postprocessor.py | 9 +++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 990c2d3c..81808890 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -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 diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 7a779e6e..10db91bd 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -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: