INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: External subtitles info in the tooltip?  (Read 705 times)

cvrkut

  • Recent member
  • *
  • Posts: 21
External subtitles info in the tooltip?
« on: November 30, 2019, 01:25:46 am »

Is it possible to determine if there are any external subtitles in the folder where the movie is?

How to display this information in the tooltip?
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 695
  • Hi
Re: External subtitles info in the tooltip?
« Reply #1 on: November 30, 2019, 12:25:58 pm »

It is, but it is neither easy nor pretty.  At least the solution that I came up with.  It's quite possible there is a much more elegant way to do this, but this is what I got.

For this demo I only worried about SRT subs (see below for to handle all filetypes), you will have to adjust for more filetypes, which is going to make this solution even uglier and more difficult (although there is probably a solution using regex).

All of the below assumes that you have your external subtitles saved alongside the movie file in the same folder.

First, you're going to want to want your external subs imported into MC.  Here are directions on how to do so https://yabb.jriver.com/interact/index.php/topic,87545.0.html.  The linked thread is about importing comic books into MC, so adjust accordingly.  I ended up adding this to my Custom Resources file “Subtitles (srt)” .  You will need to restart MC a this point.  Then import your subtitles.  I would suggest starting with a single movie and if you find this works, go on from there.

You are going to need a few new fields.  For this exercise, I have four scratch fields that I use for experimentation, they are [_a], [_b], [_c] and [_d] (this keeps them at the top of the list for easy access) you will probably want to rename them to something logical.

For [_a] I have a value of

Code: [Select]
if(isequal([Media Sub Type], Movie, 1), RemoveRight([Filename],3)srt,)
What this does is take the movies filename, remove the last three letters, which is the files extension and replace it with srt.  So Movie_title_1999.mkv becomes Movie_title_1999.srt

For [_b] I have a value of

Code: [Select]
if(isequal([filename], srt, 8), [filename],)
This is just saying if the filename contains srt, then print the filename otherwise don't print anything.

For [_c] I have a value of

Code: [Select]
if(isequal([Media Type], Data, 1), [_b],[_a])
So, if your media type is equal to data, which your subtitles will be, then [_c] will display [_b] and if the media type is not equal to data then [_c] will display [_a]

Finally, for [_d] I have a value of

Code: [Select]
ItemCount(/[filename /(path/)/[_c/])
This uses the somewhat new ItemCount feature which counts items with the same value in a given field or set of fields. 

If a movie has an srt file in the same folder as the movie, [_d] will display 2.  If there is no external subtitle file, [_d] will display 1.

Then, in your tooltip you could have something like

Code: [Select]
if(isequal([_d], 2, 1), This movie has external subtitles,)
Some of the above could probably be condensed to fewer fields, but I like to break things into smaller chunks as I find it easier to work that way, YMMV.
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 695
  • Hi
Re: External subtitles info in the tooltip?
« Reply #2 on: November 30, 2019, 03:09:30 pm »

I figured out how to make this work with any subtitle filetype.  It's the same theory as above, but some of the fields have been tweaked a bit.

[_a] equals

Code: [Select]
if(isequal([Media Sub Type], Movie, 1), RemoveRight([Filename],3)HASSUBS,)
[_b] equals

Code: [Select]
ifelse(regex([filename], /#.+(.srt|.sub|.ass)$#/, 0, 1), RemoveRight([Filename],3)HASSUBS)
For this one, add in the subtitle file extensions in this part of the code (.srt|.sub|.ass). Make sure to update your Custom Resources file as well.

[_c] equals

Code: [Select]
if(isequal([Media Type], Data, 1), [_b],[_a])
[_d] equals

Code: [Select]
ItemCount(/[filename /(path/)/[_c/])
Hope that helps.

Logged

cvrkut

  • Recent member
  • *
  • Posts: 21
Re: External subtitles info in the tooltip?
« Reply #3 on: December 01, 2019, 12:15:50 am »

Thanks Moe!
I'll try your solution

Regards
Logged
Pages: [1]   Go Up