Veritas1000 / pdst

DVR & sports tools that work with Plex
MIT License
7 stars 1 forks source link

Home and away colors #3

Open Sarke opened 3 years ago

Sarke commented 3 years ago

Hey, I would like to be able to use home and away colors for teams. Sometimes teams tend to have the same primary colors, such as red or blue. Having the logo backgrounds be either the primary color or the light alternate color would solve this and would also (mostly) match the jersey color the teams would be wearing.

From the documentation, the image hints can set two colors, like so: Alpha_69d2e6_f96900.png

So I was thinking if there was a config option to make that refer to the home color and the second to the away color, and then apply accordingly.

Sarke commented 3 years ago

A future extension of this could be alternate logos, as some teams use a different color scheme for their alternate light jerseys.

Actually, this might be the easier overall solution, since it wouldn't require any new config options.

Instead of looking for Springfield Isotopes it could first look for Home_Springfield Isotopes_000000.png or Away_Springfield Isotopes_ffffff.png (depending, of course, if they are home or away). If that doesn't exist, use the normal filenames as it does now.

Thanks again.

EDIT: or Springfield Isotopes_at$home_000000.png if that matches the current naming convention better. Although that is normally used to apply something to the image, not match it.

Veritas1000 commented 3 years ago

I would love to have a perfect implementation for the home/away thing, the problem I ran into (and why all I have at the moment is the 'alt'/multiple colors) is that in many instances, it is not feasible to determine which team is home or away consistently - at least with the level of metadata that I see coming from Plex and its program data.

As it is now, however, there should be support for falling back to a team's secondary color (or even another color from the logo) if the 2 original bg colors are too similar.

For example, say we've got these two colors set for Toronto FC and FC Dallas: Toronto_FC_e31937.png FC_Dallas_e81f3e.png
Toronto_FC_e31937 FC_Dallas_e81f3e

They both have red as the primary color, and are similar enough that they will fail a threshold check, so the tool will first see if the second team has any additional colors configured (which in this case it doesn't but you could) - and if not will fall back to the colors in the logo, and black/white as a final backstop.

Here are the images generated for two versions of the match thumbnail: pdst generate teams:MLS/Toronto--Dallas pdst generate teams:MLS/Dallas--Toronto
Toronto vs  Dallas Dallas vs  Toronto

Granted, the 'similar color' detection isn't perfect, but I have found that in most cases it works 'good enough'

Also, this kind of works out to follow the convention of a team's first color is their home color, the second their away color. Combined with the fact that the first team always gets their 'first' color for the background, and if the files always list the home team first, then the assumed home team should always get their main color, with the away potentially falling back to the secondary if their primary color is too similar to the other team's color.