Kodi Community Forum
Help with moviestacking syntax in Adve - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Video Support (https://forum.kodi.tv/forumdisplay.php?fid=264)
+--- Thread: Help with moviestacking syntax in Adve (/showthread.php?tid=374001)



Help with moviestacking syntax in Adve - anonsm - 2023-08-03

I am looking for some help as I've been tried to figure out a way to deal with videos that have different file names but need to be combined in to 1
Kodi can take videos with filename called:
Quote:videoname pt1.mp4
videoname pt2.mp4
videoname pt3.mp4

And stack them successfully. That's no problem.

but I have videos with descriptions on the end that I want to retain to but have kodi combine them by finding pt1, pt2, pt3 in the file name despite the names not matching 100%
Quote:videoname - pt1 - Intro.mp4
videoname - pt2 - Opening.mp4
videoname - pt4 - Intermission.mp4
videoname - pt5 - Ending.mp4

I am trying to figure out a way to just get kodi to look at folder for the title, then detect "pt#" in the filename and stack them but I can't seem to figure out how to do that. I don't want to change the filenames as in the first example as I still want to be able to view them individually outside of kodi and the file name helps with the description. Ideally, it would behave like having to wild cards in the filenames bookending the part number.
Quote:*wildcard*pt1*wildcard*
*wildcard*pt2*wildcard*
*wildcard*pt3*wildcard*

I am not an XML or regex expert. Information I find online for syntax has a very technical explanation that I don't quite understand as a non-programmer. I've been utilizing advancedsettings.xml to try to accomplish this, particularly this section: https://kodi.wiki/view/Advancedsettings.xml#moviestacking

Code block:
<moviestacking>
<!-- <cd/dvd/part/pt/disk/disc> <0-N> -->
<regexp>(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]+)(.*?)(\.[^.]+)$</regexp>
<!-- <cd/dvd/part/pt/disk/disc> <a-d> -->
<regexp>(.*?)([ _.-]*(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[a-d])(.*?)(\.[^.]+)$</regexp>
<!-- movienamea-xvid.avi, movienameb-xvid.avi -->
<regexp>(.*?)([ ._-]*[a-d])(.*?)(\.[^.]+)$</regexp>
</moviestacking>

I thought "*" was the character for a wildcard, so when I tried to throw a "*" after pt# it just caused kodi to freeze when it encountered the files in the scan. This is the default logic:



I don't quite know what (.*?) and ([ _.-] mean in this context
Quote:(?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9]

This tells me that it locates pt and has a wildcard for the numbers 0-9. That's all I can really extract from this bit, I'm not sure what the plus means at the end of the bracket for numbers, nor do I understand the syntax for "(.*?)(.[.]+)$" that comes after it.I want it to detect any video files in a particular folder and stack them according to pt1, pt2, pt3, somewhere in the filename and stack them despite the different filenames. It should be pulling the folder name.
Is this even possible?


RE: Help with moviestacking syntax in Adve - izprtxqkft - 2023-08-03

you are working with Regular Expressions which are practically a programming language on their own by complexity

rather than try to explain all the parameters and possibilities of this i feel it would be better for you to learn on your own

paste this (?:cd|dvd|p(?:ar)?t|dis[ck])[ _.-]*[0-9] expression into https://regex101.com/ and it will explain everything it sees from the program side

paste the string you are trying to match against into the second box and you can start to see your results as you change the expression


this will be much easier for you as well as anyone attempting to explain it


RE: Help with moviestacking syntax in Adve - anonsm - 2023-08-03

Thanks for your reply. 

This website is very helpful in deciphering Regex. So it looks like I'm dealing with 4 groups here. 

Group 1 videotitle 
Group 2 part number (pt1, pt2, etc)
Group 3 anything after that (Intro, Opening, Intermission, etc)
Group 4 file extension (.mp4) 

It looks like the groups are matching, but kodi is still not picking them up and stacking them. For the third capture group, I tried (?:.*?) which created a group 0 for a non-capturing group which seemed promising, but it didn't seem to take. If group 3 is getting matches which is kodi still rejecting it? 

Image


RE: Help with moviestacking syntax in Adve - anonsm - 2023-08-03

Thank you for your reply, that website what very helpful at getting me a bit more understanding. What I essentially need to do is isolate group 3 

It looked like the examples I have set them in 4 groups 
Group 1: videoname 1
Group 2: part number (pt1, pt2, pt3, etc)
Group 3: any text after that (intro, Opening, Intermission, etc) 
Group 4: file extension (.mp4)

What I essentially need to do is isolate group 3 and get kodi to throw it out or ignore it. It's successfully "matching" all the groups by default. So why is kodi not stacking them? 

I've tried to use (?:.*?) to make a non-capturing group, it works in the editor, you linked to, it doesn't even try to count the text after "pt" as a group, but that didn't seem to work in kodi where it would just ignore the characters after group 2 and move onto group 4.


RE: Help with moviestacking syntax in Adve - Karellen - 2023-08-03

(2023-08-03, 21:19)anonsm Wrote: It looks like the groups are matching, but kodi is still not picking them up and stacking them
It's not something I use, but if IIRC there is a requirement that the filenames are identical except for the "Pt1" numbering.
Could you modify your filenames and see if it then works? If it does, you will have your answer on why it's not working.

Why not merge them and add chapter marks instead? Easier if you convert them to mkv and do that.


RE: Help with moviestacking syntax in Adve - anonsm - 2023-08-03

Yes, It does indeed work when I label them as 

Code:
videofile 1 pt1
videofile 1 pt2
videofile 1 pt3

But the problem I have is I need to keep them as separate files because after the presentation is over, I need to cherry-pick a specific section of the performance. With the videos combined, I no longer can do that, and with the filenames missing a descriptor in the name, I have issues knowing which file is what section. 

 So I'm I suppose I'm out of luck for my particular use case? There's no syntax I can write that will work?


RE: Help with moviestacking syntax in Adve - Karellen - 2023-08-03

(2023-08-03, 21:47)anonsm Wrote:  So I'm I suppose I'm out of luck for my particular use case?
Unfortunately I think you are.


RE: Help with moviestacking syntax in Adve - jjd-uk - 2023-08-03

Why do they need to be stacked?

Enable Play next video automatically see https://kodi.wiki/view/Settings/Player/Videos#Play_next_video_automatically

Then if the files reside in a folder containing only those files, then select Folder and press Play (or select Play from conext menu). This creates a temporary playlist and will automatically play each file in turn, so there should be no difference in the playback behaviour from stacked files.


RE: Help with moviestacking syntax in Adve - jjd-uk - 2023-08-03

Even without that setting enabled you can enter folder select 1st video file and open Context menu and select "Play from here" and all videos in folder will be played in turn.