]> diplodocus.org Git - flac-archive/commitdiff
some write work
author <epg@pretzelnet.org> <>
Thu, 27 Dec 2012 00:36:02 +0000 (16:36 -0800)
committer <epg@pretzelnet.org> <>
Thu, 27 Dec 2012 00:36:02 +0000 (16:36 -0800)
rewrite-tags

index 6d47eaa..a5c69f7 100755 (executable)
@@ -3,8 +3,6 @@
 import sys
 from subprocess import Popen, PIPE
 
 import sys
 from subprocess import Popen, PIPE
 
-from org.diplodocus.util import run_or_die
-
 from flac_archive.tags import Tags
 
 class SubprocessError(Exception):
 from flac_archive.tags import Tags
 
 class SubprocessError(Exception):
@@ -66,6 +64,32 @@ def do_read(filenames):
     print '\n'.join(coll_tags.all())
     return 0
 
     print '\n'.join(coll_tags.all())
     return 0
 
+def do_write(args):
+    tags = Tags()
+    tags.load(open(args.pop(0)))
+    if len(args) != len(tags):
+        sys.stderr.write('expected %d flac files, got %d\n'
+                         % (len(tags), len(args)))
+        return 4
+    artist = tags.get_path_safe('ARTIST')
+    album = tags.get_path_safe('ALBUM'),
+    try:
+        os.mkdir(artist)
+    except OSError, e:
+        if e.errno != EEXIST:
+            raise
+    album_path = artist + '/' + album
+    try:
+        os.mkdir(album_path)
+    except OSError, e:
+        if e.errno != EEXIST:
+            raise
+    for i, old_fn in enumerate(args):
+        track = i + 1
+        fn = '%s/%s/%s.flac' % (artist, album, tags.make_filename(track))
+        if fn != old_fn:
+            #os.rename(old_fn, fn)
+
 def main(args):
     if len(args) < 3:
         return usage()
 def main(args):
     if len(args) < 3:
         return usage()