elgatito / plugin.video.elementum

Elementum add-on for Kodi. Development of this addon has been stopped!
http://elementum.surge.sh
MIT License
467 stars 157 forks source link

[Bug] Playback progress from Kodi Library doesn't update progress in Elementum #959

Open burekas7 opened 6 months ago

burekas7 commented 6 months ago

@elgatito @antonsoroko Following to this issue: https://github.com/elgatito/plugin.video.elementum/issues/782

When I'm watching through Elementum, the progress is updating also in the Kodi Library item. But when I'm watching through Kodi Library, the progress isn't updating in Elementum (Trakt Movies Collection, for example. Movie: Jurassic World Dominion)

still show 18% instead of 24%

Maybe it does update in the background, but the list itself n Elementum isn't updating/refreshing. I don't know. Like the problem I have here: https://github.com/elgatito/plugin.video.elementum/issues/680

Kodi debug log: https://paste.ubuntu.com/p/TKSRyyM7Bj/plain


Elementum 0.1.98

antonsoroko commented 6 months ago

@burekas7

When I'm watching through Elementum, the progress is updating also in the Kodi Library item. But when I'm watching through Kodi Library, the progress isn't updating in Elementum

i see now. looks like there was misunderstanding between us.

there is no sync of "playback % progress" from trakt to elementum internal items. only "kodi library"<->trakt via elementum as a "middle man". but not "elementum internal items" <-> trakt.

for this specific use case, when user do not use kodi library at all, I made #782 .

but this does not mean that

So actually there is no way to share this progress with other devices?

multi device sync works, as elgatito said before, but you just need to use Kodi library menus (not elementum internal menus).


i thought that multi device sync does not work for you, that's why i asked you to create new issue. but this "issue" is basically a duplicate of "feature request" #782 .

burekas7 commented 6 months ago

@antonsoroko

Thanks. So I will test the "multi-device-kody-libraries-sync" and then I will close it.

Regarding the main issue, we will discuss on it back in your issue: https://github.com/elgatito/plugin.video.elementum/issues/782

elgatito commented 3 months ago

@burekas7 Can you elaborate on this one.

Movie: Jurassic World Dominion is it in Kodi library? Pointing to Elementum? Or other plugin or video file? It is also in Elementum library?

When you open it from Kodi library - you play it with Elementum and then trying to open same item, by searching for it in Elementum, and expecting to see changed playback progress?

burekas7 commented 3 months ago

@elgatito Yes, the kodi library content is base on Elementum. As I said it's working only in one direction. When playing in Elementum addon, the progress is updated also in Kodi Library. But when playing it from Kodi library, the progress isn't updated in Elementum.

elgatito commented 3 months ago

Do I understand the reproduce way right: 1) Have something in Kodi library added. 2) Open that item from Kodi library. 3) Open same item from Elementum, but it does not propose to continue from place where it stopped, when started from Kodi library.

Trakt sync is turned off or enabled?

burekas7 commented 1 month ago

Do I understand the reproduce way right:

  1. Have something in Kodi library added.
  2. Open that item from Kodi library.
  3. Open same item from Elementum, but it does not propose to continue from place where it stopped, when started from Kodi library.

Trakt sync is turned off or enabled?

Yes, Trakt sync is enable.

And yes regarding the flow. In Kodi Library for example the tag shows "17%" But in Elementum (Trakt Collection -> {TV_Show} -> {Episode}) it isn't synced with that.

The opposite does work. When watching in Elementum the progress is synced with Kodi Library.

antonsoroko commented 1 month ago

that's true. but if you open that item in elementum and you will continue playback (if you have this option enabled - it will take % from kodi) and then stop playback - then poster will be updated with % in elementum collection/etc.

so it is a bit tricky situation.

burekas7 commented 1 month ago

@antonsoroko No, that's not what's happening. If I click on the same item in Elementum it starts the watching from the beginning, it has no idea about the watching status from the library in Kodi.

And as I say if I will stop during the playback, it will update the status in Kodi library, But it doesn't work the other way when watching in Kodi Library, Elementum isn't update/synced.

antonsoroko commented 1 month ago

@burekas7 it is happening for me. otherwise i would not have written about that. have you seen

(if you have this option enabled - it will take % from kodi)

try to use different values for this option.

antonsoroko commented 1 month ago

@elgatito as i can see in your log - you changed that settings, so things do not work as expected :-)

for https://github.com/elgatito/plugin.video.elementum/blob/d06801d6f2682ef8a8d31e9ba77a3149b4b18aaa/resources/language/messages.pot#L2013 https://github.com/elgatito/plugin.video.elementum/blob/d06801d6f2682ef8a8d31e9ba77a3149b4b18aaa/resources/settings.xml#L16 default is 1 which is https://github.com/elgatito/plugin.video.elementum/blob/d06801d6f2682ef8a8d31e9ba77a3149b4b18aaa/resources/language/messages.pot#L2021

but you changed it to 0 (see in log PlayResumeAction: 0,) which is https://github.com/elgatito/plugin.video.elementum/blob/d06801d6f2682ef8a8d31e9ba77a3149b4b18aaa/resources/language/messages.pot#L2017

so resume works only for Kodi library items.

if you want resume to work with both kodi library items and elementum items set it to: a. "by Elementum - Ask" (default) - but in library it will ask you twice (kodi dialog and elementum dialog), in elementum once b. "by Elementum - Force" - this will ask you once in library (kodi dialog) and 0 in elementum

(also you can do Library - Videos - Default Select Action, change it to "Resume" , so kodi will also force resume - thus 0 dialogs about resume)

in future - please check your settings first.


(there is still a small UI issue that before you open video in elementum menu, video will not have progress bar on its poster, but after you open video at least once - progress bar will appear. but i do not see an easy way to solve it in code. maybe elgatito knows. but anyway this is not the issue you described. it is a UI bug, not a sync bug.)

burekas7 commented 1 month ago

@antonsoroko @elgatito

Trust me I know this setting well enough, and I suppose I had a good reason for choosing to set it like this: A detailed discussion I had in the past about this - https://github.com/elgatito/plugin.video.elementum/issues/660

So there is no optional to keep this setting as it is now and make that works?

And as you mentioned, it requires clicking to update the display of the percentages on the item

antonsoroko commented 1 month ago

@burekas7

this is quite complicated. unfortunately https://github.com/elgatito/plugin.video.elementum/issues/660 does not give person a full context and understanding why "by kodi" does not work for plugin's items and why "by Elementum" was added.

so context: there is kodi's library. it managed by kodi and consists of real items. not plugin's items or else, but real files. but for example, .strm file can refer to plugin item (to a plugin's path). there is plugin's item - they are created dynamically (ListItem structure) and point to plugin itself, like plugin://script.skin.helper.widgets/?action=movieslisting or plugin://plugin.video.elementum/library/movie/play/12345 (path).

so now you should see that there is no real connection between kodi's library and elementum's library. elementum make request to kodi to find some video in kodi's library when we need to interact with kodi's library.

as you can see in code https://github.com/elgatito/elementum/blob/ff8de0367514b29fac4d1a88d5ee2896f6b0e019/bittorrent/player.go#L347 if you chose "by Kodi" then elementum does nothing. so if kodi somehow has data about item (e.g. you already opened video before) - it will show you resume dialog.

if you chose "by Elementum" - then elementum get resume data from its own database and apply it after video starts. also, that's why there is no "progress" on poster until you click on it.

btw, about this from old issue:

When there is previously torrent that is saved in Elementum, and you choose "No" in this dialog, and choose another torrent from the results, the Resume dialog doesn't show up if you choose a different torrent.

elementum stores resume data for torrent, not for tmdb id or else. thus change of torrent means that there is no resume data thus no dialog.

(elgatito can correct me if i explained it wrong.)


I guess there is a "solution" to make "by Kodi" work with elementum's items: when we create ListItem we need to make request to kodi and ask if kodi has this item (by TMDB id) in and this item has resume data. if so - we apply ResumeTime to our ListItem.

i made a test build with such change - looks like it works.

please test: plugin.video.elementum-v0.1.103-3-gb35ce2b.windows_x64.zip

what i did is simple: inside of https://github.com/elgatito/elementum/blob/ddd98e3e79cf4c2aa3ac08ff548079730e47fe30/tmdb/movie.go#L483

    if lm, err := uid.GetMovieByTMDB(movie.ID); lm != nil && err == nil {
        item.Info.DBID = lm.UIDs.Kodi
    }

i added

        if lm.Resume != nil {
            item.Properties.ResumeTime = strconv.FormatFloat(lm.Resume.Position, 'f', 6, 64)
            item.Properties.TotalTime = strconv.FormatFloat(lm.Resume.Total, 'f', 6, 64)
        }

and same for episode type (and also same for trakt types, if you use forceTrakt option). obviously this work only when you have kodi's library integration enabled in elementum's settings.


if your test will be satisfactory then i will publish PR.

burekas7 commented 1 month ago

@antonsoroko @elgatito Thank you for the detailed explanation.

And I tested the version, it works!

Unless I saw that you might be intending to check another way? https://github.com/elgatito/plugin.video.elementum/issues/782#issuecomment-2125624927

antonsoroko commented 1 month ago

@burekas7 nice. i have published a fix. hopefully elgatito will review it at some point.


to clarify: this fix is only about situation when you have library integration enabled. since we already have all the code about library and code about "resume data" sync from trakt to library - it was easy to fix. this resume data is per library video.

but we also have internal "resume data" (it is not received from trakt, but from kodi's player when you play video) that is used by option called "by Elementum". this resume data is per torrent.

and in #782 the idea is to get resume data from trakt even when user do no use kodi library (for people like me). this data will be per TMDB id.

and obviously we will have to deal with some issues because we will have 3 sources of "resume data". e.g.: which sources has more priority, how to make sure that all items (kodi/elementum) has same resume time, how to make sure that if you play in one place - then in other place resume also was updated.

what i mean: fixing #782 would require more effort. thus hard to tell when it will be done.

burekas7 commented 1 month ago

@antonsoroko It seems there is a bug with the solution maybe. While watching from Kodi Library and stopping the playback, the watching progress is synced from Kodi to Elementum. But Episodes 6,7 are episodes that I finished to watch, but it shows them with progress value. (First I thought it happened because Trakt was down for a while, but I don't think it's the reason, maybe the solution is good only when stopping the playback, not when done watching.)

EDIT: The TV Shows -> Progress -> Was updated after a while, But TV Collevtion -> Still the same, even though the unwatched episode count is correct

Elementum screen shots: image image

Kodi Library: image

antonsoroko commented 1 month ago

@burekas7 how exactly you get such state of progress? i can only imagine something like this:

  1. open video in kodi library and watch until 30%
  2. open same video in elementum menu (i used collection) and see that it is indeed 30%
  3. watch video until 60%
  4. open same video in kodi library and see that it is indeed 60%
  5. watch video until the end (100%) and see that it is marked as watched in kodi library
  6. find same video in elementum menu and see that it still 60%? (or else)

i mean: i need "steps to reproduce the issue". please try steps above to see if they reproduce the issue. and if you have your own steps - please provide them too.


tried my steps and i got the issue. kodi sets ResumeTime property to 0 when you watched video. and we get that 0. and then we set our item's ResumeTime to 0. but kodi ignores that. i see that kodi stores ResumeTime for plugin's items as well. thus kodi apply that time anyway (after we apply our ResumeTime). i do not see a way to "fix" that, since i do not see a way to get that resume data from kodi, it looks like internal data.

you can enable debug in kodi and install context.elementum and use menu "elementum menu -> Information" and it will print debug info into log, including ResumeTime. for kodi library item it is 0 (same 0 we get via JSON-RPC API), but for elementum item kodi says previous number (5027 for me).

then you can install https://sqlitebrowser.org and open .kodi/userdata/Database/MyVideos121.db and find that ResumeTime number (timeInSeconds column): image and file id=10366 is image

but in kodi it is 0 (empty) image and path to item is different of course (id=11420) image

image

so the issue again is the fact that kodi library's item is one thing and elementum's item is another thing and they are not connected. so small hack (like i did) will not help to really connect those 2 entities.


even though the unwatched episode count is correct

that's because ListItem.PlayCount was updated and it is more than 1 (thus considered as watched). and we search for PlayCount by tmdb id.


if you did different steps - then maybe we can fix it for different steps, but for steps i described - i do not see a way to fix it.

antonsoroko commented 1 month ago

@burekas7 okay, i found Files.SetFileDetails RPC call that can set resume data to any file. so i added code that will check if elementum's item is in kodi library and if so - it will set resume data to a elementum's item path (like plugin://plugin.video.elementum/movie/1029575/links/The%20Family%20Plan%20%282023%29). full list of code changes - https://github.com/elgatito/elementum/pull/134/files

looks like it works. hopefully it will not affect performance.

please test: plugin.video.elementum-v0.1.103-3-gb35ce2b.windows_x64.zip


btw, there is a neat tool to explore kodi's RPC - https://forum.kodi.tv/showthread.php?tid=172734

burekas7 commented 1 month ago

@antonsoroko Thanks, it works. The items are now shown as "watched", the same as Kodi Library

antonsoroko commented 1 month ago

@burekas7 can you please test it for a week or more? Maybe there will be some side effects because of this new integration. I do not use library (i have it only on my development device) so i will not see such side effects.

burekas7 commented 1 month ago

@antonsoroko I'm getting an error when trying to open the menu Movies -> Trakt > My Collection error <general>: ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host Then Elementum restart itself.

Log: https://paste.ubuntu.com/p/JTfwbV2pqd/plain

antonsoroko commented 1 month ago

@burekas7 oh, i see that you use almost all non-standard options :-D which is very good for testing :-) in this case it is about ForceUseTrakt. i use only tmdb (since trakt does not support proper translations) so i missed one small change for trakt movies. if you do not care about translation - with ForceUseTrakt=true elementum should be slightly faster.

please try: plugin.video.elementum-v0.1.103-3-gb35ce2b.windows_x64.zip


btw, InternalProxyEnabled and InternalDNSEnabled should be used only if really needed. InternalProxyEnabled right is only useful for debugging, or to "override" burst's python HTTP client with elementum's golang HTTP client - in some rare situations it can help with anti bot protection. InternalDNSEnabled is useful if you need to unblock some site (like TMDB) that use very simple block based on DNS records, but you do not want to change your OS/router DNS settings.

in all other situations those 2 options will make your elementum less stable and less fast.


also when you post link to "plain" log - paste.ubuntu.com forces user to login into ubuntu.com site (try to open it in incognito window, for example). would be better to post "standard" link.