Skip to content

Instantly share code, notes, and snippets.

@nmarley
Last active June 17, 2017 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmarley/6d33fc77741b6c95666e96d9d970ea1e to your computer and use it in GitHub Desktop.
Save nmarley/6d33fc77741b6c95666e96d9d970ea1e to your computer and use it in GitHub Desktop.
quick/dirty Python script to use Docker for legacy Perl code to manage MP3/Id3 tags
import sys
import os
from pprint import pprint
import re
with open('list.txt', 'r') as f:
data = f.read()
filenames = [line for line in data.split('\n') if line]
for fn in filenames:
result = re.match(r'^Pimsleur - Turkish - Lesson (\d{2}).mp3$', fn)
track_string = result.group(1)
track_num = int(track_string)
year = 2006
title = 'Turkish - Unit %s' % track_string
artist = 'Pimsleur'
album = 'Turkish'
genre = 'Language'
total_trax = 30
t1 = """docker run --rm -v "$PWD":/data mp3info2 \\
/usr/local/bin/DropTags.pl '/data/{filename}'"""
command = t1.format(filename=fn)
print(command)
template = """docker run --rm -v "$PWD":/data mp3info2 \\
/usr/local/bin/mp3info2 -t '{title}' -a '{artist}' \\
-l '{album}' -c '' -y {year} -g '{genre}' -n {num}/{total_trax} \\
-2 '/data/{filename}'"""
command = template.format(
year=year,
title=title,
artist=artist,
album=album,
genre=genre,
num=track_num,
total_trax=total_trax,
filename=fn
)
print(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment