Spaces:
Running
Running
File size: 812 Bytes
804813e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from flask import Flask, render_template, jsonify, request
from ytmusicapi import YTMusic
import os
app = Flask(__name__)
ytmusic = YTMusic()
@app.route('/')
def index():
return render_template('index.html')
@app.route('/search', methods=['POST'])
def search():
query = request.json.get('query', '')
search_results = ytmusic.search(query, filter="songs")
return jsonify(search_results)
@app.route('/get_artist', methods=['GET'])
def get_artist():
artist_id = request.args.get('id')
artist_info = ytmusic.get_artist(artist_id)
return jsonify(artist_info)
@app.route('/get_album', methods=['GET'])
def get_album():
album_id = request.args.get('id')
album_info = ytmusic.get_album(album_id)
return jsonify(album_info)
if __name__ == '__main__':
app.run(debug=True)
|