youtube + musicbrainz data works

This commit is contained in:
N0\A
2025-10-30 12:07:51 +01:00
parent eaa6ab4ba5
commit 31e4bfb38c
5 changed files with 34 additions and 7 deletions

2
.gitignore vendored
View File

@@ -113,6 +113,6 @@ dmypy.json
.pyre/
.vscode/
result.json

View File

@@ -1,12 +1,11 @@
from sys import argv
import musicdl.metadata as metadata
from musicdl.download import download
from musicdl.metadata import search
def main():
url = argv[1]
print(url)
result = metadata.search("You Wouldn't Know", "Jonathan Coulton feat. Ellen McLain")
import json
json.dump(result, open("result.json", "w"), indent=4)
title, artist, album = download(url)
results = search(title, artist, album)
if __name__ == '__main__':
main()

4
musicdl/download.py Normal file
View File

@@ -0,0 +1,4 @@
def download(url: str):
if "youtu" in url:
from musicdl.youtube import download
return download(url)

23
musicdl/youtube.py Normal file
View File

@@ -0,0 +1,23 @@
import yt_dlp
def download(url: str):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
}],
'outtmpl': '%(title)s.%(ext)s',
}
ydl = yt_dlp.YoutubeDL(ydl_opts) #type: ignore
# get data
info = ydl.extract_info(url, download=False)
title = info['title']
artist = info['creator']
album = None
# download
#ydl.download(url)
return title, artist, album

View File

@@ -1 +1,2 @@
musicbrainzngs
musicbrainzngs
yt_dlp