That’s a command you’re going to type or paste into your terminal (OSX or Linux) or Powershell (Windows). In some cases it's displaying *output* from a command you've typed, but the difference should be apparent in context.
IMPORTANT NOTE:
This walkthrough is going to be pretty pedantic. I’m assuming you’re reading it because you have no idea how to get a Python script going, so I’m proceeding from the assumption that you want to be walked through every little detail. You’re going to deliberately cause errors and then fix them as you go through it. This is to help you understand what exactly is going on behind the scenes so that when you see these sorts of problems in the wild you will have some background to understand what’s happening. If I only give you the happy path, then when you make a typo later on you’ll have no idea where that typo might be or why it’s breaking things.
I am assuming you do not have any of these tools already installed. When writing this up I started with a brand new Windows 10 install.
This walkthrough involves typing commands into a command window. On Mac OS X or Linux, you can use your standard terminal window, whether that's the builtin Terminal app or something like iTerm. On Windows, you should use PowerShell. There are other options for command windows in Windows, but if you want this to work as written, which I assume is the case since you've read this far, you should use Powershell.
If you are running this on a desktop Linux machine, start up the Terminal application. That window will be the terminal you will type commands into, so leave it open.
In order to run a Python script. the first thing you'll need is a Python interpreter. THis is typically already present on Linux and Mac, but will probably have to be installed on Windows.
First let's check if it's installed already [type this into your terminal]:
```
python3 --version
```
If this doesn't return `3.7.0` or higher, you'll need to get Python 3 installed.
<details>
<summary>Linux</summary>
<br/>
Describing a python install for any arbitrary linux is out of scope here, but if you're using Ubuntu, [this](https://techviewleo.com/how-to-install-python-on-ubuntu-linux/) might be useful.
Go to http://www.python.org/download and download the latest version of Python for Windows in 32 or 64-bit as appropriate for your system [probably 64-bit]. As this is written, that's 3.10.4.
For Windows 10, you will need to enable scripts in PowerShell. Follow the instructions [here](https://windowsloop.com/enable-powershell-scripts-execution-windows-10) to do so. If you skip this step you're going to hit a hard stop in a little bit.
The git install is discussed here: [Download for Linux and Unix](https://git-scm.com/download/linux)
</details>
<details>
<summary>OS X</summary>
<br/>
The git install is discussed here: [Git - Downloading Package](https://git-scm.com/download/mac)
</details>
<details>
<summary>Windows</summary>
<br/>
Download the installer from [here](https://git-scm.com/download/windows)
Run the install; you can probably just accept the defaults and click through except for the step that asks you to choose an editor; you probably want to choose something other than the default there:
![Git Install](git-install.png)
This install comes with its own command line interface. **Do not use this interface in this walkthrough**. Continue to do everything here in Powershell.
**NOTE: The rest of this walkthrough assumes you are staying in this directory in this terminal/Powershell window.**
<details>
<summary>What did that do?</summary>
<br/>
```
cd ~
```
This changes to your home directory, which will be something like `/home/yourname` or `/Users/yourname` or `C:\Users\YourName` depending on the platform.
Later on you can move it elsewhere if you want, but for now put it there. This will ensure that everything to follow works just like it says here. Presumably you’re reading this because the other docs are unclear to you. Don’t make unilateral changes to my assumptions while doing this.
<details>
<summary>Why use git instead of downloading the release ZIP?</summary>
<br/>
Retrieving the code with `git` makes updating simpler. When you want to update to the newest version, you can go into this directory and type:
```
git pull
```
No need to download a new ZIP, uncompress it, etc.
This walkthrough is going to use a "virtual environment", since that provides a simple way to keep the requirements for a given thing self-contained; think of it as a "sandbox" for this script. It also provides a clean way to recover from mistakes, and keeps the host system clean.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
You apparently didn't check the “Add to path” checkbox above under [installing Python](#installing-python). "Repair" your Python install and check "add python to environment variables".
This tells Python3 to use the `venv` module to create a virtual environment called `pmm-venv`. The only visible effect will be the creation of a `pmm-venv` directory.
</details>
That command will not produce any output if it works; it will display an error if a problem occurs. If everything is fine, you will be looking at something like this:
```
> python -m venv pmm-venv
>
```
If you aren't looking at an error, you're ready to move on.
.\pmm-venv\Scripts\activate : File C:\Users\mroche\Plex-Meta-Manager\pmm-venv\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink LinkID=135170.
You will need to take care of that before moving on. Follow the instructions [here](https://windowsloop.com/enable-powershell-scripts-execution-windows-10).
</details>
That command will not produce any output if it works; it will display an error if a problem occurs.
You may see a change in your prompt, something like this:
Note that the prompt now shows the name of the virtual environment. You may not see this; it's dependent on *your* terminal configuration, not anything to do with Python or PMM.
<details>
<summary>What did that do?</summary>
<br/>
This tells Python to make the virtual environment "active", which means to use the copy of python that is available there, install all support libraries there, etc. This keeps the PMM code and its runtime environment totally separate from your host machine's environment.
An advantage of doing this in a virutal environment is that in the event something goes wrong with this part of the setup, you can delete that pmm-venv directory and do the setup again.
**IMPORTANT: In the future, when you want to run the script, you will need to do this "activation" step every time. Not the venv creation, just the activation**:
Plex-Meta-Manager, like every other Python script, depends on support libraries that manage things like connections to Plex, or getting things from the internet, or writing files and so on.
These support libraries are called “requirements”, and they are defined in that file called `requirements.txt`. To install them, type the following command [type this into your terminal]:
Config Error: config not found at /Users/mroche/Plex-Meta-Manager/config
```
That error means you don’t have a config file, but we at least know that the requirements are in place and the script can run.
### Setting up the initial config file
Next you’ll set up the config file. ThIs tells PMM how to connect to Plex and a variety of other services.
Before you do this you’ll need:
1. TMDb API key. They’re free.
1. Plex URL and Token
There are a bunch of other services you *can* configure in the config file, but these two are the bare minimum.
#### Getting a TMDb API Key
Note that if you already have an API key, you can use that one. You don’t need another.
Go to https://www.themoviedb.org/. Log into your account [or create one if you don’t have one already], then go to “Settings” under your account menu.
In the sidebar menu on the left, select “API”.
Click to generate a new API key under "Request an API Key". If there is already one there, copy it and go to the [next step](#getting-a-plex-url-and-token).
There will be a form to fill out; the answers are arbitrary. The URL can be your personal website, or probably even google.com or the like.
Once you’ve done that there should be an API Key available on this screen.
Copy that value, you’ll need it for the config file.
#### Getting a Plex URL and Token
The Plex URL is whatever URL you’d use **from this machine** to connect directly to your Plex server [i.e. NOT app.plex.tv].
As with the TMDb API Key, if you already have a Plex Token, you can use that one.
This article describes how to get a token: [Finding an authentication token](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/)
#### Editing the config template
First, make a copy of the template. This is going to create a copy of the base template that you can then edit. You only need to do this once.
I’m using `nano` here simply because it’s built into OSX. On Linux you may need to install `nano`, or you can use any other text editor you wish, provided it saves files as PLAIN TEXT.
You will ultimately need an entry here for each of the libraries on which you want PMM to act. Those top-level elements [Movies, TV Shows, Anime, Music] are names of libraries on your Plex server.
You can see there that PMM found its config file, was able to connect to TMDb, was able to connect to Plex, and then failed trying to read the “Movies-NOSUCHLIBRARY library, which of course doesn’t exist.
Open the config file again and change "Movies-NOSUCHLIBRARY" to reflect *your own* Plex. Then delete any lines that start with “git”. Those are all sets of collections, and we just want to create a few as examples.
This metadata file contains definitions of the actions you want PMM to take; these can be things like creating collections or playlists, adding overlays, changing things like posters, etc. You can find lots of examples [here](https://github.com/meisnate12/Plex-Meta-Manager-Configs) and throughout the wiki.
I chose a letterboxd list for the last one since trakt requires authentication and again, I didn’t want to complicate this walkthrough.
This is going to create three collections. One contains movies that feature Bill Murray. One is up to 100 movies that came out in the 1980s sorted by popularity. The last are movies that appear on a list of good endings according to Vulture.
The first one is based on a template to illustrate that concept. If you wanted to create a collection for another actor you just have to copy and edit those two lines [the ID comes from TMDb]. All the other config details come from the template.
As it builds the collections, you should see a fair amount of logging showing which movies are being added to each collection and which ones aren’t found. Once it completes, go to Plex, go to your Movies library, and click “Collections” at the top.
When you click into each, you’ll see the movies that PMM added to each collection.
Each time you run the script, new movies that match the collection definition will be added. For example, if you don’t have “The Razors’ Edge” now, when you download it and run PMM again it will be added to the Bill Murray collection.
If you download any of the missing 22 movies on the Vulture list, running PMM would add them to that collection. And so on.
TV Shows and other libraries work the same way as you've seen above. Create a section under `Libraries:` in the config.yml, create a metadata file, define collections, run the script.