Merge branch 'main' of https://repos.hackathon.bz.it/2025-summer/team-1
This commit is contained in:
commit
e22ad91601
640 changed files with 101753 additions and 31 deletions
|
@ -1,12 +1,10 @@
|
|||
import dotenv
|
||||
from flask import Flask, Response, jsonify, request
|
||||
from flask_cors import CORS
|
||||
|
||||
import dotenv
|
||||
from .room import Room
|
||||
from .song import init_db
|
||||
|
||||
from . import song_fetch
|
||||
|
||||
dotenv.load_dotenv()
|
||||
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@ def lastfm_search(query: str) -> tuple[str, str]:
|
|||
return track_info["name"], track_info["artist"]
|
||||
|
||||
|
||||
def lastfm_getinfo(
|
||||
name: str, artist: str
|
||||
) -> tuple[str, str, str, str, list[str]]: # ( id, image_id, tags )
|
||||
def lastfm_getinfo(name: str, artist: str) -> tuple[str, str, str, str, list[str]]: # ( id, image_id, tags )
|
||||
response = requests.get(
|
||||
url="https://ws.audioscrobbler.com/2.0/?method=track.getInfo&format=json",
|
||||
params={
|
||||
|
@ -44,20 +42,23 @@ def lastfm_getinfo(
|
|||
)
|
||||
|
||||
|
||||
print(yt_dlp, flush=True)
|
||||
def download_song_mp3(name: str, artist: str) -> tuple[str, str] | None: # ( id, audio )
|
||||
ydl_opts = {
|
||||
"format": "bestaudio",
|
||||
"default_search": "ytsearch1",
|
||||
"outtmpl": "%(title)s.%(ext)s",
|
||||
"skip_download": True,
|
||||
}
|
||||
|
||||
# # def get_yt_mp3link(name: str, artist: str) -> str: ...
|
||||
# # os.popen("/yt-dlp ")
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(f"{name!r} - {artist!r}", download=False)
|
||||
|
||||
# # /yt-dlp/yt-dlp.sh "ytsearch1:Never gonna give you up" --get-url -f "ba"
|
||||
first_entry = info["entries"][0]
|
||||
|
||||
# import json
|
||||
video_id = first_entry["id"]
|
||||
|
||||
# print(json.dumps(lastfm_getinfo(*lastfm_search("money")), indent=2))
|
||||
# exit(1)
|
||||
for fmt in first_entry["formats"]:
|
||||
if "acodec" in fmt and fmt["acodec"] != "none":
|
||||
return video_id, fmt["url"]
|
||||
|
||||
|
||||
# # def
|
||||
|
||||
|
||||
# ## query ==> lastfm ==> list of songs ==> take first ==> request song info ==> get YT link ==> save in DB ==>
|
||||
return None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue