]> diplodocus.org Git - flac-archive/blobdiff - flac2mp3
add C++ build rules
[flac-archive] / flac2mp3
index cbc0662531e8e23195d2a18bd275453da2150f81..24e4a48f64b980349bed23cfc0ffdf8b77bbdfbb 100755 (executable)
--- a/flac2mp3
+++ b/flac2mp3
@@ -89,9 +89,6 @@ def flac2mp3(fn, title, artist, album_artist, album, discnum, date,
     verbose and tmp.append('--verbose')
     lame_options = ' '.join(tmp)
 
-    outfile = ('%s (%s) %02d %s.mp3' % (artist, album,
-                                        track, title)).replace('/', '_')
-
     # Escape any single quotes ' so we can quote this.
     (fn, title, artist, album_artist,
      album, date) = [(x or '').replace("'", r"'\''")
@@ -109,8 +106,11 @@ def flac2mp3(fn, title, artist, album_artist, album, discnum, date,
 
     quoted_outfile = ('%s (%s) %02d %s.mp3' % (artist, outfile_album,
                                                track, title)).replace('/', '_')
+    # HACK! :(
+    if check_missing:
+        return quoted_outfile.replace(r"'\''", "'")
 
-    pic_options = None
+    pic_options = ''
     if pics:
         (fd, picfn) = tempfile.mkstemp()
         f = os.fdopen(fd, 'wb')
@@ -201,6 +201,8 @@ def main(argv):
         parser.add_option('--lame-options')
         parser.add_option('-q', '--quiet', action='store_true', default=False)
         parser.add_option('-v', '--verbose', action='store_true', default=False)
+        parser.add_option('--check-missing-files', action='store_true',
+                          default=False)
     except:
         traceback.print_exc()
         return 2
@@ -217,6 +219,8 @@ def main(argv):
     separator = ' '
     try:
         global debug, flac_options, lame_options, quiet, verbose
+        global check_missing
+        check_missing = options.check_missing_files
         debug = options.debug
         lame_options = options.lame_options
         quiet = options.quiet
@@ -254,6 +258,16 @@ def main(argv):
                     artist = tags.get('ARTIST', track)
                     artist.extend(tags.get('FEATURING', track))
                     album_artist = tags.gets('ALBUMARTIST', track)
+                    if check_missing:
+                        mp3 = flac2mp3(fn, title,
+                                 ', '.join(artist),
+                                 album_artist, album, discnum,
+                                 tags.gets('DATE', track),
+                                 track, args[i], pics)
+                        if not os.path.exists(mp3):
+                            print fn
+                            break
+                        continue
                     jobs.append((fn, title,
                                  ', '.join(artist),
                                  album_artist, album, discnum,