Skip to content

Instantly share code, notes, and snippets.

@mikka2061
Created March 17, 2019 22:17
Show Gist options
  • Save mikka2061/e2991b4ad6ca0928cc6040a1c21f805b to your computer and use it in GitHub Desktop.
Save mikka2061/e2991b4ad6ca0928cc6040a1c21f805b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import frontmatter
import glob
from mutagen.id3 import ID3, TIT2, TPE1, TRCK, TALB
import os
try:
post = frontmatter.load('podcast.yaml')
except:
print("podcast.yaml not found or not parseable")
if post:
title = post['title']
author = post['author']
for audio_file in glob.glob('*.mp3'):
audio = ID3(audio_file)
episode = os.path.splitext(audio_file)[0]
track = [int(s) for s in episode.split() if s.isdigit()]
audio.add(TIT2(encoding=3, text=episode + " - " + title))
audio.add(TPE1(encoding=3, text=author))
audio.add(TALB(encoding=3, text=title))
audio.add(TRCK(encoding=3, text=str(track[0])))
audio.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment