Python-PlexAPI
This unofficial app installation guide is provided for your convenience. The guide is provided as-is and may not be updated or maintained by Ultra.cc. Unofficial support may be offered via Discord only and at the sole discretion of Ultra.cc staff. Use at your own risk and only proceed if you are comfortable managing the application on your own.
Python-PlexAPI is a utility tool with intent of performing actions on your Plex instance by interacting with the Plex API. Included features are library actions such as scan, analyze, empty trash among many other things.
- More information can be found here.
Prerequisites
Installation
Do note, Python-PlexAPI requires some familiarity with the Linux terminal and scripting in general. If you are new to this, you should start by reading Your Ultra.cc Shell - A Beginner's Guide.
- Connect to your Ultra.cc service via SSH
- Once connected, execute the following command:
pip install plexapi
- Once the installation has completed, you can begin using the utility tool.
- In this guide, we will use our pre-made script that lists all your media titles in a
.txt
file.- However, this is just one of many usecases. Other examples can be found here.
- Start by downloading the script to your Ultra service with the following command.
wget https://scripts.usbx.me/ultra.cc/util/Python-PlexAPI/main.py
- Next, open the file in the Nano editor.
nano main.py
-
Before you can use the script, you need to edit the
plex_url
,plex_token
and the library names of your Plex server.- You can find your Plex IP in the Plex webUI. Navigate to Settings > Remote Access and copy the Private IP. It will be in the format of
172.17.0.xxx
. Do note, if Plex is restarted/upgraded, the private IP might change, and you will need to update your script with the new IP. - You can find your Plex token by following the instructions in this link.
- Additionally, you must edit the script to reflect your library names instead of 4K Movies, 1080p Movies and TV Shows.
- The
file.write
row represents what is written to the file by the script. - The
plex.library.section
row is the name of the Plex library the script should look for.
- The
- You can find your Plex IP in the Plex webUI. Navigate to Settings > Remote Access and copy the Private IP. It will be in the format of
-
Once you have edited the script with your Plex server details and library names, you can save and exit the editor.
- To save and exit, press
CTRL+X
andY
, then pressENTER
to confirm.
- To save and exit, press
-
To run the script, execute the following command:
python main.py
- Depending on the size of your library, it may take some time to execute.
- If the execution of the script was successful, you should see the following output in your terminal.
ultradocs@spica:~$ python plexapi.py
Media titles with release year have been written to plex_media_titles_with_year.txt
- You can find your media titles listed in
plex_media_titles_with_year.txt