stashapp / CommunityScripts

This is a public repository containing plugin and utility scripts created by the Stash Community.
https://docs.stashapp.cc/add-ons/
GNU Affero General Public License v3.0
191 stars 147 forks source link

Set the Cover Based on User's Original Custom Image Name #434

Open tobylibo opened 2 months ago

tobylibo commented 2 months ago

Plugin: setSceneCoverFromFile.
Ver: 0.4-ca4a670 Stashapp Ver: v0.26.2-129-ge4ef14e8

I've found that it will only set an image named poster or cover as the cover. Please add any custom image names in the future.

Reason: There are two types of cover images: horizontal and vertical. Stashapp is not friendly enough to support vertical cover. However, most of the movie covers are vertical. In my video folder, in addition to the video files, there are also two kinds of cover images: poster (vertical) and fanart (horizontal ). But now this plugin doesn't support setting an image named fanart as a cover, only an image named poster as a cover.

I hope that in future updates, the plugin will be able to set the cover based on the user's original custom image name, rather than just the poster or cover.

Thanks.

DogmaDragon commented 2 months ago

You can configure the pattern with regex in https://github.com/stashapp/CommunityScripts/blob/main/plugins/setSceneCoverFromFile/set_cover.py#L17, by updating your local file.

tobylibo commented 2 months ago

You can configure the pattern with regex in https://github.com/stashapp/CommunityScripts/blob/main/plugins/setSceneCoverFromFile/set_cover.py#L17, by updating your local file.

Thank you soooooooooooooooo much!

I changed the code from:

cover_pattern = r"(?:thumb|poster|cover)\.(?:jpg|png)"

to:

cover_pattern = r"(?:thumb|fanart)\.(?:jpg|png)"

It works.

Thank you for your reply!

tobylibo commented 2 months ago

@DogmaDragon

Plugin: setSceneCoverFromFile.

I may have found a bug. I used the method above and most of the covers that can be set are correct. But there are some videos that do have the same cover set up.

Especially when the file name is similar, it will be set to the same cover page.

Like what:

studios-my.video.fimename.1.mp4 ... studios-my.video.fimename.11.mp4 studios-my.video.fimename.12.mp4

or

studios-my.video.fimename.2.mp4 ... studios-my.video.fimename.21.mp4 studios-my.video.fimename.22.mp4 studios-my.video.fimename.23.mp4

However, sometimes, even though the file name is similar, it is possible to set a different cover correctly.

Very strange.