diff options
author | Lars Wirzenius <liw@liw.fi> | 2009-12-21 19:15:26 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2009-12-21 19:15:26 +0200 |
commit | 397aadef390ff3074dad6d60f37814619114c30b (patch) | |
tree | 2bd08b5538dfc784a75d65acdfd80f6ac2cf281f | |
parent | 411ecba7be71b1ee3f1a4acd784e8e7d60f3d9d9 (diff) | |
parent | 2dec307b95b755231648c001a9bc3d4607378380 (diff) | |
download | extrautils-397aadef390ff3074dad6d60f37814619114c30b.tar.gz |
Merged from gytha.
-rwxr-xr-x | musictomp3 | 3 | ||||
-rwxr-xr-x | test-flacs | 60 | ||||
-rw-r--r-- | test-flacs.1 | 25 |
3 files changed, 87 insertions, 1 deletions
@@ -190,7 +190,8 @@ class MusicToMp3(object): return filename.endswith('.flac') def needs_copying(self, filename): - return filename.endswith('.mp3') + dummy, ext = os.path.splitext(filename) + return ext.lower() in ['.mp3', '.m4a'] def run(self): logging.basicConfig(filename='musictomp3.log', level=logging.DEBUG) diff --git a/test-flacs b/test-flacs new file mode 100755 index 0000000..3028adc --- /dev/null +++ b/test-flacs @@ -0,0 +1,60 @@ +#!/usr/bin/python + + +import multiprocessing +import os +import subprocess +import sys +import time + + +def test_flacs(job_queue, result_queue): + i = 0 + for filename in iter(job_queue.get, None): + p = subprocess.Popen(['flac', '--totally-silent', '--test', filename]) + p.communicate() + result_queue.put((filename, p.returncode == 0)) + i += 1 + if i >= 10: + time.sleep(1) + i = 0 + + +def find_files(root): + pathnames = set() + for dirname, subdirs, filenames in os.walk(root): + for pathname in [os.path.join(dirname, x) for x in filenames]: + if pathname.endswith('.flac'): + pathnames.add(pathname) + return pathnames + + +files = find_files(sys.argv[1]) + +job_queue = multiprocessing.Queue() +result_queue = multiprocessing.Queue() +for job in files: + job_queue.put(job) +for i in range(multiprocessing.cpu_count()): + p = multiprocessing.Process(target=test_flacs, + args=(job_queue, result_queue)) + p.start() +total = len(files) +bad = list() +for done in range(total): + result = result_queue.get() + sys.stderr.write('\r%d / %d done' % (done + 1, total)) + sys.stderr.flush() + if result: + filename, ok = result + if not ok: + bad.append(filename) + +for i in range(multiprocessing.cpu_count()): + job_queue.put(None) + +sys.stderr.write('\n') + +for filename in bad: + print 'BAD:', filename + diff --git a/test-flacs.1 b/test-flacs.1 new file mode 100644 index 0000000..aabf8ce --- /dev/null +++ b/test-flacs.1 @@ -0,0 +1,25 @@ +.\" Copyright (C) 2009 Lars Wirzenius +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.\" +.TH TEST-FLACS 1 +.SH NAME +test-flacs \- check FLAC files for correctness +.SH SYNOPSIS +.B test-flacs +.IR dirname ... +.SH DESCRIPTION +.B test-flacs +checks that FLAC files (*.flac) are OK, using "flac --test". +It reports the names of the files that are not OK. |