Plex.sort is a simple script that lets you log into your Plex account and select a playlist to sort.
Currently, Python 3.7+ is supported.
-
Make sure pip is installed on your machine.
-
Create a virtual environment and activate it (optional), e.g.:
pip install virtualenv
python3 -m venv venv
source venv/bin/activate
- Install the packages from the
requirements.txt
file using pip:
pip install -r requirements.txt
- Execute the script and follow the guidance
./plex_sort.py
(venv) ➜ Plex.sort ./plex_sort.py
0: PlexServerHome
1: NAS1337
2: Another Storage Resource
Select resource to connect to: 1
0: Favorite music
1: Movies to watch
2: Random hits
3: X-mas songs
Select a playlist to sort: 3
0: Sort by title, ascending
1: Sort by title, descending
2: Sort by sorting title, ascending
3: Sort by sorting title, descending
4: Shuffle randomly
Select sorting method: 0
Do you want to create a duplicated playlist instead of modifying the selected one? [yN]
Successfully sorted playlist X-mas songs.
To skip the initial login process every time you use the script you might want to take a note of your authentication
token after your first login and save it to the config.ini file which should be located in ~/.config/plexapi/
(which can be overridden by setting the environment variable PLEXAPI_CONFIG_PATH
with the file path you desire) or in
the same directory as this script. Instead of the token you could also save your username and password to the
config.ini
file.
Instead of the token you could also save your username and password to the config.ini
file.
[auth]
myplex_username = JohnDoe
myplex_password = MyR4nd0mPassword
server_token = AjsUeO6Bk89BQPdu5Dnj
Important note for 2FA accounts
If you have activated two-factor authentication, after you have already logged in once you can either log in again with
your previously generated token or add your 6-digit number from the authenticator app at the end of your password, e.g.
Authenticator app shows: 123456
Username: JohnDoe
Password (will not be echoed): MyR4nd0mPassword123456
Or use the config.ini
file with your previously generated token:
[auth]
server_token = AjsUeO6Bk89BQPdu5Dnj