i gave up
This commit is contained in:
parent
fef8ae685d
commit
c61c00dfd6
1 changed files with 9 additions and 7 deletions
16
unsync.py
16
unsync.py
|
@ -8,6 +8,7 @@ import os.path
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from zlib import crc32
|
||||||
|
|
||||||
import mutaext
|
import mutaext
|
||||||
import convert
|
import convert
|
||||||
|
@ -79,12 +80,13 @@ def makefilename(md):
|
||||||
title = md['title']
|
title = md['title']
|
||||||
artist = md['artist']
|
artist = md['artist']
|
||||||
album = md['album']
|
album = md['album']
|
||||||
sync = md.get('sync')
|
|
||||||
|
|
||||||
# TODO: strip /'s and other possible nasties
|
fn = "%(artist)s - %(album)s - %(title)s" % locals()
|
||||||
if sync:
|
crc = crc32(fn.encode('utf-8')) & 0xFFFFFFFF
|
||||||
return "!%(sync)s %(artist)s - %(album)s - %(title)s.ogg" % locals()
|
# FAT is a pain to deal with so just use nondescript filenames
|
||||||
return "%(artist)s - %(album)s - %(title)s.ogg" % locals()
|
fn = '{:08X}.ogg'.format(crc)
|
||||||
|
|
||||||
|
return fn
|
||||||
|
|
||||||
def run(args):
|
def run(args):
|
||||||
if not len(args) in (2, 3):
|
if not len(args) in (2, 3):
|
||||||
|
@ -129,13 +131,13 @@ def run(args):
|
||||||
if md.seen:
|
if md.seen:
|
||||||
try:
|
try:
|
||||||
_from = md.seen
|
_from = md.seen
|
||||||
_to = fout.encode('utf-8')
|
_to = fout
|
||||||
if type(_from) != type(_to):
|
if type(_from) != type(_to):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
|
|
||||||
if _from != _to:
|
if _from != _to:
|
||||||
print("MOV", _from)
|
print("MOV", _from)
|
||||||
#os.rename(_from, _to)
|
os.rename(_from, _to)
|
||||||
continue
|
continue
|
||||||
except:
|
except:
|
||||||
lament(type(_from), type(_to))
|
lament(type(_from), type(_to))
|
||||||
|
|
Loading…
Reference in a new issue