Youtube Playlist Generation
After my successful experiment with automatic Spotify playlist generation couple of days ago, I couldn't help but wonder - could I do the same with YouTube? Spoiler alert: Yes, and it was surprisingly straightforward!
The Inspiration
My previous adventure with Spotify playlist automation left me hungry for more. While Spotify is great for music streaming, YouTube's vast library of music videos, live performances, and covers adds another dimension to the listening experience.
Getting Started with ChatGPT
As with my Spotify project, I turned to ChatGPT for guidance. It provided clear prerequisites and step-by-step instructions that made the process incredibly smooth.
Prerequisites: Setting Up YouTube Data API
The first step was getting access to YouTube's Data API. ChatGPT walked me through:
- Creating a Google Cloud Project
- Enabling the YouTube Data API v3
- Getting API credentials (OAuth 2.0 client)
- Setting up authentication
The Implementation Journey
Here's what the process looked like:
1. **Install Required Libraries**
```python
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib
```
2. **Writing the Code**
The Python script needed to:
- Authenticate with YouTube
- Create a new playlist
- Add videos to the playlist
For now I am generating the IDs of the relevant videos using a manual prompt and using the output in the code. A fun challenge arose when I discovered that some of the video IDs generated through prompts were outdated. This required adding error handling to ensure the script continued running even if some videos weren't available. It was a great learning opportunity to make the code more robust!
The Result
After about 10 minutes of setup and execution, I had my first automated YouTube playlist ready! You can check it out here:
[My Automated Playlist](https://www.youtube.com/playlist?list=PL5vPIiNWEdKZE8Jp5IeAJjsFTiQ5HuSB3)
What's Next?
This success has opened up so many possibilities! I'm already thinking about:
- Generating themed playlists for different moods
- Creating genre-specific collections
- Adding filters for video quality and popularity
- Automating playlist updates based on new releases
The ease of implementation has really motivated me to explore more
.

