initial-speaker-cli#26
Conversation
| print(f"Finished playing {played_count}/{total_count} videos") | ||
|
|
||
| if __name__ == "__main__": | ||
| playlist_url = 'https://www.youtube.com/playlist?list=PLyLqO_HeaCB5QxDs04P0un3SAyfGYS-GW' |
There was a problem hiding this comment.
no hard coded url plsssss, if you want to include some functionality for testing that is okay, but you would then need to use arge parsing
There was a problem hiding this comment.
I have updated using arge parsing with an option -u for the url
| url: str | ||
|
|
||
| @app.get("/") | ||
| def root(): |
There was a problem hiding this comment.
dont return hello world here, either dont have a route for / or implement some type of functioanlity
i prefer not having an api route for / as just by looking at it idk what it is.
There was a problem hiding this comment.
I have deleted the root / for now
| audio_url = playing_queue.pop(0) # Get the next URL | ||
| played_count += 1 | ||
|
|
||
| print(f"Playing video {played_count}/{total_count}: {audio_url[:50]}...") |
There was a problem hiding this comment.
I updated it in audio43.py and use the functions from it in here
|
|
||
| app = FastAPI() | ||
|
|
||
| class PlaylistRequest(BaseModel): |
There was a problem hiding this comment.
I agree with the use of BaseModel USUALLY but in this case when we only have 1 variable in the class, importing a whole library for this functioanlity actually kind of defeats the purpose of BaseModel
There was a problem hiding this comment.
I have removed it, and just simply use a direct argument for url
| audio_url = playing_queue.pop(0) # Get the next URL | ||
| played_count += 1 | ||
|
|
||
| print(f"Playing video {played_count}/{total_count}: {audio_url[:50]}...") |
There was a problem hiding this comment.
I updated with a global constant. It is for limiting the number of char when displaying the url
| playing_queue.append(next_url) | ||
| print(f"Added next video to queue. Remaining: {len(remaining_queue)}") | ||
| except Exception as e: | ||
| print(f"Error playing {audio_url[:50]}: {str(e)}") |
There was a problem hiding this comment.
could we write the errors to a file? printing when no one is looking at the logs is useless. and if pi gets turned off or somethign we have the lgos saved
There was a problem hiding this comment.
I move the errors to errors.log instead in the updated code
|
|
||
| def get_youtube_audio_urls(playlist_url): | ||
| # Create a list to store the URLs | ||
| audio_urls = [] |
There was a problem hiding this comment.
removed in updated code
|
|
||
| def get_youtube_audio_urls(playlist_url): | ||
| # Create a list to store the URLs | ||
| audio_urls = [] |
| @@ -0,0 +1,73 @@ | |||
| import subprocess | |||
| import queue | |||
This PR implements a FastAPI version of the audio player functionality.
The project has two main components:
audio43.py: Contains the original command-line audio player functionalitymain.py: Implements the same functionality as a FastAPI web serviceThe implementation: