From 0347ca1bcc0a42578771738e67fa156568daa9ef Mon Sep 17 00:00:00 2001 From: Ade Date: Sat, 16 May 2015 09:02:38 +1200 Subject: [PATCH] Various - Email SSL - History, show Folder Name when hovering over Status - Cuesplit, allow wav, ape to be split - mb, possible fix for #2181 --- data/interfaces/default/config.html | 3 ++ data/interfaces/default/history.html | 45 +++++++++++++++------------- headphones/config.py | 1 + headphones/cuesplit.py | 25 +++++++--------- headphones/helpers.py | 2 +- headphones/mb.py | 4 +-- headphones/notifiers.py | 5 +++- headphones/postprocessor.py | 8 +---- headphones/webserve.py | 3 +- 9 files changed, 49 insertions(+), 47 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 991c004a..3b1ddb6f 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -1134,6 +1134,9 @@
+
+ +
diff --git a/data/interfaces/default/history.html b/data/interfaces/default/history.html index 0b7cd6ee..e27b024b 100644 --- a/data/interfaces/default/history.html +++ b/data/interfaces/default/history.html @@ -32,32 +32,35 @@ - %for item in history: - <% - if item['Status'] == 'Processed': - grade = 'A' - elif item['Status'] == 'Snatched': - grade = 'C' - elif item['Status'] == 'Unprocessed': - grade = 'X' - elif item['Status'] == 'Frozen': - grade = 'X' - else: - grade = 'U' + %for item in history: + <% + if item['Status'] == 'Processed': + grade = 'A' + elif item['Status'] == 'Snatched': + grade = 'C' + elif item['Status'] == 'Unprocessed': + grade = 'X' + elif item['Status'] == 'Frozen': + grade = 'X' + else: + grade = 'U' - fileid = 'unknown' - if item['URL'].find('nzb') != -1: - fileid = 'nzb' - if item['URL'].find('torrent') != -1: - fileid = 'torrent' - if item['URL'].find('rutracker') != -1: - fileid = 'torrent' - %> + fileid = 'unknown' + if item['URL'].find('nzb') != -1: + fileid = 'nzb' + if item['URL'].find('torrent') != -1: + fileid = 'torrent' + if item['URL'].find('rutracker') != -1: + fileid = 'torrent' + + folder = 'Folder: ' + item['FolderName'] + + %> ${item['DateAdded']} ${cgi.escape(item['Title'], quote=True)} [${fileid}][album page] ${helpers.bytes_to_mb(item['Size'])} - ${item['Status']} + ${item['Status']} [retry][new] diff --git a/headphones/config.py b/headphones/config.py index d3e3e301..73b66765 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -64,6 +64,7 @@ _CONFIG_DEFINITIONS = { 'EMAIL_SMTP_USER': (str, 'Email', ''), 'EMAIL_SMTP_PASSWORD': (str, 'Email', ''), 'EMAIL_SMTP_PORT': (int, 'Email', 25), + 'EMAIL_SSL': (int, 'Email', 0), 'EMAIL_TLS': (int, 'Email', 0), 'EMAIL_ONSNATCH': (int, 'Email', 0), 'EMBED_ALBUM_ART': (int, 'General', 0), diff --git a/headphones/cuesplit.py b/headphones/cuesplit.py index d9b3c7bc..55112368 100755 --- a/headphones/cuesplit.py +++ b/headphones/cuesplit.py @@ -62,9 +62,7 @@ WAVE_FILE_TYPE_BY_EXTENSION = { '.flac': 'Free Lossless Audio Codec' } -# TODO: Only alow flac for now -#SHNTOOL_COMPATIBLE = ('Waveform Audio', 'WavPack', 'Free Lossless Audio Codec') -SHNTOOL_COMPATIBLE = ('Free Lossless Audio Codec') +#SHNTOOL_COMPATIBLE = ("Free Lossless Audio Codec", "Waveform Audio", "Monkey's Audio") # TODO: Make this better! # this module-level variable is bad. :( @@ -109,10 +107,10 @@ def split_baby(split_file, split_cmd): env['PATH'] += os.pathsep + headphones.CONFIG.CUE_SPLIT_FLAC_PATH process = subprocess.Popen(split_cmd, startupinfo=startupinfo, - - stdin=open(os.devnull, 'rb'), stdout=subprocess.PIPE, - stderr=subprocess.PIPE, env=env) + stdin=open(os.devnull, 'rb'), stdout=subprocess.PIPE, + stderr=subprocess.PIPE, env=env) stdout, stderr = process.communicate() + if process.returncode: logger.error('Split failed for %s', split_file.decode(headphones.SYS_ENCODING, 'replace')) out = stdout if stdout else stderr @@ -592,11 +590,10 @@ def split(albumpath): splitter = 'shntool' if splitter == 'shntool' and not check_splitter(splitter): - raise ValueError('Command not found, ensure shntool with FLAC or xld (OS X) installed') + raise ValueError('Command not found, ensure shntool or xld installed') - # Determine if file can be split (only flac allowed for shntool) - if 'xld' in splitter and wave.name_ext not in WAVE_FILE_TYPE_BY_EXTENSION.keys() or \ - wave.type not in SHNTOOL_COMPATIBLE: + # Determine if file can be split + if wave.name_ext not in WAVE_FILE_TYPE_BY_EXTENSION.keys(): raise ValueError('Cannot split, audio file has unsupported extension') # Split with xld @@ -640,7 +637,7 @@ def split(albumpath): cmd.extend(['-f']) cmd.extend([SPLIT_FILE_NAME]) cmd.extend(['-o']) - cmd.extend(['flac']) + cmd.extend([wave.name_ext.lstrip('.')]) cmd.extend([wave.name]) split = split_baby(wave.name, cmd) os.remove(SPLIT_FILE_NAME) @@ -652,9 +649,9 @@ def split(albumpath): logger.info('Tagging %s...', t.name) t.tag() - # rename FLAC files - if split and CUE_META.count_tracks() == len(base_dir.tracks(ext='.flac', split=True)): - for t in base_dir.tracks(ext='.flac', split=True): + # rename files + if split and CUE_META.count_tracks() == len(base_dir.tracks(ext=wave.name_ext, split=True)): + for t in base_dir.tracks(ext=wave.name_ext, split=True): if t.name != t.filename(): logger.info('Renaming %s to %s...', t.name, t.filename()) os.rename(t.name, t.filename()) diff --git a/headphones/helpers.py b/headphones/helpers.py index 1a319ab5..238b6dea 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -519,7 +519,7 @@ def get_downloaded_track_list(albumpath): return downloaded_track_list -def preserve_torrent_direcory(albumpath): +def preserve_torrent_directory(albumpath): """ Copy torrent directory to headphones-modified to keep files for seeding. """ diff --git a/headphones/mb.py b/headphones/mb.py index 3a150977..b0ddddce 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -218,7 +218,7 @@ def getArtist(artistid, extrasonly=False): artist_dict = {} artist = None try: - limit = 200 + limit = 100 with mb_lock: artist = musicbrainzngs.get_artist_by_id(artistid)['artist'] newRgs = None @@ -288,7 +288,7 @@ def getArtist(artistid, extrasonly=False): mb_extras_list = [] try: - limit = 200 + limit = 100 newRgs = None while newRgs is None or len(newRgs) >= limit: with mb_lock: diff --git a/headphones/notifiers.py b/headphones/notifiers.py index 9631660d..4c6ec1f6 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -843,7 +843,10 @@ class Email(object): message['To'] = headphones.CONFIG.EMAIL_TO try: - mailserver = smtplib.SMTP(headphones.CONFIG.EMAIL_SMTP_SERVER, headphones.CONFIG.EMAIL_SMTP_PORT) + if (headphones.CONFIG.EMAIL_SSL): + mailserver = smtplib.SMTP_SSL(headphones.CONFIG.EMAIL_SMTP_SERVER, headphones.CONFIG.EMAIL_SMTP_PORT) + else: + mailserver = smtplib.SMTP(headphones.CONFIG.EMAIL_SMTP_SERVER, headphones.CONFIG.EMAIL_SMTP_PORT) if (headphones.CONFIG.EMAIL_TLS): mailserver.starttls() diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index d6df01c7..8354c9ae 100755 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -188,15 +188,9 @@ def verify(albumid, albumpath, Kind=None, forced=False): # Split cue if headphones.CONFIG.CUE_SPLIT and downloaded_cuecount and downloaded_cuecount >= len(downloaded_track_list): if headphones.CONFIG.KEEP_TORRENT_FILES and Kind == "torrent": - albumpath = helpers.preserve_torrent_direcory(albumpath) + albumpath = helpers.preserve_torrent_directory(albumpath) if albumpath and helpers.cue_split(albumpath): downloaded_track_list = helpers.get_downloaded_track_list(albumpath) - else: - myDB.action('UPDATE snatched SET status = "Unprocessed" WHERE status NOT LIKE "Seed%" and AlbumID=?', [albumid]) - processed = re.search(r' \(Unprocessed\)(?:\[\d+\])?', albumpath) - if not processed: - renameUnprocessedFolder(albumpath, tag="Unprocessed") - return # test #1: metadata - usually works logger.debug('Verifying metadata...') diff --git a/headphones/webserve.py b/headphones/webserve.py index 84420d4d..1608d32f 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1167,6 +1167,7 @@ class WebInterface(object): "email_smtp_user": headphones.CONFIG.EMAIL_SMTP_USER, "email_smtp_password": headphones.CONFIG.EMAIL_SMTP_PASSWORD, "email_smtp_port": int(headphones.CONFIG.EMAIL_SMTP_PORT), + "email_ssl": checked(headphones.CONFIG.EMAIL_SSL), "email_tls": checked(headphones.CONFIG.EMAIL_TLS), "email_onsnatch": checked(headphones.CONFIG.EMAIL_ONSNATCH), "idtag": checked(headphones.CONFIG.IDTAG) @@ -1214,7 +1215,7 @@ class WebInterface(object): "nma_enabled", "nma_onsnatch", "pushalot_enabled", "pushalot_onsnatch", "synoindex_enabled", "pushover_enabled", "pushover_onsnatch", "pushbullet_enabled", "pushbullet_onsnatch", "subsonic_enabled", "twitter_enabled", "twitter_onsnatch", "osx_notify_enabled", "osx_notify_onsnatch", "boxcar_enabled", "boxcar_onsnatch", "songkick_enabled", "songkick_filter_enabled", - "mpc_enabled", "email_enabled", "email_tls", "email_onsnatch", "customauth", "idtag" + "mpc_enabled", "email_enabled", "email_ssl", "email_tls", "email_onsnatch", "customauth", "idtag" ] for checked_config in checked_configs: if checked_config not in kwargs: