im85288 / service.upnext

GNU General Public License v2.0
80 stars 41 forks source link

Request: Ignore Typical DVD/BR Files #271

Closed CS-Alchemist closed 1 year ago

CS-Alchemist commented 2 years ago

Is it possible to add a feature to ignore typical DVD or BR Files like .iso or .bdmv? I really like this add-on but it interprets a single Video-Element from a BR/DVD as a complete episode and will start the next entry from the library. The only workaround is to deactivate this add-on while playing such files.

MoojMidge commented 2 years ago

Can you provide a Kodi log from when you are playing an iso/bdmv when using UpNext?

Are you saying that each individual m2ts is considered as an individual episode when using UpNext? Has the iso/bdmv been scanned into your Kodi library or are you just playing the iso/bdmv from the Kodi file manager?

CS-Alchemist commented 2 years ago

Not every m2ts file is considered as an single episode. But the BR playlists are. (mpls files) These files have the playtime information that Kodi uses for the player. When I start the first BR and the first playlist is played, then the Up-Next window comes, just before the end of the first playlist. But this playlist contains only some short video clips, like the animation clip of the distributor, as well as some information about parental control and screening rights, etc. I should note that I always play such blurays with menu and call the index.bdmv for playback. I would appreciate it very much if with this playback method upnext would generally not react. Because of the BR menu and the binary files on the bluray UpNext is not necessary and Kodi can play the next episode on the disc by itself. The same applies to complete DVD-ISO rips.

Meanwhile, with the new Kodi update the problem disappeared that Upnext at the beginning of bluray playback immediately starts the next entry in the library. (here the same Bluray xD). But the Upnext Messege still appears after a few seconds, counts down its time and does nothing more.

To answer your second question: Yes all bluray rips and also DVD rips are correctly scanned and stored in the library, as well as all other video files that work with Upnext. This can be seen in the following log.

With the Bluray log it looks quite interesting from line 359. With the DVD log likewise starting from line 359

BluRay_Files.log DVD_ISO_Files.log

MoojMidge commented 2 years ago

Thanks for the log, helps to understand what is happening.

Unfortunately, from the available Python or JSON-RPC APIs, there doesn't seem to be a way to detect that Kodi is playing a disc or disc image. Could check for file types, but your Bluray log indicates that you are using strm files so checking for the file type wouldn't work reliably.

The log also seems to indicate that when opening the menu and selecting an item, the short clips that play prior to the actual episode are still considered to be same as the actual episode that follows which further complicates things.

One option may be to include a check for a minimum video length - if the currently playing video is shorter than a user configurable minimum video length then disable UpNext. However this would only help when playing the short clips between the episodes, the multi-episode files you have would still show the UpNext popup.

Will have a think to see if there is anything else that can be done.

CS-Alchemist commented 2 years ago

What if you check the filename of the current and following episode before the upnext message appears?

Or what would upnext do in case of multi-episode files, as it is described here: "https://kodi.wiki/view/Naming_video_files/Episodes#Multi-Episode_Files" ?

I used the strm files for Kodi's naming scheme, because I don't want to mess up BR's folder hierarchy or other video files. So whether .strm or .bdmv, .m2ts, etc should not matter for now.

I guess upnext wouldn't have to show anything if the current episode and the following episode are from the same file. Or am I thinking wrong?

Wouldn't it be enough if upnext only appears if these filenames are different?

I don't know all the Kodi interfaces, but if it's possible to find out the filenames and compare them, then that would be feasible, wouldn't it?

MoojMidge commented 2 years ago

That is what UpNext should do, but the combination of .strm files, multi-episode files, and BD/DVD playback messes things up a bit.

The episodes are scanned into the library as .iso or .stream files, but the file that Kodi indicates as currently playing is the .vob or .m2ts, so checking the current video playing against the next episode in the library never results in a match.

There is a way around this however - need to find the current episode in the library, check the file that has been scanned in, and use that file as a comparison with other episodes, rather than the file that is actually being played.

Had made this change to fix some other non-related issues with .stream files, but it looks like it should fix your problem as well.

MoojMidge commented 1 year ago

@CS-Alchemist can you check if the changes in #277 fixes this problem?

CS-Alchemist commented 1 year ago

The popup comes as before. Right after the first playlist of the bluray/DVD. But now suggests the next episode that has a different file.

But you helped me to understand the architecture of the plugin and I could fix the problem myself by writing the following lines after "# Find position of current episode".

#Check if current Episode is a DVD/BR with own Menu
            #ISO DVD
            if current_library_file.find(".iso") != -1:
                self.log('File is a DVD', 1)
                return None
            #Bluray
            elif current_library_file.find("index.bdmv") != -1:
                self.log('File is a Bluray', 1)
                return None
            #check if a strm file includes a DVD or BR File
            elif current_library_file.find(".strm") != -1:
                with closing(File(current_library_file)) as fd:
                    fcontent=fd.read()
                if fcontent.find(".iso"):
                    self.log('File is a DVD', 1)
                    return None
                elif fcontent.find("index.bdmv"):
                    self.log('File is a Bluray', 1)
                    return None    

This needs two imports:

from contextlib import closing from xbmcvfs import File

I need these imports to read in files that are on the network or locally with kodi. With this I check if .strm files contain typical files for DVDs or BR

I would appreciate it very much if something like this could be implemented. I have attached your api.py from #277 with my code again.

I thank you for your efforts and the time you had to provide for it.

PS: I have no idea what the function log does xD So I'm not sure if this is even necessary, or useful after all. I have simply taken over from the last return.

api.py.txt

MoojMidge commented 1 year ago

Glad you got it working, but to be honest I'm a bit confused.

Are you able to clarify what the content of the strm files are? Do they all just have a single entry pointing to the same iso or bdmv file, after which you open the episodes manually from the disc menu?

I had assumed your strm files were pointing to a series of m2ts or mpls files, but if the strm files point to the iso or bdmv file directly then something seems odd.

I have a couple of Blu-rays in my library and when I tried to play the bdmv or even the individual mpls files, I don't see the same thing as you do - there are no multiple OnAVStart or OnPlay events that occur when the the mpls loads up the different m2ts files.

I would appreciate it very much if something like this could be implemented.

It should be possible to check for an iso or bdmv file being played when UpNext first tries to start due to a video starting, rather than UpNext running, opening and checking the strm file, and then exiting. I have updated #277, can you check if this now works for you?

CS-Alchemist commented 1 year ago

Thank you very much :), your comitts in #277 just works perfectly with all my DVD and Bluray Files, when i play those with Disc-Menu.

"I had assumed your strm files were pointing to a series of m2ts or mpls files, but if the strm files point to the iso or bdmv file directly then something seems odd."

"I have a couple of Blu-rays in my library and when I tried to play the bdmv or even the individual mpls files, I don't see the same thing as you do - there are no multiple OnAVStart or OnPlay events that occur when the the mpls loads up the different m2ts files."

To clarify the questions and ambiguities I will now digress a bit and explain why I have deposited my series and movies as they are currently.

As I mentioned before, I always play my Blu-rays/DVDs with menu. With the DVD, of course, the whole thing is quite uncomplicated, because the UDF 1.02 file system is compatible with the ISO 9660 standard. This standard is fully supported by Kodi, and is also compatible with any operating system. So for a DVD there is only one image file.

But this is unfortunately not possible with the Bluray. The files on the BR are simply too big for that. That's why BluRay, unlike DVD, does not use its own image, but the files are in the standardized directories for Bluray.

If I were to play stream files (.m2ts) directly with Kodi, I would only see an excerpt from a series or movie. Audio and subtitle tracks would have no info on which track is for which language. This is of course related to the authoring of the disc, but especially with older series, an episode is split into multiple .m2ts files. For example, the opening or ending is usually one m2ts file used by multiple episodes. Also, by default Kodi would load the first audio and subtitle track, which is also not correct. Playing .m2ts files directly is therefore not an option and must be avoided.

Playing BR playlist files (.mpls) directly would be possible, but finding out which playlist files represent which episodes/movies is very time consuming. And even there only the first audio and subtitle tracks are loaded. So it's not optimal either.

With Blurays an uncomplicated playback is really only possible if they are played directly with the menu (play index.bdmv), or I pack each episode/movie in a new container and adjust the order of the tracks. But the packing in new containers is again a lot of effort and also creates unnecessary overhead, whereby for example 1000 discs too much memory is lost. So that's the reason why I only play BRs with Menu. The playback is simply much less complicated, I save memory by less overhead and enjoy the full quality as it is intended by the distributors.

But my problem was that UpNext recognized the first .mpls file referenced by the index.bdmv as a complete episode. The first .mpls is neither a movie, nor an episode. Mostly it only contains information about the distributor or contains advertisements for other series. That was also the reason why UpNext wanted to suggest the next episode to me within a minute (like you see in the provided log files).

And for this reason I have wished that UpNext generally does not react to content if a BR/DVD with menu is played. The disc itself can select the next episode without upnext having to react.

And to answer the question again why I use .strm files: I don't want to have to customize my folder hierarchy for movies and series for the scraper to find them. Kodi is not the only application that accesses my movie collection and a flat folder hierarchy that I would have to provide for the scraper is not optimal for a large movie collection as it is very difficult to find desired episodes and movies. For this reason playlists are used, which the scraper can read and deposit individual files for movies and series directly into the library. For MultiEpisodeFiles (DVD/BR) actually .strm files are used. These also usually have only one entry. I know that this is quite unusual, but this is actually the only solution that is easy to manage and I do not experience any disadvantages. Because the textfiles are created by scripts immediately and stored correctly, so that the scraper can find everything cleanly.

But the use of .strm files should be irrelevant, since this was not the problem.

So much for that.

Your commits work fine on my Kodi environments (Libreelec, Ubuntu, AndroidTV). Thanks again.