Win Problems with initializing my first addon
#1
Hi,
I've been trying to get started on plugin development. I'm kind of a beginner at python, so don't mind me writing some stupid questions. I know the basics, and what I don't know I can always learn. However Kodi addons are a huge step up for me, since there aren't many examples on getting started. I wanted to start off with some basics. A simple search engine. Just a text field and a confirm button at the bottom similarly to the YouTube addons search button. Whenever I click open on the addon, I want a new window to popup. However I can't get the window to show. I usually ask ChatGPT to generate some starting code, so that's the first thing I did. After solving a bunch of errors I keep getting stuck on these two problems. It either does nothing with no errors related to the project, or it loops indefinitely with no way to go back to the previous menu. Right now it doesn't loop and doesn't run at all. I will post both the addon.xml file, and the plugin.py file below, both of which are contained in the same directory. The icon and fanart of Spotify, are from the existing Spotify plugin, so I won't share them here. Here are both the files:
https://paste.kodi.tv/inugevamig.kodi
https://paste.kodi.tv/onejazicic
If anyone can explain to me what I'm doing wrong, please tell me. Thanks in advance!
Reply
#2
Thread moved to addon development, where you may find a better chance of such support.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#3
Thanks DarrenHill, for moving the topic. I didn't see the development header above Addons. I guess I just didn't scroll down enough.
Reply
#4
I see multiple problems whith your code:
  1. Why this 2 level code structure? One class will do just fine.
  2. You don't call .doModal() method for your custom dialow window so it is never displayed.
  3. It is strange that you don't use ControlEdit for entering text.
  4. Also, if you are creating a Python-based UI for your addon from scratch you need to provide textures for some of the controls, including buttons, otherwise they will not be displayed correctly.

As a a bit of a self-promotion I'd recommend you to check PyXBMCt library that simplifies creating a custom Python-based UI for your addons: https://github.com/romanvm/script.module.pyxbmct
It's a wrapper around some of xbmcgui classes that provides API similar to desktop GUI libraries like PyQt and also included all the necessary textures.

Addon UIs can also be skin-based when all the controls are defined in an XML file like in Kodi skins. Skin-based UIs are more-feature rich than pure-Python ones.
Reply
#5
Thank you Roman_V_M for summing up some issues. As I said, I'm still very much a beginner at python, let alone kodi plugin development, I'll try to reply to each one of the points you made.
1. I don't know what you mean by 2 level structure. I'm guessing you mean the part where I call the Plugin class, and in that class, I do nothing but call the MyClass. It's probably unnecessary, so I'll remove it. However if it means something else, please explain it. 
2. I've tried to do the same thing as another script, which just called an entire class, instead of anything related to .doModal(). I've also seen some scripts that use .doModal(). Can you explain to me why I should use .doModal(), and what the difference is?
3. Can you give me an example of how I would use ControlEdit?
As for the rest, I don't mind the self promotion. I wouldn't have found it otherwise. It seems easier to use then to provide custom textures. I'll try writing something with the use of your library. 
Thank you for replying, and if I get stuck again, I'll post it here.
Reply
#6
I'm stuck again. I tried to start off simple and use the second example code provided by your webpage. With no error, nothing appears when I open/run the plugin. I'm on Kodi version 20.2. I just checked and there appears to be a version 20.3 & 20.4. I guess I haven't updated in a while. I will do so as soon as I get this to work. Can you help me?
Reply
#7
(2024-02-11, 21:09)FirePower Wrote: 1. I don't know what you mean by 2 level structure. I'm guessing you mean the part where I call the Plugin class, and in that class, I do nothing but call the MyClass. It's probably unnecessary, so I'll remove it. However if it means something else, please explain it. 

I mean that having 2 classes when one of them does nothing but wraps another class does not make much sense.
 
(2024-02-11, 21:09)FirePower Wrote: 2. I've tried to do the same thing as another script, which just called an entire class, instead of anything related to .doModal(). I've also seen some scripts that use .doModal(). Can you explain to me why I should use .doModal(), and what the difference is?

doModal() is the method that displays your Window instance and starts the event loop for accepting controller events.  I recommend to start with reading the documentation for xbmcgui classes. There's official documentation: https://xbmc.github.io/docs.kodi.tv/mast...mcgui.html and unofficial one: https://romanvm.github.io/Kodistubs/_aut...ow.doModal
 
(2024-02-11, 22:06)FirePower Wrote: I'm stuck again. I tried to start off simple and use the second example code provided by your webpage. With no error, nothing appears when I open/run the plugin. I'm on Kodi version 20.2. I just checked and there appears to be a version 20.3 & 20.4. I guess I haven't updated in a while. I will do so as soon as I get this to work. Can you help me?
Yes, the examples are pretty old but I can assure you that they are still relevant and should work because there wasn't any major changes in Kodi or PyXBMCt since then. I'd recommend to turn on debug logging in your Kodi and always check the log if something does not work.
Reply
#8
Hello again! I've been quite busy with my addon these past couple of days. Turns out my PC was the issue. It had nothing to do with the script being outdated, my computer is somehow just not running it properly. After installing Kodi on my laptop, the example ran, and I've been koding ever since. Thanks again for providing such an easy way to develop on Kodi's addons. PyXBMCt really makes things more clear. However the reason I'm back was that my addon might need a second window to select one of the search results. After you click one of the search results, I want Kodi to start another class, and then return to the first window. Now for my question, what is the best way to switch from one dialog/window to another, and back? Can you show me an example of how that would be done?
Reply
#9
My question still remains, but in the meantime I tried to add it myself. What I've got shows another window, but doesn't wait for a button click, when it's supposed to. I will post one python script from before I added a second dialog, and one after. Basically I added a third example_button, which connects to a def button_dialog which runs a second class. The class is basically the same example as before (on your webpage), but I replaced the MyAddon occurances with MyAddon2, and every occurance of self with self2. That's about all thats different, however I still don't understand why it launches both dialog's at once. I will post the differences as a 3rd paste.
Before:
https://paste.kodi.tv/hayaqopigi.kodi
After:
https://paste.kodi.tv/jereceqolo.kodi
Difference:
https://paste.kodi.tv/atagamehis
I also get this error which I can't figure out if it happens before or after clicking the example button. I also don't know what the error means:
https://paste.kodi.tv/aboxahawuc.kodi
Reply
#10
self.connect(self.example_button, self.example_dialog("Example"))

You should connect function objects, not function calls. Have you read the documentation?
Reply
#11
I read parts of the documention, but could not find anything on connecting a second dialog, only actions in the same dialog. Again I'm no expert, so I might've missed it. I started with the example provided on the page, and copied over some parts from the demo. After some modifications I ended up here. Also After some results on the difference between function objects and calls, I (well mostly ChatGPT) found a solution. Adding lambda: in the line you provided worked. If anyone's curious, this is the modified line:
Code:
self.connect(self.example_button, lambda: self.example_dialog("Example"))

Thanks for your reply. If I need help again, I will reply again. Once my addon is finished, I will close the thread. Until then, have a nice day!
Reply
#12
Hello again. After some more trial and error, I finished one part of the addon, but I still want to add something to it. While I could get a direct URL from SpotDL, I also want a way to handle it inside of the YouTube plugin. After that I was thinking of making my project public. My apologies for not reading the wiki thoroughly. I saw that about an hour after posting my comment.
As for the questions, I've got a few. I'll sum them up down here:
1. Is it possible to send a YouTube URL to the YouTube addon, and let it handle the playback from there? If so how?
2. Can you help me with adding some settings to the addon? I don't think you can search spotipy without credentials, and I don't want everyone to use mine. Unless you know a way without credentials.
3. This is the first project I want to post on GitHub. Can you help me with a good tutorial on how to get started?
4. I'm also quite unfamiliar with what I am allowed to post there and what not. Am I allowed to include a binary of SpotDL? Since it's already built I wasn't sure if I'm allowed to share it or not. Both spotipy and SpotDL are under MIT License, but the text for that license is too complex for me to understand this simple question.
5. I did however read you need to provide the MIT License somewhere in you addon. Is the plugin description good enough? Or do I need to provide the actual license.txt file?
Reply
#13
(2024-03-06, 19:21)FirePower Wrote: Is it possible to send a YouTube URL to the YouTube addon, and let it handle the playback from there? If so how?

Player.Open(plugin://plugin.video.youtube) - https://kodi.wiki/view/JSON-RPC_API/v13#Player.Open
addon parses sys.argv for parameters so you will have to find out what you need to pass to it - https://github.com/anxdpanic/plugin.video.youtube
 
(2024-03-06, 19:21)FirePower Wrote: Can you help me with adding some settings to the addon?

https://kodi.wiki/view/Add-on_settings
(2024-03-06, 19:21)FirePower Wrote: This is the first project I want to post on GitHub. Can you help me with a good tutorial on how to get started?

https://docs.github.com/en/repositories/...positories
 
(2024-03-06, 19:21)FirePower Wrote: Am I allowed to include a binary of SpotDL?

allowed or not allowed aside you're going to have issues including binaries in addons in general
and it looks like they don't provide anything for Android or OSX anyway so you will be limiting your audience
Reply
#14
Wow, that was quick. Thank you for your reply. After two clicks from visiting, I found this reference to playing youtube URLs form other plugins in Kodi. Thank you for providing the first link. As for this one, it should help me get started on GitHub. I can't thank you enough. I guess you're right about including binary's in my project. However with my limited knowledge about python, and the 207781 lines of code I would have to read to get SpotDL working on any platform... Maybe I'm just lazy, but for now it works, I guess I'll just post it to GitHub with the binaries. In the future I might get back to learning how SpotDL works, and post it without the binaries. As for the settings, I will start reading on that soon.
Reply
#15
My apologies, I refreshed my browser and forgot to add in the links. The first one is this one, and the second is this one
Reply

Logout Mark Read Team Forum Stats Members Help
Problems with initializing my first addon0