Created
March 17, 2019 22:17
-
-
Save mikka2061/e2991b4ad6ca0928cc6040a1c21f805b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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