documentation
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ app = Flask(__name__)
|
|
9 |
|
10 |
@app.route('/')
|
11 |
def index():
|
|
|
12 |
try:
|
13 |
return send_from_directory('.', 'index.html')
|
14 |
except Exception as e:
|
@@ -16,6 +17,7 @@ def index():
|
|
16 |
|
17 |
@app.route('/video_id', methods=['POST'])
|
18 |
def video_id() -> str:
|
|
|
19 |
try:
|
20 |
title: str = request.json.get('title')
|
21 |
artist: str = request.json.get('artist')
|
@@ -26,6 +28,7 @@ def video_id() -> str:
|
|
26 |
|
27 |
@app.route('/parse_csv', methods=['POST'])
|
28 |
def parse_csv():
|
|
|
29 |
try:
|
30 |
file = request.files['file']
|
31 |
# Process the uploaded file
|
@@ -34,8 +37,8 @@ def parse_csv():
|
|
34 |
return shazamlibrary_df.to_json(orient="records")
|
35 |
except Exception as e:
|
36 |
return str(e)
|
37 |
-
|
38 |
|
39 |
def _get_youtube_song(title: str, artist: str) -> Optional[YouTube]:
|
|
|
40 |
search_result = Search(f'{title} by {artist}')
|
41 |
return search_result.results[0] if search_result.results else None
|
|
|
9 |
|
10 |
@app.route('/')
|
11 |
def index():
|
12 |
+
"""Route handler for the home page"""
|
13 |
try:
|
14 |
return send_from_directory('.', 'index.html')
|
15 |
except Exception as e:
|
|
|
17 |
|
18 |
@app.route('/video_id', methods=['POST'])
|
19 |
def video_id() -> str:
|
20 |
+
"""Route handler for retrieving the YouTube video ID"""
|
21 |
try:
|
22 |
title: str = request.json.get('title')
|
23 |
artist: str = request.json.get('artist')
|
|
|
28 |
|
29 |
@app.route('/parse_csv', methods=['POST'])
|
30 |
def parse_csv():
|
31 |
+
"""Route handler for parsing the uploaded CSV file"""
|
32 |
try:
|
33 |
file = request.files['file']
|
34 |
# Process the uploaded file
|
|
|
37 |
return shazamlibrary_df.to_json(orient="records")
|
38 |
except Exception as e:
|
39 |
return str(e)
|
|
|
40 |
|
41 |
def _get_youtube_song(title: str, artist: str) -> Optional[YouTube]:
|
42 |
+
"""Searches for a YouTube video based on the given title and artist"""
|
43 |
search_result = Search(f'{title} by {artist}')
|
44 |
return search_result.results[0] if search_result.results else None
|