youtube + musicbrainz data works
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -113,6 +113,6 @@ dmypy.json
|
||||
.pyre/
|
||||
|
||||
|
||||
|
||||
.vscode/
|
||||
|
||||
result.json
|
||||
@@ -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
4
musicdl/download.py
Normal 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
23
musicdl/youtube.py
Normal 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
|
||||
@@ -1 +1,2 @@
|
||||
musicbrainzngs
|
||||
musicbrainzngs
|
||||
yt_dlp
|
||||
Reference in New Issue
Block a user