youtube + musicbrainz data works
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -113,6 +113,6 @@ dmypy.json
|
|||||||
.pyre/
|
.pyre/
|
||||||
|
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
|
||||||
result.json
|
result.json
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
from sys import argv
|
from sys import argv
|
||||||
import musicdl.metadata as metadata
|
from musicdl.download import download
|
||||||
|
from musicdl.metadata import search
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
url = argv[1]
|
url = argv[1]
|
||||||
print(url)
|
title, artist, album = download(url)
|
||||||
result = metadata.search("You Wouldn't Know", "Jonathan Coulton feat. Ellen McLain")
|
results = search(title, artist, album)
|
||||||
import json
|
|
||||||
json.dump(result, open("result.json", "w"), indent=4)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
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