Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Add movies poster by folder #6

Closed
omerher opened this issue Feb 9, 2021 · 6 comments · Fixed by #30
Closed

Feature Request - Add movies poster by folder #6

omerher opened this issue Feb 9, 2021 · 6 comments · Fixed by #30
Assignees
Labels
enhancement New feature or request

Comments

@omerher
Copy link

omerher commented Feb 9, 2021

Due to the removal of the previous issue, I'm posting one without TPDb. Like before it uses the config and plex (probably not the version this repo uses but similar). Here's the code from my program:

import requests
from bs4 import BeautifulSoup
import os

from config_tools import Plex, Config


# subtype can be 'movie', 'show', or None (movie/tv combined)
def get_collection(plex, data, exact=None, subtype=None):
    collection_list = plex.Library.search(title=data, libtype="collection")
    if len(collection_list) > 1:
        for collection in collection_list:
            if collection.title == data:
                return collection
        if not exact:
            c_names = ["| " + (str(i + 1) + ") " + collection.title + " (" + collection.subtype + ")") for i, collection in enumerate(collection_list)]
            print("| 0) Do Nothing")
            print("\n".join(c_names))
            while True:
                try:
                    selection = int(input("| Choose collection number: ")) - 1
                    if selection >= 0:
                        return collection_list[selection]
                    elif selection == -1:
                        raise ValueError("No collection selected")
                    else:
                        print("| Invalid entry")
                except (IndexError, ValueError) as E:
                    print("| Invalid entry")
    elif len(collection_list) == 1 and (exact is None or collection_list[0].title == data):
        return collection_list[0]
    else:
        raise ValueError("Collection {} Not Found".format(data))

def change_artwork_folder(plex, posters_dir, collection_name):
	for file in os.listdir(posters_dir):
		root, ext = os.path.splitext(file)
		try:
			movie, year = root.split(" (")
			movie = movie.replace("- ", " ")

			try:
				plex_movie = plex.Library.search(title=movie)[0]
				plex_movie.uploadPoster(filepath=f"{posters_dir}/{file}")
			except IndexError:
				print(f"Couldn't find {movie}")
		except ValueError:
			collection = get_collection(plex, collection_name)
			collection.uploadPoster(filepath=f"{posters_dir}/{file}")

########################################################################################################################################

config_path = "config.yml"
config = Config(config_path)
plex = Plex(config_path)

collections = config.collections
for c in collections:
	posters_path = collections[c].get("path_to_posters")
	if posters_path is not None:
		change_artwork_folder(plex, posters_path, c)
@meisnate12
Copy link
Member

I'm just curious is there a reason you want the program to do this over just putting the poster files in the same folder as the movie to just let the Scanner find it?

@meisnate12 meisnate12 added the enhancement New feature or request label Feb 10, 2021
@meisnate12 meisnate12 self-assigned this Feb 10, 2021
@omerher
Copy link
Author

omerher commented Feb 11, 2021

This script can add posters for individual movies and if I'm not mistaken the current version of the program can only add posters for collections.

@meisnate12
Copy link
Member

meisnate12 commented Feb 12, 2021

ok so heres what im thinking for this.

Inside your assets folder under the collection folder you can add folders for movies that are in said collection for example

├── The Lord of the Rings
│   ├── poster.png
│   ├── background.png
│   ├── The Lord of the Rings The Fellowship of the Ring (2001)
│       ├── poster.png
│       ├── background.png
│   ├── The Lord of the Rings The Two Towers (2002)
│       ├── poster.png
│       ├── background.png
│   ├── The Lord of the Rings The Return of the King (2003)
│       ├── poster.png
│       ├── background.png

The folder name for the movie posters must be exactly the same as the folder name the movie is located in your library.

This is how i would want to implement this what do you think?

@omerher
Copy link
Author

omerher commented Feb 12, 2021

I feel like most people are happy with the default background for a movie or don't bother to change it, so maybe instead of putting them into folders you would just have the movie as the name of the image.

├── The Lord of the Rings
│   ├── poster.png
│   ├── background.png
│   ├── The Lord of the Rings The Fellowship of the Ring (2001).jpg
│   ├── The Lord of the Rings The Two Towers (2002).jpg
│   ├── The Lord of the Rings The Return of the King (2003).jpg

This is the default name format (except for the collection poster) for ThePosterDB (which is probably where most people get their collection posters) and would make dragging and dropping posters very easy.

I might be wrong, but I think putting each poster in a folder of its own and renaming it would be more tedious than doing it on the plex app.

@meisnate12
Copy link
Member

well as one of the people who changes the backgrounds of their movies I would have to disagree and if you need to make your files into folders you can use this Kometa-Team/Community-Configs#8

@omerher
Copy link
Author

omerher commented Feb 12, 2021

Just tested out the script and it works a lot better and easier than I thought it would, so yeah your original suggestion works great.

@meisnate12 meisnate12 mentioned this issue Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants