Inspired by https://gist.github.com/blacktwin/397f07724abebd1223ba6ea644ea1669 (my original gist https://gist.github.com/cfurrow/13a062359bd83ac17a38f8c4fcd3bab2)

How to use

Be sure you have Pyton 3.9+ installed, then run:

pip install -r requirements.txt

Then get the URL of your plex server and your X-Plex-Token from the URL bar of your browser when you are logged in to your Plex server. See Plex's help doc on how to do this

Then copy the .env.example file to a new file called .env, and set the following variables. Be sure to use the correct URL or IP address for your Plex server. In the example below, the Plex server is at IP address 192.168.0.110 and the port is 32400 (the default Plex port).

PLEX_URL="https://192.168.0.100:32400"
PLEX_TOKEN=your-token-here

Now you should be able to run either script:

python cartoon_playlist.py

# or this one:
python aired_today_playlist.py

# or this one:
python aired_today_playlist.py '2019-02-10'

# or this one (which will delete other 'aired today' playlists, and then create a new one for the date given):
python aired_today_playlist.py --delete '2019-02-10'

You should see output like this depending on the script you ran:

python cartoon_playlist.py
Saturday Morning Cartoons already exists. Deleting it and will rebuild.
<Collection:5043:80s-Cartoons>
<Collection:5044:90s-Cartoons>
...snipped...
Adding 30 cartoons to playlist.


python aired_today_playlist.py
Building a playlist: Aired Today 12-30
Removing old Aired Today Playlists
Removing old Aired Today Playlists
Adding 28 videos to playlist.

Now go checkout your Plex server, and there will be a new playlist called "Saturday Morning Cartoons".

Troubleshooting

If you see an error like this:

(401) unauthorized; https://192.168.0.100:32400/ <html><head><script>window.location = window.location.href.match(/(^.+\/)[^\/]*$/)[1] + 'web/index.html';</script><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>

That means the token you are using is not valid. Make sure you are using the correct token for the correct server.