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

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #1
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.
(This post was last modified: 2017-02-23 21:35 by EinNarr.)
find quote
gedisony Offline
Senior Member
Posts: 187
Joined: Mar 2015
Reputation: 12
Post: #2
context menu?
you can addContextMenuItems to each listItem before feeding it to addDirectoryItem
find quote
boogiepop Offline
Junior Member
Posts: 45
Joined: Jan 2015
Reputation: 2
Post: #3
as gedisony mentioned
http://mirrors.kodi.tv/docs/python-docs/...tMenuItems


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.
(This post was last modified: 2017-02-22 16:46 by boogiepop.)
find quote
DarrenHill Offline
Team-Kodi Minion
Posts: 5,416
Joined: Oct 2014
Reputation: 123
Location: UK, except when I'm not.
Post: #4
Such an add-on would be getting close to the edges of our forum rules (wiki) I would say.

| Banned add-ons (wiki) | Forum rules (wiki) | First time user (wiki) | FAQs (wiki) | Troubleshooting (wiki) | Add-ons (wiki) | Free content (wiki) | Debug Log (wiki) |
find quote
boogiepop Offline
Junior Member
Posts: 45
Joined: Jan 2015
Reputation: 2
Post: #5
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
(This post was last modified: 2017-02-23 15:26 by boogiepop.)
find quote
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #6
(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.
find quote
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #7
(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.
find quote
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #8
(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?
find quote
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #9
(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?
find quote
gedisony Offline
Senior Member
Posts: 187
Joined: Mar 2015
Reputation: 12
Post: #10
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"
find quote
EinNarr Offline
Junior Member
Posts: 21
Joined: Feb 2017
Reputation: 0
Post: #11
(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.
find quote
DarrenHill Offline
Team-Kodi Minion
Posts: 5,416
Joined: Oct 2014
Reputation: 123
Location: UK, except when I'm not.
Post: #12
(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...

| Banned add-ons (wiki) | Forum rules (wiki) | First time user (wiki) | FAQs (wiki) | Troubleshooting (wiki) | Add-ons (wiki) | Free content (wiki) | Debug Log (wiki) |
find quote
boogiepop Offline
Junior Member
Posts: 45
Joined: Jan 2015
Reputation: 2
Post: #13
@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.
(This post was last modified: 2017-02-27 09:18 by boogiepop.)
find quote
tribler Offline
Junior Member
Posts: 2
Joined: Mar 2015
Reputation: 2
Post: #14
(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: a4ea0496-005b-11e7-83bb-7301980efaf6.png]
find quote