Python-PlexAPI
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, and empty trash among many other things.
- More information can be found here.
Prerequisites
Installation
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.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. - 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 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
If you require further assistance, you can open a support ticket here!
Feedback and suggestions regarding this article are welcome on our Discord server