Page 1 of 1
Rename posters separated from the movies
Posted: 04 Oct 2023, 08:39
by hama4reall
So i have searched through the form and found one topic about renaming images but that topic had different use case my use case is i have a zip that contains all the posters (with somewhat random names) and a sheet that have all the name of the poster files and their movie names and year and tmdbid, to simplify the process for filebot i renamed the files to there movies names like for example:
Original file name:
→
Code: Select all
Iron Sky The Coming Race (2019).webp
using the sheet so filebot can match theme (i could add the tmdbid but i don't know if that makes filebot match precisely and where should i put it), i want to sort them out to the movies folders with the pattern i have in my filebot but it wont match the posters since they're *.webp now i have a workaround for this which is rename the extensions to *.mkv and then match it and sort them with filebot afterwards rename those *-poster.mkv to *-poster.webp but this is not a great solution for me since some movies might not exist and that will only create empty folder with just the poster inside
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 08:49
by rednoah
You can probably
Plain File Mode to rename given files based on the information of your spreadsheet, i.e. CSV / TSV file.
e.g. use current file name as key to lookup some other value in a TSV table:
e.g. spreadsheet.tsv
This seems to be the first step of what you have already done. But you could extend this step
(NOTE: much more use case details required from your side regarding input / output details) to lookup the corresponding movie file
(NOTE: TMDB ID will be useful for that) and then have the format return the file path of that movie file
(without extension) as target file path.
We assume that you you have all the *.webp files in some folder, separate from the movie files, linked to the movie file only via your spreadsheet. However, if the *.webp file is in the same folder as the movie file, then there are
other options.
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 09:05
by hama4reall
Thanks for the reference but i want to sort them out to different folders like in my filebot format
Code: Select all
/Media/{f.path.match(/Badini/).upperInitial()}/{any { anime ? 'Anime' : '' }{ genres =~ /Animation/ ? 'Animation' : '' }}/{any {f.path.match(/Documentary/).upperInitial()}{ genre =~ /Documentary/ ? 'Documentary' : '' }}/{info.OriginalLanguage.toLocale().displayLanguage}/{~jellyfin.id}
According to this structure i want the posters to be sorted to but filebot won't match with TheMovieDatabase
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 09:07
by hama4reall
And yes i have the posters in a different folder separated from the movie files
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 09:48
by hama4reall
In a nutshell i want to extract information from TMDB and rename the files based on them, my sheet doesn't have all the info needed so I'm trying to use FileBot for that matter
And for matching the files with tmdb i have three columns (Movie Name, Release Year, TMDBid)
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 10:31
by rednoah
hama4reall wrote: ↑04 Oct 2023, 09:48
In a nutshell i want to extract information from TMDB and rename the files based on them, my sheet doesn't have all the info needed so I'm trying to use FileBot for that matter
And for matching the files with tmdb i have three columns (Movie Name, Release Year, TMDBid)
You cannot (easily) do that. You can however (easily) process files based on already previously processed files.
e.g.
e.g. sample companion files
e.g. sample files with xattr metadata
Code: Select all
/path/to/Movies/Avatar (2009)/Avatar (2009).mp4
csv() can be used with a folder as argument
(as opposed to a TSV text file) which then provides a
File ➔ Metadata Object map of the folder contents.
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 14:06
by hama4reall
Sorry for not attaching the spreadsheet, Here is it:
https://drive.google.com/file/d/1A_M12B ... sp=sharing
Could you make an example from it I'm not experienced in java and coding in general
Re: Rename posters separated from the movies
Posted: 04 Oct 2023, 15:30
by rednoah
e.g.
e.g. /path/to/ids.tsv
** export the last 2 columns as TSV file to make it easier to read in the data from your format expression
Re: Rename posters separated from the movies
Posted: 05 Oct 2023, 11:54
by hama4reall
Ok i have been trying to make it work but the format gives this error:
Code: Select all
Expression yields empty value: Cannot invoke "java.lang.Integer.intValue()" because "
Yesterday the format were applied on half of the files but today after converting them from .webp to .jpg none of them can be applied all gives the error above.
The format i have applied is:
Code: Select all
{
def mid = csv('/files/Movies.tsv')[f.name] as int
csv('/Media/Movies/').findResult{ f, m -> if (mid == m.id) f.dir / 'poster' }
}
And the tsv file i use is:
https://drive.google.com/file/d/1iks8vA ... sp=sharing
My Movies Fomrat is:
Code: Select all
/Media/{f.path.match(/Badini/).upperInitial()}/{ hd == /UHD/ ? '4K Movies' : 'Movies' }/{f.path.match(/Short/).upperInitial}/{ genres =~ /Animation/ ? 'Animation' : '' }/{ genre =~ /Documentary/ ? 'Documentary' : '' }/{info.OriginalLanguage.toLocale().displayLanguage}/{~jellyfin.id}
I want the posters to go to
Code: Select all
/Media/Movies/{Movie Language}/{Movie Name} ({Year}) [tmdbid-{TMDBID}]/poster.jpg
I use filebot as xpra application
Re: Rename posters separated from the movies
Posted: 05 Oct 2023, 14:19
by rednoah
If you change the filename, then the filename no longer matches the filename in the TSV file and so the mapping no longer works.
You can use
{fn} (name without extension) as key and remove all the .webp in your TSV file, to make sure the key in the format matches the key in the TSV file.
e.g.
Groovy: Select all
{
def key = fn
def value = csv('/files/Movies.tsv')[key]
if (value == null) {
throw new Exception("File '$key' is not on the list")
}
def mid = value as int
def movieFile = csv('/Media/Movies/').findResult{ f, m -> if (mid == m.id) f }
if (movieFile == null) {
throw new Exception("ID '$mid' does not correspond to any file")
}
return movieFile.dir / 'poster'
}
/files/Movies.tsv
Code: Select all
romeo-and-the-black-brothers 35832
Adding error messages makes the code a bit longer. But just read it and it'll make sense.
Re: Rename posters separated from the movies
Posted: 05 Oct 2023, 20:52
by hama4reall
Oh, i just realized that. Thanks a lot for the extended code it works now after a quick find (.webp) & replace (.jpg) in the spreadsheet.
Re: Rename posters separated from the movies
Posted: 07 Oct 2023, 06:04
by rednoah
If you've got it working, please create a tutorial for the next guy. You've effectively created your own tool for your own ultra-specific use case, but others may be able to adapt and re-use for their ultra-specific use case. Typical users wouldn't expect this possible, much less in ~2 lines of code, so some documentation would be useful.
Re: Rename posters separated from the movies
Posted: 08 Oct 2023, 19:28
by hama4reall
Sure, when i finish sorting my Medias, i will
Re: Rename posters separated from the movies
Posted: 10 Oct 2023, 16:26
by hama4reall
I have finished sorting the Movie's Posters, now i'm trying to sort the Show's posters but it gives `Expression yields empty value` with the format:
Code: Select all
`{
def mid = csv('/files/unsorted/Shows.tsv')[f.name] as int
csv('/Media/Shows/').findResult{ f, m -> if (mid == m.id) f.dir/ 'poster' }
}`
and the second format that contains error types it didn't work but the first one was really good for the movies, my Shows Format is Like so
Code: Select all
`/Media/{f.path.match(/Badini/).upperInitial()}/{ hd == /UHD/ ? '4K' : 'Shows'}/{any { anime ? 'Anime' : '' }{ genres =~ /Animation/ ? 'Animation' : '' }{f.path.match(/Documentary/).upperInitial()}{ genre =~ /Documentary/ ? 'Documentary' : '' }{info.OriginalLanguage.toLocale().displayLanguage}}/{~jellyfin.id}`
The tsv file is the same as the above (first Coloumn Contains File names, second Coloumn contain tmdbid)
Re: Rename posters separated from the movies
Posted: 10 Oct 2023, 16:58
by rednoah
You'll want to use the longer version so that you can get better error reporting, of course may need to be adjusted for your specific use case, file paths, TSV columns, etc:
viewtopic.php?p=61298#p61298
The
if (mid == m.id) bit probably doesn't work for episodes, since you'll want to find episode files by series ID and not episode ID. Use
if (mid == m.seriesInfo.id) instead. You may also need to modify the target file path bit, since you'll be searching for episode files, which are usually in a season folder, which is then in a series folder where your poster probably wants to go.
e.g.