Skip to content

Commit ebb4a45

Browse files
committed
config class updates
1 parent 752d317 commit ebb4a45

40 files changed

+2086
-2000
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
**/*.pickle
1111
**/*.sqlite
1212

13+
config.yaml
14+
1315
Kometa/metadata-items
1416

1517
Plex/movies

Kometa/.env.example

Lines changed: 0 additions & 23 deletions
This file was deleted.

Kometa/README.md

Lines changed: 181 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,151 @@ Misc scripts and tools. Undocumented scripts probably do what I need them to but
66

77
See the top-level [README](../README.md) for setup instructions.
88

9-
All these scripts use the same `.env` and requirements.
9+
All these scripts use the same `config.yaml` and requirements.
1010

11-
Any that communicate with Plex require:
12-
```
13-
PLEXAPI_AUTH_SERVER_BASEURL=https://plex.domain.tld
14-
# Just the base URL, no /web or anything at the end.
15-
# i.e. http://192.168.1.11:32400 or the like
16-
PLEXAPI_AUTH_SERVER_TOKEN=PLEX-TOKEN
11+
### `config.template.yaml` contents
12+
13+
```yaml
14+
plex_api:
15+
header_identifier: "media-scripts"
16+
timeout: 360
17+
auth_server:
18+
base_url: 'YOUR_PLEX_URL'
19+
token: 'YOUR_PLEX_TOKEN'
20+
log:
21+
backup_count: 3
22+
format: "%(asctime)s %(module)12s:%(lineno)-4s %(levelname)-9s %(message)s"
23+
level: "INFO"
24+
path: "plexapi.log"
25+
rotate_bytes: 512000
26+
show_secrets: 0
27+
skip_verify_ssl: 0
28+
29+
general:
30+
tmdb_key: "TMDB_API_KEY" # https://developers.themoviedb.org/3/getting-started/introduction
31+
tvdb_key: "TVDB_V4_API_KEY" # currently not used; https://thetvdb.com/api-information
32+
delay: 1 # optional delay between items
33+
library_names: Movies,TV Shows,Movies 4K # comma-separated list of libraries to act on
34+
superchat: 0
35+
36+
kometa:
37+
config_dir: /kometa/is/here # location of Kometa config dir as seen by this script
38+
39+
image_download:
40+
what_to_grab:
41+
### collection-related
42+
include_collection_artwork: 1 # should get-all-posters retrieve collection posters?
43+
only_collection_artwork: 0 # should get-all-posters retrieve ONLY collection posters?
44+
only_these_collections: "Bing|Bang|Boing" # only grab artwork for these collections and items in them
45+
46+
### tv-related
47+
seasons: 1 # should get-all-posters retrieve season posters?
48+
episodes: 1 # should get-all-posters retrieve episode posters? [requires GRAB_SEASONS]
49+
50+
### background-related
51+
backgrounds: 1 # should get-all-posters retrieve backgrounds?
52+
artwork: 1 # current background is downloaded with current poster
53+
54+
### quantity-related
55+
only_current: 0 # should get-all-posters retrieve ONLY current artwork?
56+
poster_depth: 20 # grab this many posters [0 grabs all] [ONLY_CURRENT overrides this]
57+
58+
### what-to-keep
59+
keep_junk: 0 # keep files that script would normally delete [incorrect filetypes, mainly]
60+
find_overlaid_images: 0 # check all downloaded images for overlays
61+
retain_overlaid_images: 0 # keep images that have an overlay EXIF tag [this will override the following two]
62+
retain_kometa_overlaid_images: 0 # keep images that have the Kometa overlay EXIF tag
63+
retain_tcm_overlaid_images: 0 # keep images that have the TCM overlay EXIF tag
64+
65+
## where-to-put-it
66+
where_to_put_it:
67+
use_asset_naming: 1 # should grab-all-posters name images to match Kometa's Asset Directory requirements?
68+
use_asset_folders: 1 # should those Kometa-Asset-Directory names use asset folders?
69+
use_asset_subfolders: 0 # create asset folders in subfolders ["Collections", "Other", or [0-9, A-Z]] ]
70+
assets_by_libraries: 1 # should those Kometa-Asset-Directory images be sorted into library folders?
71+
asset_dir: "assets" # top-level directory for those Kometa-Asset-Directory images
72+
# if asset-directory naming is on, the next three are ignored
73+
poster_dir: "extracted_posters" # put downloaded posters here
74+
current_poster_dir: "current_posters" # put downloaded current posters and artwork here
75+
poster_consolidate: 0 # if false, posters are separated into folders by library
76+
77+
## tracking
78+
tracking:
79+
track_urls: 1 # If set to 1, URLS are tracked and won't be downloaded twice
80+
track_completion: 1 # If set to 1, movies/shows are tracked as complete by rating id
81+
track_image_sources: 1 # keep a file containing file names and source URLs
82+
83+
## general
84+
general:
85+
poster_download: 1 # if false, generate a script rather than downloading
86+
folders_only: 0 # Just build out the folder hierarchy; no image downloading
87+
default_years_back: 2 # in absence of a "last run date", grab things added this many years back.
88+
# 0 sets the fallback date to the beginning of time
89+
threaded_downloads: 0 # should downloads be done in the background in threads?
90+
reset_libraries: "Bing,Bang,Boing" # reset "last time" count to the fallback date for these libraries
91+
reset_collections: "Bing,Bang,Boing" # CURRENTLY UNUSED
92+
add_source_exif_comment: 1 # CURRENTLY UNUSED
93+
94+
status:
95+
plex_owner: "yournamehere" # account name of the server owner
96+
target_plex_url: "https://plex.domain2.tld" # As above, the target of apply_all_status
97+
target_plex_token: "PLEX-TOKEN-TWO" # As above, the target of apply_all_status
98+
target_plex_owner: "yournamehere" # As above, the target of apply_all_status
99+
library_map: '{"LIBRARY_ON_PLEX":"LIBRARY_ON_TARGET_PLEX", ...}'
100+
# In apply_all_status, map libraries according to this JSON.
101+
102+
reset_posters:
103+
track_reset_status: 1 # should reset-posters-* keep track of status and pick up where it left off?
104+
clear_reset_status: 0
105+
local_reset_archive: 1 # should reset-posters-tmdb keep a local archive of posters?
106+
override_overlay_status: 0
107+
target_labels: this label, that label # comma-separated list of labels to reset posters on
108+
remove_labels: 0 # attempt to remove the TARGET_LABELs from items after resetting the poster
109+
reset_seasons: 1 # reset-posters-* resets season artwork as well in TV libraries
110+
reset_episodes: 1 # reset-posters-* resets episode artwork as well in TV libraries [requires RESET_SEASONS=True]
111+
retain_reset_status_file: 0 # Don't delete the reset progress file at the end
112+
flush_status_at_start: 0 # Delete the reset progress file at the start instead of reading it
113+
reset_seasons_with_series: 0 # If there isn't a season poster, use the series poster
114+
dry_run: 0 # [currently only works with reset-posters-*]; don't actually do anything, just log
115+
116+
list_item_ids:
117+
include_collection_members: 0
118+
only_collection_members: 0
119+
120+
delete_collection:
121+
keep_collections: "bing,bang" # List of collections to keep
122+
123+
refresh_metadata:
124+
refresh_1970_only: 1 # If 1, only refresh things that have an originally-available date of 1970-01-01
125+
126+
rematch_items:
127+
unmatched_only: 1 # If 1, only rematch things that are currently unmatched
128+
129+
reset_added_at:
130+
adjust_date_futures_only: 0 # Only look at items that show up as added in the future
131+
adjust_date_epoch_only: 1 # Only adjust items that have "originally available" dates of `1970-01-01`
132+
133+
actor:
134+
cast_depth: 20 # how deep to go into the cast for actor collections
135+
top_count: 10 # how many actors to export
136+
job_type: "Actor"
137+
known_for_only: 0 # ignore cast members who are not primarily known as actors
138+
build_collections: 0 # build yaml for Kometa config.yml
139+
num_collections: 20 # this many actors in Kometa yaml
140+
track_gender: 1 # Pay attention to actor gender [as recorded on TMDB]
141+
min_gender_none: 5 # include minimum this many "none" gendered actors in the YAML, if possible
142+
min_gender_female: 5 # include minimum this many "female" gendered actors in the YAML, if possible
143+
min_gender_male: 5 # include minimum this many "male" gendered actors in the YAML, if possible
144+
min_gender_nb: 5 # include minimum this many "non-binary" gendered actors in the YAML, if possible
145+
146+
low_poster_count:
147+
poster_threshold: 10 # how many posters counts as a "low" count?
148+
149+
crew:
150+
depth: 20
151+
count: 100
152+
target_job: Director
153+
show_jobs: 0
17154
```
18155
19156
## Scripts:
@@ -34,18 +171,21 @@ You've deleted stuff from Plex and want to clean up the leftover backup art that
34171
35172
### Settings
36173
37-
The script uses these settings from the `.env`:
38-
```
39-
LIBRARY_NAMES=Movies,TV Shows,Movies 4K # comma-separated list of libraries to act on
40-
DELAY=1 # optional delay between items
41-
KOMETA_CONFIG_DIR=/opt/kometa/config/ # path to Kometa config directory
174+
The script uses these settings from the `config.yaml`:
175+
```yaml
176+
general:
177+
delay: 1 # optional delay between items
178+
library_names: Movies,TV Shows,Movies 4K # comma-separated list of libraries to act on
179+
180+
kometa:
181+
config_dir: /kometa/is/here # location of Kometa config dir as seen by this script
42182
```
43183

44184
### Usage
45185
1. setup as above
46186
2. Run with `python clean-overlay-backup.py`
47187

48-
The script will catalog the backup files and current Plex contents for each library listed in the `.env`.
188+
The script will catalog the backup files and current Plex contents for each library listed in the `config.yaml`.
49189

50190
It then compares the two lists, and any files in the backup dir that do not correspond to current items in Plkex are deleted.
51191

@@ -56,7 +196,7 @@ connecting to https://plex.bing.bang...
56196
Loading Movies ...
57197
Loading movies from Movies ...
58198
Completed loading 6965 of 6965 movie(s) from Movies
59-
Clean Overlay Backup Movies |████████████████████████████████████████| 6965/6965 [100%] in 11.0s (633.23/s)
199+
Clean Overlay Backup Movies |████████████████████████████████████████| 6965/6965 [100%] in 11.0s (633.23/s)
60200
Processed 6965 of 6965
61201
0 items to delete
62202
279 items in Plex with no backup art
@@ -72,6 +212,7 @@ You're getting started with Kometa and you want to export your existing collecti
72212
Here is a quick and dirty [emphasis on "quick" and "dirty"] way to do that.
73213
74214
### Usage
215+
75216
1. setup as above
76217
2. Run with `python extract-collections.py`
77218
@@ -110,7 +251,7 @@ Here is a basic script to do that.
110251

111252
The script will clone or update the `Kometa-Images` repo, then iterate through it applying overlays to each image and storing them in a parallel file system rooted at `Kometa-Images-Overlaid`, ready for you to use with the Kometa Asset Directory [after moving them to that directory] or via template variables.
112253

113-
It chooses the overlay by name based on the "group" that each collection is part of:
254+
It chooses the overlay by name based on the "group" that each collection is part of:
114255
```
115256
Kometa-Images
116257
├── aspect
@@ -143,7 +284,7 @@ If there isn't a specific image for a "group", then `Kometa/default_collection_o
143284
Fetch/Pull on Kometa-Images
144285
Using default_collection_overlays/overlay-template.png as global overlay
145286
building list of targets
146-
Applying overlays |████████████████████████████▎ | ▇▅▃ 5027/7119 [71%] in 3:53 (21.6/s, eta: 1:37)
287+
Applying overlays |████████████████████████████▎ | ▇▅▃ 5027/7119 [71%] in 3:53 (21.6/s, eta: 1:37)
147288
Kometa-Images/genre/Sword & Sandal.jpg
148289
```
149290

@@ -266,18 +407,29 @@ Note, this will only copy images that have received overlays, and for which the
266407

267408
If you don't have overlays on any episodes, this script will not put any episode images in the asset directory, and so on.
268409

410+
```yaml
411+
image_download:
412+
where_to_put_it:
413+
use_asset_folders: 1 # should those Kometa-Asset-Directory names use asset folders?
414+
asset_dir: "assets" # top-level directory for those Kometa-Asset-Directory images
269415
```
270-
# ORIGINAL TO ASSETS
271-
USE_ASSET_FOLDERS=1 # should the asset directory use asset folders?
272-
ASSET_DIR=assets # top-level directory for those assets
416+
417+
The asset file system will be rooted at the directory in the `asset_dir` setting, and `use_asset_folders` controls whether the images are stored as:
418+
419+
```yaml
420+
use_asset_folders: 1
273421
```
274-
The asset file system will be rooted at the directory in the `ASSET_DIR` setting, and `USE_ASSET_FOLDERS` controls whether the images are stored as:
275422

276-
`USE_ASSET_FOLDERS=1`
277423
```
278424
Media-Scripts/Plex/assets/All That Jazz (1979) {imdb-tt0078754} {tmdb-16858}.jpg
279425
```
280-
or `USE_ASSET_FOLDERS=0`
426+
427+
or
428+
429+
```yaml
430+
use_asset_folders: 0
431+
```
432+
281433
```
282434
Media-Scripts/Plex/assets/All That Jazz (1979) {imdb-tt0078754} {tmdb-16858}/poster.jpg
283435
```
@@ -289,7 +441,7 @@ connecting to https://test-plex.DOMAIN.TLD...
289441
Loading Test-Movies ...
290442
Loading movies ...
291443
Completed loading 35 of 35 movie(s) from Test-Movies
292-
Grab all posters Test-Movies |████████████████████████████████████████| 35/35 [100%] in 0.2s (190.63/s)
444+
Grab all posters Test-Movies |████████████████████████████████████████| 35/35 [100%] in 0.2s (190.63/s)
293445
Processed 35 of 35
294446
Complete!
295447
```
@@ -370,10 +522,12 @@ For each movie, gets the cast from TMDB; keeps track across all movies how many
370522

371523
At the end, builds a basic Kometa metadata file for the top N actors.
372524

373-
Script-specific variables in .env:
374-
```
375-
CAST_DEPTH=20 ### HOW DEEP TO GO INTO EACH MOVIE CAST
376-
TOP_COUNT=10 ### PUT THIS MANY INTO THE FILE AT THE END
525+
Script-specific variables in `config.yaml`:
526+
527+
```yaml
528+
actor:
529+
cast_depth: 20 # how deep to go into the cast for actor collections
530+
top_count: 10 # how many actors to export
377531
```
378532
379533
`CAST_DEPTH` is meant to prevent some journeyman character actor from showing up in the top ten; I'm thinking of someone like Clint Howard who's been in the cast of many movies, but I'm guessing when you think of the top ten actors in your library you're not thinking about Clint. Maybe you are, though, in which case set that higher.

0 commit comments

Comments
 (0)