Created
July 20, 2023 07:41
-
-
Save acheong08/61c34adf507e7e5cdcc5cae83d89c8d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from yt_dlp import YoutubeDL | |
from mutagen.easymp4 import EasyMP4 | |
import os | |
ydl = YoutubeDL() | |
# List files | |
files = os.listdir() | |
# Filter out non-m4a files | |
files = [f for f in files if f.endswith(".m4a")] | |
for file in files: | |
yt_id = file.split(".")[0] | |
# Get metadata | |
info = ydl.extract_info(yt_id, download=False) | |
m4a = EasyMP4(file) | |
m4a["title"] = info.get("title") | |
m4a["artist"] = ( | |
info.get("uploader") or info.get("channel") or info.get("uploader_id") | |
) | |
m4a.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment