From 03e07db9d54d5f8a84c077b67dab537c1933dba0 Mon Sep 17 00:00:00 2001 From: Remy Date: Tue, 23 Aug 2011 11:48:48 +0800 Subject: [PATCH 1/8] Fixed unicode errors on track matching --- headphones/librarysync.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/headphones/librarysync.py b/headphones/librarysync.py index 825ec8b8..81a7da4d 100644 --- a/headphones/librarysync.py +++ b/headphones/librarysync.py @@ -151,16 +151,18 @@ def libraryScan(dir=None): new_file_name = new_file_name.replace('?','_').replace(':', '_') - full_path_to_file = os.path.normpath(os.path.join(headphones.MUSIC_DIR, folder, new_file_name)).encode(headphones.SYS_ENCODING) + full_path_to_file = os.path.normpath(os.path.join(headphones.MUSIC_DIR, folder, new_file_name)).encode(headphones.SYS_ENCODING, 'replace') match = glob.glob(full_path_to_file) if match: logger.info('Found a match: %s. Writing MBID to metadata' % match[0]) + + unipath = unicode(match[0], headphones.SYS_ENCODING, errors='replace') - myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [match[0], track['TrackID']]) - myDB.action('DELETE from have WHERE Location=?', [match[0]]) + myDB.action('UPDATE tracks SET Location=? WHERE TrackID=?', [unipath, track['TrackID']]) + myDB.action('DELETE from have WHERE Location=?', [unipath]) # Try to insert the appropriate track id so we don't have to keep doing this try: From 216d3e9e228fa69061fb7d249feed5eb3887ed5a Mon Sep 17 00:00:00 2001 From: Antoine Bertin Date: Mon, 22 Aug 2011 02:57:19 +0800 Subject: [PATCH 2/8] Add more control over verbosity --- Headphones.py | 11 +++++++---- headphones/__init__.py | 8 ++++---- headphones/logger.py | 12 ++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Headphones.py b/Headphones.py index 7f9139fe..65c7d8fc 100644 --- a/Headphones.py +++ b/Headphones.py @@ -41,6 +41,7 @@ def main(): # Set up and gather command line arguments parser = argparse.ArgumentParser(description='Music add-on for SABnzbd+') + parser.add_argument('-v', '--verbose', action='store_true', help='Increase console logging verbosity') parser.add_argument('-q', '--quiet', action='store_true', help='Turn off console logging') parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon') parser.add_argument('-p', '--port', type=int, help='Force Headphones to run on a specified port') @@ -50,13 +51,15 @@ def main(): parser.add_argument('--pidfile', help='Create a pid file (only relevant when running as a daemon)') args = parser.parse_args() - - if args.quiet: - headphones.QUIET=True + + if args.verbose: + headphones.VERBOSE = 2 + elif args.quiet: + headphones.VERBOSE = 0 if args.daemon: headphones.DAEMON=True - headphones.QUIET=True + headphones.VERBOSE = 0 if args.pidfile : headphones.PIDFILE = args.pidfile diff --git a/headphones/__init__.py b/headphones/__init__.py index c2a50ece..60637241 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -22,7 +22,7 @@ SIGNAL = None SYS_ENCODING = None -QUIET = False +VERBOSE = 1 DAEMON = False PIDFILE= None @@ -173,7 +173,7 @@ def initialize(): with INIT_LOCK: - global __INITIALIZED__, FULL_PATH, PROG_DIR, QUIET, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \ + global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \ HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \ CURRENT_VERSION, LATEST_VERSION, MUSIC_DIR, DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \ ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, \ @@ -280,11 +280,11 @@ def initialize(): try: os.makedirs(LOG_DIR) except OSError: - if not QUIET: + if VERBOSE: print 'Unable to create the log directory. Logging to screen only.' # Start the logger, silence console logging if we need to - logger.headphones_log.initLogger(quiet=QUIET) + logger.headphones_log.initLogger(verbose=VERBOSE) # Update some old config code: if FOLDER_FORMAT == '%artist/%album/%track': diff --git a/headphones/logger.py b/headphones/logger.py index 9df46990..97c435bc 100644 --- a/headphones/logger.py +++ b/headphones/logger.py @@ -20,7 +20,7 @@ class RotatingLogger(object): self.max_files = max_files - def initLogger(self, quiet=False): + def initLogger(self, verbose=1): l = logging.getLogger('headphones') l.setLevel(logging.DEBUG) @@ -35,13 +35,13 @@ class RotatingLogger(object): filehandler.setFormatter(fileformatter) l.addHandler(filehandler) - if not quiet: - + if verbose: consolehandler = logging.StreamHandler() - consolehandler.setLevel(logging.INFO) - + if verbose == 1: + consolehandler.setLevel(logging.INFO) + if verbose == 2: + consolehandler.setLevel(logging.DEBUG) consoleformatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(message)s', '%d-%b-%Y %H:%M:%S') - consolehandler.setFormatter(consoleformatter) l.addHandler(consolehandler) From 0bf10f0d05b12ce26b7aec12299ce5e0e01bb7b1 Mon Sep 17 00:00:00 2001 From: Remy Date: Wed, 24 Aug 2011 06:13:47 +0800 Subject: [PATCH 3/8] Removed empty tokens --- headphones/searcher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/headphones/searcher.py b/headphones/searcher.py index 90e5b044..84979a0e 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -448,6 +448,8 @@ def verifyresult(title, artistterm, term): #another attempt to weed out substrings. We don't want "Vol III" when we were looking for "Vol II" tokens = re.split('\W', term, re.IGNORECASE | re.UNICODE) for token in tokens: + if not token: + continue if token == 'Various' or token == 'Artists' or token == 'VA': continue if not re.search('(?:\W|^)+' + token + '(?:\W|$)+', title, re.IGNORECASE | re.UNICODE): From b2b50c6e966770d7f4d8291fe9c009fa5cf44dfc Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Thu, 25 Aug 2011 09:34:58 -0300 Subject: [PATCH 4/8] - Add vbr encoder --- data/interfaces/default/config.html | 25 +++++++++++++++++++++++++ data/interfaces/remix/config.html | 25 +++++++++++++++++++++++++ headphones/__init__.py | 2 +- headphones/encode.py | 14 ++++++++++++-- headphones/webserve.py | 8 ++++++-- 5 files changed, 69 insertions(+), 5 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index fe789c72..9742cf3e 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -289,6 +289,31 @@ %endfor +
+

VBR/CBR: + + Quality:

+

Bitrate:

+
+

VBR/CBR: + + Quality:

+

Bitrate: Re-encode downloads during postprocessing

Note: this option requires the lame or ffmpeg encoder +
+

Re-encode only LossLess format (.flac)



<% if config['encoder'] == 'lame': diff --git a/data/interfaces/remix/config.html b/data/interfaces/remix/config.html index 9742cf3e..8674f6ab 100644 --- a/data/interfaces/remix/config.html +++ b/data/interfaces/remix/config.html @@ -263,6 +263,8 @@

Re-encode downloads during postprocessing

Note: this option requires the lame or ffmpeg encoder +
+

Re-encode only LossLess format (.flac)



<% if config['encoder'] == 'lame': diff --git a/headphones/__init__.py b/headphones/__init__.py index f888ec26..eeec7ed3 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -122,6 +122,7 @@ ADVANCEDENCODER = None ENCODEROUTPUTFORMAT = None ENCODERQUALITY = None ENCODERVBRCBR = None +ENCODERLOSSLESS = True def CheckSection(sec): """ Check if INI section exists, if not create it """ @@ -181,7 +182,8 @@ def initialize(): LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \ NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \ - ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRVBR + ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRVBR, \ + ENCODERLOSSLESS if __INITIALIZED__: return False @@ -272,6 +274,7 @@ def initialize(): ENCODEROUTPUTFORMAT = check_setting_str(CFG, 'General', 'encoderoutputformat', 'mp3') ENCODERQUALITY = check_setting_int(CFG, 'General', 'vorbisquality', 5) ENCODERVBRCBR = check_setting_str(CFG, 'General', 'encodervbrcbr', 'cbr') + ENCODERLOSSLESS = bool(check_setting_int(CFG, 'General', 'encoderlossless', 1)) if not LOG_DIR: LOG_DIR = os.path.join(DATA_DIR, 'logs') @@ -459,6 +462,7 @@ def config_write(): new_config['General']['encoderoutputformat'] = ENCODEROUTPUTFORMAT new_config['General']['encoderquality'] = ENCODERQUALITY new_config['General']['encodervbrcbr'] = ENCODERVBRCBR + new_config['General']['encoderlossless'] = ENCODERLOSSLESS new_config.write() diff --git a/headphones/encode.py b/headphones/encode.py index d8cd032f..fa530ac3 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -31,10 +31,18 @@ def encode(albumPath): for r,d,f in os.walk(albumPath): for music in f: if any(music.endswith('.' + x) for x in headphones.MEDIA_FORMATS): - musicFiles.append(os.path.join(r, music)) - musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING) - musicTempFiles.append(os.path.join(tempDirEncode, musicTemp)) - + if (headphones.ENCODERLOSSLESS): + if (music.endswith('.flac')): + musicFiles.append(os.path.join(r, music)) + musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING) + musicTempFiles.append(os.path.join(tempDirEncode, musicTemp)) + else: + logger.warn('Music "%s" is already encoded' % (music)) + else: + musicFiles.append(os.path.join(r, music)) + musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING) + musicTempFiles.append(os.path.join(tempDirEncode, musicTemp)) + if headphones.ENCODER=='lame': encoder=os.path.join(headphones.ENCODERFOLDER,'lame') elif headphones.ENCODER=='ffmpeg': @@ -42,7 +50,6 @@ def encode(albumPath): i=0 for music in musicFiles: infoMusic=MediaFile(music) - if headphones.ENCODER == 'lame': if not any(music.endswith('.' +headphones.ENCODEROUTPUTFORMAT) for x in ["mp3", "wav"]): logger.warn('Lame cant encode "%s" format for "%s", use ffmpeg' % (os.path.splitext(music)[1],music)) @@ -65,8 +72,8 @@ def encode(albumPath): else: command(encoder,music,musicTempFiles[i],albumPath) ifencoded=1 - i=i+1 - + i=i+1 + shutil.rmtree(tempDirEncode) time.sleep(1) for r,d,f in os.walk(albumPath): @@ -76,8 +83,6 @@ def encode(albumPath): if ifencoded==0: logger.info('Encoding for folder "%s" is not needed' % (albumPath)) - else: - logger.info('Encoding for folder "%s" is completed in %s' % (albumPath,getTimeEncode(startAlbumTime))) return musicFinalFiles diff --git a/headphones/webserve.py b/headphones/webserve.py index 9466cb99..7ec86da6 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -359,7 +359,8 @@ class WebInterface(object): "encoderoutputformat": headphones.ENCODEROUTPUTFORMAT, "samplingfrequency": int(headphones.SAMPLINGFREQUENCY), "encodervbrcbr": (headphones.ENCODERVBRCBR), - "encoderquality": int(headphones.ENCODERQUALITY) + "encoderquality": int(headphones.ENCODERQUALITY), + "encoderlossless": checked(headphones.ENCODERLOSSLESS) } return serve_template(templatename="config.html", title="Settings", config=config) config.exposed = True @@ -370,7 +371,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, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None, - encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None): + encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0): headphones.HTTP_HOST = http_host headphones.HTTP_PORT = http_port @@ -423,6 +424,7 @@ class WebInterface(object): headphones.ENCODEROUTPUTFORMAT = encoderoutputformat headphones.ENCODERVBRCBR = encodervbrcbr headphones.ENCODERQUALITY = int(encoderquality) + headphones.ENCODERLOSSLESS = encoderlossless headphones.config_write() From f85d78c45293bfaad6aff96c439009eb9112acc0 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Thu, 25 Aug 2011 11:33:39 -0300 Subject: [PATCH 6/8] Typo error for command of quality in ffmpeg --- headphones/encode.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/headphones/encode.py b/headphones/encode.py index fa530ac3..c02ceb58 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -115,11 +115,11 @@ def command(encoder,musicSource,musicDest,albumPath): cmd=cmd+ ' -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k' elif headphones.ENCODERVBRCBR=='vbr': if (ENCODERQUALITY>=0 and ENCODERQUALITY<=9): - cmd=cmd+' -V'+str(ENCODERQUALITY) + cmd=cmd+' -aq '+str(ENCODERQUALITY) elif (ENCODERQUALITY<0): - cmd=cmd+' -V0' + cmd=cmd+' -aq 0' elif (ENCODERQUALITY>9): - cmd=cmd+' -V9' + cmd=cmd+' -aq 9' cmd=cmd+ ' -y -ac 2 -map_metadata 0:0,s0 -vn' cmd=cmd+ ' ' + headphones.ADVANCEDENCODER cmd=cmd+ ' "' + musicDest + '"' From f23fd3b09e3c6cce259a10dadd1bae3846085db6 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Thu, 25 Aug 2011 14:28:54 -0300 Subject: [PATCH 7/8] - If using the advanced encoding functions, it disable the audio properties. --- data/interfaces/default/config.html | 10 ++++- data/interfaces/remix/config.html | 10 +++-- headphones/encode.py | 60 ++++++++++++++++------------- 3 files changed, 49 insertions(+), 31 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index cddd77e4..a3818110 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -290,7 +290,9 @@ %endfor - +
+ +

Audio Properties:


VBR/CBR:



-

Advance Encode Options:

+

Advance Encode Options:

+

+ (ignores audio properties) +

+

Path to Encoder:

diff --git a/data/interfaces/remix/config.html b/data/interfaces/remix/config.html index 8674f6ab..04c99637 100644 --- a/data/interfaces/remix/config.html +++ b/data/interfaces/remix/config.html @@ -290,7 +290,8 @@ %endfor - +
+

Audio Properties:


VBR/CBR:



-

Advance Encode Options:

-
+

Advance Encode Options:

+

+ (ignores audio properties) +

+

Path to Encoder:

diff --git a/headphones/encode.py b/headphones/encode.py index c02ceb58..12a4b6d7 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -91,38 +91,46 @@ def command(encoder,musicSource,musicDest,albumPath): cmd='' startMusicTime=time.clock() if headphones.ENCODER == 'lame': - cmd=encoder + ' -h' - if headphones.ENCODERVBRCBR=='cbr': - cmd=cmd+ ' --resample ' + str(headphones.SAMPLINGFREQUENCY) + ' -b ' + str(headphones.BITRATE) - elif headphones.ENCODERVBRCBR=='vbr': - if (ENCODERQUALITY>=0 and ENCODERQUALITY<=9): - cmd=cmd+' -V'+str(ENCODERQUALITY) - elif (ENCODERQUALITY<0): - cmd=cmd+' -V0' - elif (ENCODERQUALITY>9): - cmd=cmd+' -V9' - cmd=cmd+ ' ' + headphones.ADVANCEDENCODER + if headphones.ADVANCEDENCODER =='': + cmd=encoder + ' -h' + if headphones.ENCODERVBRCBR=='cbr': + cmd=cmd+ ' --resample ' + str(headphones.SAMPLINGFREQUENCY) + ' -b ' + str(headphones.BITRATE) + elif headphones.ENCODERVBRCBR=='vbr': + if (ENCODERQUALITY>=0 and ENCODERQUALITY<=9): + cmd=cmd+' -V'+str(ENCODERQUALITY) + elif (ENCODERQUALITY<0): + cmd=cmd+' -V0' + elif (ENCODERQUALITY>9): + cmd=cmd+' -V9' + cmd=cmd+ ' ' + headphones.ADVANCEDENCODER + else: + cmd=cmd+' '+ headphones.ADVANCEDENCODER cmd=cmd+ ' "' + musicSource + '"' cmd=cmd+ ' "' + musicDest +'"' + elif headphones.ENCODER == 'ffmpeg': cmd=encoder+ ' -i' cmd=cmd+ ' "' + musicSource + '"' - if headphones.ENCODEROUTPUTFORMAT=='ogg': - cmd=cmd+ ' -acodec libvorbis' - if headphones.ENCODEROUTPUTFORMAT=='m4a': - cmd=cmd+ ' -strict experimental' - if headphones.ENCODERVBRCBR=='cbr': - cmd=cmd+ ' -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k' - elif headphones.ENCODERVBRCBR=='vbr': - if (ENCODERQUALITY>=0 and ENCODERQUALITY<=9): - cmd=cmd+' -aq '+str(ENCODERQUALITY) - elif (ENCODERQUALITY<0): - cmd=cmd+' -aq 0' - elif (ENCODERQUALITY>9): - cmd=cmd+' -aq 9' - cmd=cmd+ ' -y -ac 2 -map_metadata 0:0,s0 -vn' - cmd=cmd+ ' ' + headphones.ADVANCEDENCODER + if headphones.ADVANCEDENCODER =='': + if headphones.ENCODEROUTPUTFORMAT=='ogg': + cmd=cmd+ ' -acodec libvorbis' + if headphones.ENCODEROUTPUTFORMAT=='m4a': + cmd=cmd+ ' -strict experimental' + if headphones.ENCODERVBRCBR=='cbr': + cmd=cmd+ ' -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k' + elif headphones.ENCODERVBRCBR=='vbr': + if (ENCODERQUALITY>=0 and ENCODERQUALITY<=9): + cmd=cmd+' -aq '+str(ENCODERQUALITY) + elif (ENCODERQUALITY<0): + cmd=cmd+' -aq 0' + elif (ENCODERQUALITY>9): + cmd=cmd+' -aq 9' + cmd=cmd+ ' -y -ac 2 -map_metadata 0:0,s0 -vn' + else: + cmd=cmd+' '+ headphones.ADVANCEDENCODER cmd=cmd+ ' "' + musicDest + '"' + print cmd + time.sleep(10) return_code = call(cmd, shell=True) if (return_code==0) and (os.path.exists(musicDest)): os.remove(musicSource) From 6e03ade3dc66f08e5382c8776d8fdda565de6ff5 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Thu, 25 Aug 2011 15:33:29 -0300 Subject: [PATCH 8/8] Fix when extension has any letter in upcase. --- headphones/encode.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/headphones/encode.py b/headphones/encode.py index 12a4b6d7..ba51db3c 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -30,9 +30,9 @@ def encode(albumPath): for r,d,f in os.walk(albumPath): for music in f: - if any(music.endswith('.' + x) for x in headphones.MEDIA_FORMATS): + if any(music.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS): if (headphones.ENCODERLOSSLESS): - if (music.endswith('.flac')): + if (music.lower().endswith('.flac')): musicFiles.append(os.path.join(r, music)) musicTemp = os.path.normpath(os.path.splitext(music)[0]+'.'+headphones.ENCODEROUTPUTFORMAT).encode(headphones.SYS_ENCODING) musicTempFiles.append(os.path.join(tempDirEncode, musicTemp)) @@ -51,23 +51,23 @@ def encode(albumPath): for music in musicFiles: infoMusic=MediaFile(music) if headphones.ENCODER == 'lame': - if not any(music.endswith('.' +headphones.ENCODEROUTPUTFORMAT) for x in ["mp3", "wav"]): + if not any(music.lower().endswith('.' +headphones.ENCODEROUTPUTFORMAT) for x in ["mp3", "wav"]): logger.warn('Lame cant encode "%s" format for "%s", use ffmpeg' % (os.path.splitext(music)[1],music)) else: - if (music.endswith('.mp3') and (infoMusic.bitrate/1000<=headphones.BITRATE)): + if (music.lower().endswith('.mp3') 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) ifencoded=1 else: if headphones.ENCODEROUTPUTFORMAT=='ogg': - if music.endswith('.ogg'): + if music.lower().endswith('.ogg'): logger.warn('Can not reencode .ogg music "%s"' % (music)) else: command(encoder,music,musicTempFiles[i],albumPath) ifencoded=1 elif (headphones.ENCODEROUTPUTFORMAT=='mp3' or headphones.ENCODEROUTPUTFORMAT=='m4a'): - if (music.endswith('.'+headphones.ENCODEROUTPUTFORMAT) and (infoMusic.bitrate/1000<=headphones.BITRATE)): + if (music.lower().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) @@ -78,7 +78,7 @@ def encode(albumPath): time.sleep(1) for r,d,f in os.walk(albumPath): for music in f: - if any(music.endswith('.' + x) for x in headphones.MEDIA_FORMATS): + if any(music.lower().endswith('.' + x.lower()) for x in headphones.MEDIA_FORMATS): musicFinalFiles.append(os.path.join(r, music)) if ifencoded==0: