diff options
author | Ryan Kavanagh <rak@debian.org> | 2018-08-21 18:05:58 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@debian.org> | 2018-08-21 18:05:58 -0400 |
commit | c0c698f74ac91b1fbf4cc8b5e39fe49441a2ba68 (patch) | |
tree | 4b70a8fdbdfb27100cf6173d4fd3efe2f737d390 /bin/my_tagger | |
parent | Added script to update internet radio playlist (diff) |
Delete a bunch of old scripts
Diffstat (limited to 'bin/my_tagger')
-rwxr-xr-x | bin/my_tagger | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/bin/my_tagger b/bin/my_tagger deleted file mode 100755 index f09b031..0000000 --- a/bin/my_tagger +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/python - -import codecs -import re - -from mutagen import flac - -FILENAME='tracks' - -CONFIRM=True -DEBUG=False -SWAPNAME=True -SAVE=True -SPLIT=False - -if CONFIRM or DEBUG: - import pprint - # From - # http://stackoverflow.com/questions/10883399/unable-to-encode-decode-pprint-output - class PPUTF8(pprint.PrettyPrinter): - def format(self, object, context, maxlevels, level): - if isinstance(object, unicode): - return (object.encode('utf8'), True, False) - return pprint.PrettyPrinter.format(self, object, context, - maxlevels, level) - - -if __name__ == '__main__': - if CONFIRM or DEBUG: - pp = PPUTF8(indent=4) - - with codecs.open(FILENAME, encoding='utf-8', mode='r') as f: - lines = f.readlines() - headers = lines[0][:-1].split('\t') - - if SWAPNAME: - first_last = re.compile('^(?P<last>[^,]+),\s+(?P<first>.+)$') - - files = {} - for i, file in enumerate(lines[1:]): - # i starts counting at zero while we need it to start counting at 1 - # since 0 is the header line - i += 1 - line = lines[i].replace('\n', '').split('\t') - file = line[0] - files[file] = {} - for j, tag in enumerate(line[1:]): - # j starts counting at 0, should be 1 - j += 1 - header = headers[j] - files[file][header] = tag.strip() - if header == 'ARTIST' or header == 'LYRICIST' or \ - header == 'ARRANGER': - if SPLIT: - files[file][header] = [name.strip() for name in - tag.split(';')] - else: - files[file][header] = tag.strip() - if SWAPNAME: - for n, name in enumerate(files[file][header]): - res = first_last.match(name) - if res: - files[file][header][n] = res.group('first') + \ - ' ' + res.group('last') - - - - if CONFIRM: - print "Loaded data:\n" - pp.pprint(files) - - if CONFIRM: - if raw_input("\nSave files? [Y/n]").lower()in ['', 'y']: - SAVE = True - else: - SAVE = False - - file = flac.FLAC() - for name in files.keys(): - file.load(name) - # Delete tags - file.delete() - for key, val in files[name].iteritems(): - file[key] = val - if SAVE: - file.save() - - if DEBUG: - print "\n\nData in flac file:", name - pp.pprint(file) |