2022-07-03 04:33:01 +00:00
![banner.jpg ](assets/media-organizer-banner.png?raw=true "Media Organizer Banner" )
2021-06-11 04:47:53 +00:00
2021-03-31 14:51:33 +00:00
# media_organizer
2021-04-02 04:12:10 +00:00
*A set of python scripts to rename movies and tv shows.*
2021-03-31 14:51:33 +00:00
2022-07-04 00:46:28 +00:00
![screenshot.jpg ](assets/media-organizer-screenshot.png?raw=true "Media Organizer Screenshot" )
2021-03-31 14:51:33 +00:00
This project is used and tested under Linux and is ideal to be used from something like a Raspberry Pi or a Linux based NAS. If you want to help me to get it to work under Windows, please contribute.
2021-03-31 15:03:11 +00:00
## Run
2022-07-03 04:33:01 +00:00
Clone the repo, setup config file (see below) and run `interface.py` . Use your arrow keys to navigate up and down the menu.
2021-05-30 05:17:16 +00:00
* **q** quit the interface
2022-07-03 04:33:01 +00:00
* **r** refresh the pending items by rescanning the file system.
2021-03-31 15:03:11 +00:00
2021-05-30 05:17:16 +00:00
## Movies
2022-07-03 04:33:01 +00:00
Detect movie names by querying [themoviedb.org ](https://www.themoviedb.org/ ) API and renaming the file based on a selection of possible matches. Follow the config file instructions below to get your API key.
2021-03-31 14:51:33 +00:00
All data is courtesy of [The Movie Database ](https://www.themoviedb.org ), please contribute to this excellent database.
2022-07-03 04:33:01 +00:00
Movies will get renamed to this naming style:
**{movie-name} ({Year})/{movie-name} ({Year}).{ext}**
2021-03-31 14:51:33 +00:00
2021-05-30 05:17:16 +00:00
## TV shows
2022-07-03 04:33:01 +00:00
Detect tv show filenames by querying the publicly available [tvmaze.com ](https://www.tvmaze.com/ ) API to identify the show name and the episode name based on a selection of possible matches. Please contribute to this excellent database.
2021-03-31 14:51:33 +00:00
2022-07-03 04:33:01 +00:00
Episodes are named with this template:
2021-04-02 04:12:10 +00:00
**{show-name}/Season {nr}/show-name - S{nr}E{nr} - {episode-name}.{ext}**
2021-03-31 14:51:33 +00:00
2021-05-30 05:17:16 +00:00
## Trailer download
2022-07-03 04:33:01 +00:00
Download trailers from links provided from emby and move them into the movie folder.
Trailers are named with this template:
2022-12-20 08:57:49 +00:00
**{movie-name} ({Year})_{youtube-id}_trailer.mkv**
2021-04-16 08:45:19 +00:00
2021-05-30 05:17:16 +00:00
## Fix Movie Names
2022-07-03 04:33:01 +00:00
Sometimes Emby gets it wrong. Sometimes this script can get it wrong too. The *Fix Movie Names* function goes through the movie library looking for filenames that don't match with the movie name as identified in emby.
2021-04-17 08:53:59 +00:00
2021-12-29 16:20:18 +00:00
## CSV export
2022-07-03 04:33:01 +00:00
Export the library to csv files. Calles the Emby API to get a list of movies and episodes and exports this to a convenient set of CSV files.
2021-05-30 05:17:16 +00:00
2021-03-31 14:51:33 +00:00
## setup
2021-04-18 02:55:20 +00:00
Needs Python >= 3.6 to run.
### install requirements
2022-07-03 04:33:01 +00:00
These are the non standard Python libraries in use in this project:
2021-03-31 14:51:33 +00:00
* [requests ](https://pypi.org/project/requests/ )
2021-06-12 04:13:24 +00:00
* Install on Arch: `sudo pacman -S python-requests`
* Install with pip: `pip install requests`
2021-04-16 08:45:19 +00:00
* [trash-cli ](https://pypi.org/project/trash-cli/ )
* Install on Arch: `sudo pacman -S trash-cli`
* Install with pip: `pip install trash-cli`
2021-11-04 04:44:41 +00:00
* [yt-dlp ](https://pypi.org/project/yt-dlp/ )
* Install on Arch: `sudo pacman -S yt-dlp`
* Install with pip: `pip install yt-dlp`
2021-03-31 14:51:33 +00:00
* curses
* Is already installed on most linux based systems.
* On Windows: `pip install windows-curses`
2021-04-18 02:55:20 +00:00
Or use `pip` to install all the requirements:
`pip install -r requirements.txt`
2021-04-23 10:15:30 +00:00
### config json file:
Duplicate the config.sample.json file to a file named *config.json* and set the following variables:
#### media
2021-03-31 14:51:33 +00:00
* `tv_downpath` : Folder path where the tv episodes get downloaded to.
* `movie_downpath` : Folder path where the movie files get downloaded to.
2022-07-03 04:33:01 +00:00
* `sortpath` : Empty folder that can be used by *media_organizer* as a temporary sort path.
2021-04-02 04:12:10 +00:00
* `moviepath` : Root folder where the organized movie files will go.
* `tvpath` : Root folder where the organized tv episodes will go.
2022-07-03 04:33:01 +00:00
* `ext` : A list of valid media file extensions to easily filter out non-media related files.
* `log_path` : Path to a folder to output all renaming done to keep track, check for any errors and safe csv files.
2021-05-09 14:08:58 +00:00
* `movie_db_api` : Register and get your themoviedb.com **API Key (v3 auth)** acces from [here ](https://www.themoviedb.org/settings/api ).
2022-07-03 04:33:01 +00:00
* `min_file_size` : Minimal file size to be considered a relevant media file in bytes.
2021-04-16 08:45:19 +00:00
2021-04-23 10:15:30 +00:00
#### Emby integration
2021-05-30 05:17:16 +00:00
*optional:* remove the 'emby' key from config.json to disable the emby integration.
2021-04-04 08:06:49 +00:00
* `emby_url` : url where your emby instance is reachable
* `emby_user_id` : user id of your emby user
2021-04-16 08:45:19 +00:00
* `emby_api_key` : api key for your user on emby
2021-04-23 10:15:30 +00:00
#### ydl_opts *Trailer download:*
2021-05-30 05:17:16 +00:00
*optional:* remove the 'ydl_opts' key from config.json to disable the trailer download functionality.
2021-11-04 04:44:41 +00:00
Arguments under the [ydl_opts] section will get passed in to yt-dlp for *trailers* . Check out the documentation for details.
2021-05-30 05:17:16 +00:00
## Known limitations:
2022-07-03 04:33:01 +00:00
Most likely *media_organizer* will fail if there are any files like Outtakes, Extras, Featurettes, etc in the folder. For these cases, move/delete them first before running *media_organizer* .