Need help to retain watch history and resume capability for my video addon
#16
(2017-08-10, 00:53)sshah93 Wrote:
(2017-08-09, 12:35)ironic_monkey Wrote: it sounds like you are doing everything correct but all the details are as important. did you remember to make them files and not directories ? you are supposed to get a callback to your add-on on that click, but something hinders it. can you extract some code maybe so we can inspect it ?

also one thing i forgot to make explicit: the url of the item you mark as playable has to be of the plugin://<your id> type.

Hello,

Sorry was at work all day Sad

Anyways, your above comment fixed it.

Esentially within the:

Code:
xbmcplugin.addDirectoryItem( )

For the url parameter, I was accidentally sending it the url itself instead of passing it u, which was:

Code:
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&fanart="+urllib.quote_plus(fanart)+"&description="+urllib.quote_plus(description)

Finally, after changing xbmcplugin.addDirectoryItem(url = u), I could finally access it from the section where we do:

Code:
if mode == ??: xxx

There after I got another error, regarding the way I setResolvedUrl, however, by looking at the python module docs, I identified, it was due to me not giving it certain parameters which it required, which were:

Code:
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)


i.e. the parameters: int(sys.argv[1]) and True


Once again thankyou very much, It finally works as I wanted it to, which is it shows me whats watched now, and gives me option to resume partly watched videos. However, 2 more final things I would like to ask if possible.

ISSUE 1:

Essentially, currently my layout for my addon directory is in the following format:

Category Directory -> video_names Directory

So from the category directory, once opened we get to view the related video_names, now I have one main category which when clicked shows all video_names list, and then the rest of the categories, simply show related video names (i.e. part of the video_names, that are found in main category),

Currently if I set a video_name item to watched on the main category, its saved as watched there, however, if I go to its sub category, the video shows as unwatched, so is there away I can tell kodi to either just look out for matching names and give them their watched status accordingly (i.e. sync all related watched data for the same video_name item, found within different directories).

ISSUE 2:
Final thing is, Like many addons, how can i add an option to the category directory item, where if I right click on my mouse, on a particular category item, on the menu that appears, is there away I can make it set an option to set all items as watched or unwatched.

Once again, Thank you, very much for your support, you have really helped me solved an issue that I was struggling with, and I hope it helps other newbs like me. Sorry for pushing my luck but I hope you can continue to aid me with solving my other 2 issues.

Cheers Smile

I am sorry to bring this up again, however I still havent been able to solve issue 2 above. Can anybody help me, please
Reply
#17
sorry so dead busy at work that this slipped out of my mind.

you would have to use json for this i think. you have a function called 'SetFileDetails', where you can fiddle with playcount (playcount > 1 == watched, 0 == unwatched).
Reply
#18
(2017-08-31, 09:21)ironic_monkey Wrote: sorry so dead busy at work that this slipped out of my mind.

you would have to use json for this i think. you have a function called 'SetFileDetails', where you can fiddle with playcount (playcount > 1 == watched, 0 == unwatched).

Hello ironic_monkey,

Thankyou very much for the quick reply. I do understand that you are extremely busy and appreciate all your continued support.

Essentially I am a little confused and was wondering if you could help me solve it.

Firstly, by visiting the Python Module Docs Xbmc Gui Web Page, I found out that to add custom context menu items we need to write the following code:

xbmcgui.ListItem.addContextMenuItems([(label, action,)*], replaceItems) -- Adds item(s) to the context menu for media lists.

The label part is straight forward, as I am just stating Mark all as watched or unwatched, but the action part is confusing as I am unsure how to use it to call a local function in where I have set it up to set all items playcount = 1 or 0, depending on which context menu item is selected.

Secondly, you mentioned about a json, and using a function called 'SetFileDetails', I am not sure about how this 'SetFileDetails' function works and how it is to be manipulated, and by doing a google search I am not understanding what people in other forums are saying about how to use it.

Esentially, if i am able to use the addContextMenuItems functions arguments parameter, to call a local function, than because I already have a local json file which saves specific data related to my video addon locally to make loading the content quicker, I have already set my code to simply add a new dictionary key called "playcount" and set its value to 1 if watched or 0 for unwatched so that when its contents are loaded it can appropriately set the relevant details.

If you would like, pm me your email or some means to reach you, and I would be glad to share with you the addon I have created and maybe by seeing my code for yourself you may be able to recommend the best solution for implementing this final feature, I am simply creating this addon to help me improve my python skills, since I have recently just graduated, as through this development process I was able to learn about what webscrapping, and regex is and I have also been able to transfer those skills to other projects I was doing in between, I am not at all certain whether if I will be publishing it, however as I said if you would like to see it please let me know, It is very stable and usable so if you like it you can use it Smile.

Please let me know how i can proceed and whether you would like me to send over my code.

Cheers.
Reply
#19
i was on about the action, not how to add the context menu entry which others should be able to answer (i'm not up to snuff on the new contextmenu treatment). you will have to use the json call to perform the watch toggle for the items sitting in the kodi database.
Reply
#20
(2017-09-01, 14:41)ironic_monkey Wrote: i was on about the action, not how to add the context menu entry which others should be able to answer (i'm not up to snuff on the new contextmenu treatment). you will have to use the json call to perform the watch toggle for the items sitting in the kodi database.


Thanks again for the quick reply,

I understand what you are saying, esentially what i meant was, is that the context menu thing i showed works, just didnt know what arguments to pass, because it doesnt allow local function calls as part of the arguments, which in your case is the json call.

Its just I wasnt sure how and what to include in the JSON call, because esentially where I wish to implement the feature of click "mark all as watched", is in a folder directory before the directory where videos are shown. So ignoring the context menu, I just need to know how to make the JSON call, and then once done, how can i reference the updated JSON when i open the directory with the video items so that I can tell kodi whether to set each videos play count value to 0 or 1, based on user selection.

you mentioned "items sitting on kodi database", would this still work if certain items are not in the database, because I am trying to make it so that the old videos I watched online already can be easily marked as watched, without having to manually do them one by one.

I am really sorry for all the trouble, I just reposted the other day, because no one else replied, replied and therefore wanted to bring this post back up to recent so others could also possibly view and support.

Thank you very much.
Reply
#21
whenever some file is played in kodi, it is added to the database to track watch state, video settings etc. this was the whole reason we needed static urls in your plugin in the first place, remember? if there is no entry, i'm fairly certain SetFileDetails adds them.

the action would be a built-in function, of particular interest is 'RunScript(/path/to/some/script/which/does/whatever)'. the path can for instance be to a script in the add-on data for your plugin.
Reply

Logout Mark Read Team Forum Stats Members Help
Need help to retain watch history and resume capability for my video addon0