Kodi Community Forum
What is the best approach to achieve "like"/"subscribe" function in an add-on - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: What is the best approach to achieve "like"/"subscribe" function in an add-on (/showthread.php?tid=307745)



What is the best approach to achieve "like"/"subscribe" function in an add-on - EinNarr - 2017-02-21

What could be the best way to achieve "like"/"subscribe" function in an add-on

The add-on I am working on is a Peer-to-Peer file sharing add-on. There is channels that users may wish to subscribe. My former idea with to add a item to the menu, which subscribe or unsubscribe after clicking, and toggle the button by refreshing the page. But with addDirectoryItem, it can only open a url. This will make the user stay on the same page after clicking "subscribe" and then "..".

Is there any better approach to achieve this kind of function?

Thx a lot for your help.


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - gedisony - 2017-02-22

context menu?
you can addContextMenuItems to each listItem before feeding it to addDirectoryItem


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - boogiepop - 2017-02-22

as gedisony mentioned
http://mirrors.kodi.tv/docs/python-docs/16.x-jarvis/xbmcgui.html#ListItem-addContextMenuItems


also:
RunPlugin(plugin) #need to specify kodi url
RunScript(script[,args]*) #need to specify absoulte paths

are the actions i suggest that will execute the actual query.


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - DarrenHill - 2017-02-22

Such an add-on would be getting close to the edges of our forum rules (wiki) I would say.


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - boogiepop - 2017-02-23

Dont confuse Tribler with other P2Ps, it is a project funded by EU and Executed by Deft University, also ran some trials with Wikipedia & BBC. They are also the guys behind IETF RFC 7574 PPSPP protocol.

https://tools.ietf.org/html/rfc7574
https://tribler.org/about.html


RE: What is the best approach to achieve "like"/"subscribe" functi... - EinNarr - 2017-02-23

(2017-02-23, 15:25)boogiepop Wrote: Dont confuse Tribler with other P2Ps, it is a project funded by EU and Executed by Deft University, also ran some trials with Wikipedia & BBC. They are also the guys behind IETF RFC 7574 PPSPP protocol.

https://tools.ietf.org/html/rfc7574
https://tribler.org/about.html

Thanks a lot for the explanation.


RE: What is the best approach to achieve "like"/"subscribe" functi... - EinNarr - 2017-02-23

(2017-02-22, 21:14)DarrenHill Wrote: Such an add-on would be getting close to the edges of our forum rules (wiki) I would say.

As mentioned in #5, the project my addon links to is kinda a academical project on self-organising systems. Could this possibly be regarded as an exception in Forum Rules 2.5.4.B? As it aims to share files in a completely decentralized and anonymous way, we can't stop some people from coming up with some bad ideas.


RE: What is the best approach to achieve "like"/"subscribe" functi... - EinNarr - 2017-02-23

(2017-02-22, 05:05)gedisony Wrote: context menu?
you can addContextMenuItems to each listItem before feeding it to addDirectoryItem

Thx for the suggestion.
How can I make it happen that after clicking on 'subscribe', the button become 'unsubscribe' to remind the user that he has subscribed successfully?


RE: What is the best approach to achieve "like"/"subscribe" functi... - EinNarr - 2017-02-23

(2017-02-23, 15:25)boogiepop Wrote: Dont confuse Tribler with other P2Ps, it is a project funded by EU and Executed by Deft University, also ran some trials with Wikipedia & BBC. They are also the guys behind IETF RFC 7574 PPSPP protocol.

https://tools.ietf.org/html/rfc7574
https://tribler.org/about.html

Thx for the suggestion.
How can I make it happen that after clicking on 'subscribe', the button become 'unsubscribe' to remind the user that he has subscribed successfully?
In another way. Is it possible to change the label of a listItem without opening a new URL?


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - gedisony - 2017-02-23

From what I've read, you can't update a listItem once it is shown to the user.

Your plugin is no longer running once the user sees the listItems.
so the only way to change the labels would be to load the list again.
I think kodi selects the last selected listItem so at least you have that.

another thing, once your user hits 'unsubscribe' your plugin needs to send the command to the server.
Chances are, the server has not finished executing the command before your plugin refreshes the list.

The easiest way would be to just show a confirmation message.
"Your request to unsubscribed from cat facts have been sent"


RE: What is the best approach to achieve "like"/"subscribe" functi... - EinNarr - 2017-02-23

(2017-02-23, 18:52)gedisony Wrote: From what I've read, you can't update a listItem once it is shown to the user.

Your plugin is no longer running once the user sees the listItems.
so the only way to change the labels would be to load the list again.
I think kodi selects the last selected listItem so at least you have that.

another thing, once your user hits 'unsubscribe' your plugin needs to send the command to the server.
Chances are, the server has not finished executing the command before your plugin refreshes the list.

The easiest way would be to just show a confirmation message.
"Your request to unsubscribed from cat facts have been sent"

Thx. So there is not a way to dynamically show whether this channel is subscribed or not subscribed? Quite a pity so.


RE: What is the best approach to achieve "like"/"subscribe" functi... - DarrenHill - 2017-02-23

(2017-02-23, 16:57)EinNarr Wrote:
(2017-02-22, 21:14)DarrenHill Wrote: Such an add-on would be getting close to the edges of our forum rules (wiki) I would say.

As mentioned in #5, the project my addon links to is kinda a academical project on self-organising systems. Could this possibly be regarded as an exception in Forum Rules 2.5.4.B? As it aims to share files in a completely decentralized and anonymous way, we can't stop some people from coming up with some bad ideas.

It's innocent until proven guilty, or more relevantly until users and others subvert it that way.

My post above was a comment and semi warning only of something to keep in mind. Hence why this thread is still active and not in the bin...


RE: What is the best approach to achieve "like"/"subscribe" function in an add-on - boogiepop - 2017-02-27

@einarr, to make your context toggeling like sub/unsub, when you add context check if item is sub or unsub first, and add conext menu accordingly,

Add your context to actuion runscript. At the end of your script that will be executed, call xbmc.executebulitin("container.refresh"). So when you call the script the container will be updated. And the context action will be toggled.


RE: What is the best approach to achieve "like"/"subscribe" functi... - tribler - 2017-04-20

(2017-02-23, 20:59)DarrenHill Wrote:
(2017-02-23, 16:57)EinNarr Wrote:
(2017-02-22, 21:14)DarrenHill Wrote: Such an add-on would be getting close to the edges of our forum rules (wiki) I would say.
As mentioned in #5, the project my addon links to is kinda a academical project on self-organising systems. Could this possibly be regarded as an exception in Forum Rules 2.5.4.B? As it aims to share files in a completely decentralized and anonymous way, we can't stop some people from coming up with some bad ideas.
It's innocent until proven guilty, or more relevantly until users and others subvert it that way.
My post above was a comment and semi warning only of something to keep in mind. Hence why this thread is still active and not in the bin...

Thank you for not putting this thread in the bin!

Some background on Tribler. I'm the faculty member at Delft University of Technology working on for the past 18 years on creating open collaborative systems that scale (pre-wikipedia). We've had many failures over the past years on how to build trust and create sustainable cooperation.
Our current Tribler work actually contained one of the worlds first primitive ledgers in Aug 2007 (pre-bitcoin), see our bandwidth-as-a-currency work together with Harvard University, http://news.bbc.co.uk/2/hi/technology/6971904.stm
With the great work going on of adding Tribler support into Kodi we're taking a new step into this long-term scientific journey. Our own 3rd generation blockchain fabric, decentral market, credit mining, and investment functions are getting ready for live usage.

Our work is sponsored by the European Union, Dutch government, banks, and various companies. They sponsor us to create a new type of online economy, with one showcase being a European Youtube-like system. Where artists can be directly paid for their content creation, without any middleman extorting their cut. This is made for the desktop and hopefully will end up in Kodi somehow. Currently there are 21 developers working with TUDelft http://blockchain-lab.org and thus you might hear more about our ongoing work in the future. As an official government employee we don't break laws and will stick to Kodi communicate guidelines. However, our scientific work is on a collision course with outdated business models.. See screenshot below of our operational code:
Image