Actor collection generator
The snippet can be accessed without any authentication.
Authored by
Mr. Carrot
You want to create a bunch of collections for your favorite actors, or a list of hot actors your friend gave you, or whatever. This script can make that easier.
- Put this script is a folder.
- Get yourself a TMDB API Key. Add it to the script.
- Change the image path to where PMM Is going to see your images.
- Update the actor list.
- Create a virtual env, activate it, and install the requirements:
python3 -m venv tmdba
source tmdba/bin/activate
python3 -m pip install tmdbsimple
python3 -m pip install requests
Run it. You'll get images in this dir, ready to be copied to the right place, and the output will be ready for you to copy-paste into your TMM config.
$ python tmdb_actors.py
Keanu Reeves:
template: {name: Actor, person: 6384, sort_title: 'z001'}
file_poster: config/assets/chaz/actors/6384-Keanu Reeves.jpg
Paul Rudd:
template: {name: Actor, person: 22226, sort_title: 'z002'}
file_poster: config/assets/chaz/actors/22226-Paul Rudd.jpg
Alexandra Daddario:
template: {name: Actor, person: 109513, sort_title: 'z003'}
file_poster: config/assets/chaz/actors/109513-Alexandra Daddario.jpg
Alice Eve:
template: {name: Actor, person: 59860, sort_title: 'z004'}
file_poster: config/assets/chaz/actors/59860-Alice Eve.jpg
tmdb_actor.py 815 B
import tmdbsimple as tmdb
import requests
tmdb.API_KEY = 'YOUR_TMDB_KEY_HERE'
tmdb.REQUESTS_SESSION = requests.Session()
image_path = "config/assets/chaz/actors/"
actors = [
"Keanu Reeves",
"Paul Rudd",
"Alexandra Daddario",
"Alice Eve"
]
search = tmdb.Search()
idx = 1
for thing in actors:
response = search.person(query=thing)
# for s in search.results:
s = search.results[0]
print(f" {s['name']}:")
print(f" template: {{name: Actor, person: {s['id']}, sort_title: 'z{idx:03}'}}")
print(f" file_poster: {image_path}{s['id']}-{s['name']}.jpg")
idx = idx + 1
url = f"https://www.themoviedb.org/t/p/w600_and_h900_bestv2/{s['profile_path']}"
r = requests.get(url)
with open(f"{s['id']}-{s['name']}.jpg", "wb") as f:
f.write(r.content)
Please register or sign in to comment