First Plugin - Incorrect Add-on Structure?
#1
Hi all,

I'm as new as they get Smile. I'm trying to make a very simple add-on that lists popular images from Instagram using xbmcswift2. I *think* I have something that works, but I can't get the add-on to install. I tried just adding the folder to the add-on directory and that didn't work, so I zipped it up and tried to install it as a zip, which returned the error that the add-on didn't have the correct structure.

Here's my file structure and code. Any idea what mistake I'm making?

/plugin.image.fungrams
addon.py
addon.xml
changelog.txt
icon.png
LICENSE.txt
/resources
__init__.py
/language/English/strings.xml
/lib/__init__.py
/lib/resources/instagram

addon.py
Code:
from xbmcswift2 import Plugin
from resources.lib.instagram.client import InstagramAPI

__addon_id__ = 'plugin.image.fungrams'
__addon_name__ = 'Fungrams'

plugin = Plugin(__addon_name__, __addon_id__, __file__)

# Setup the Instagram API

CONFIG = {
    'client_id': 'xxx',
    'client_secret': 'xxx'
}

api = InstagramAPI(**CONFIG)

# Make the only menu option show popular photos, for now.

@plugin.route('/')
def show_menu():
    item = {
        'label': 'View Popular Photos',
        'path': plugin.url_for('show_popular'),
    }
    return [item]

# Write plug-in route for popular photos

@plugin.route('/popular')
def show_popular():
    items = [{
        'label': photo.id,
        'thumbnail': photo.images['standard_resolution'].url,
        'path': photo.images['standard_resolution'].url,
        'is_playable': True,
    } for photo in api.media_popular(count=20)]
    return plugin.finish(items)

if __name__ == '__main__':
    plugin.run()

addon.xml
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.image.fungrams" name="Fungrams" version="0.1" provider-name="dicefordeath">
  <requires>
    <import addon="xbmc.python" version="2.0"/>
    <import addon="script.module.xbmcswift2" version="1.1.1"/>
  </requires>
  <extension point="xbmc.python.pluginsource" library="addon.py">
    <provides>image</provides>
  </extension>
  <extension point="xbmc.addon.metadata">
    <platform>all</platform>
    <language></language>
    <summary>Instagram Add-on for XBMC</summary>
    <description>View currently popular photos on Instagram</description>
  </extension>
</addon>
Reply
#2
Your structure and addon_id usage looks correct.
Also, just putting the folder "plugin.image.fungrams" (and its files) in your addon-dir should be enough for having it visible in XBMC (after xbmc restart) under picture/add-ons. Maybe there is a hint in Debug Log?

The only issue I can see is that your version is not in x.y.z format, not sure if this causes your issue.

To have it installable as .zip you should name the .zip "plugin.image.fungrams-0.0.1.zip", the .zip should contain a "plugin.image.fungrams" folder and all files in there.

regards,
sphere
My GitHub. My Add-ons:
Image
Reply
#3
Ah, you're right. I left the version off the zip, which prevented it from being installed that way.

I also didn't know I needed to reboot xbmc to get my new add-on to show up. Once I did that, it appeared and was enabled. Looks like it's busted, so I have some debugging to do Smile.

If I modify the files in my add-on directory, do I need to reboot xbmc every time, or will it recognize the new / modified files automatically when I try to run it?
Reply
#4
(2013-01-05, 20:29)dfdeath Wrote: Ah, you're right. I left the version off the zip, which prevented it from being installed that way.

I also didn't know I needed to reboot xbmc to get my new add-on to show up. Once I did that, it appeared and was enabled. Looks like it's busted, so I have some debugging to do Smile.

If I modify the files in my add-on directory, do I need to reboot xbmc every time, or will it recognize the new / modified files automatically when I try to run it?

No reboot needed to test.
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Ok, thanks so much.

One other question while I have you: it looks like the Instagram API client I'm using uses the httplib2 module, which is causing my add-on to fail.

I did some digging, and it looks like XBMC doesn't play nice with httplib2.. is that accurate? If so, I'm guessing the client for the Instagram API I'm using won't work?

Thanks again!
Reply
#6
(2013-01-05, 21:00)Martijn Wrote: No reboot needed to test.
When copying a new add-on to the addons dir a _restart_ is needed.

Regarding httplib2 I dont know any issues.
My GitHub. My Add-ons:
Image
Reply
#7
(2013-01-05, 21:20)sphere Wrote:
(2013-01-05, 21:00)Martijn Wrote: No reboot needed to test.
When copying a new add-on to the addons dir a _restart_ is needed.

Regarding httplib2 I dont know any issues.

Yes but when changing your py files that not needed.
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#8
(2013-01-05, 21:22)Martijn Wrote: Yes but when changing your py files that not needed.
Yes but that wasn't the question Tongue

My GitHub. My Add-ons:
Image
Reply
#9
(2013-01-05, 20:29)dfdeath Wrote: If I modify the files in my add-on directory, do I need to reboot xbmc every time, or will it recognize the new / modified files automatically when I try to run it?

Wink
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#10
(2013-01-05, 21:33)Martijn Wrote:
(2013-01-05, 20:29)dfdeath Wrote: If I modify the files in my add-on directory, do I need to reboot xbmc every time, or will it recognize the new / modified files automatically when I try to run it?

Wink

Damn, you are right. I overlooked this one Wink
My GitHub. My Add-ons:
Image
Reply
#11
Thanks for your help, guys! I got it working.

One more quick question, since I haven't been able to find much on my own: in order to pull photos from a user's stream, I need to get them authenticated with Instagram. They use OAuth 2.0 and require that the user be redirected to their server in order to login. It looks like I can't do this with a simple CURL request, etc.

Is such a thing possible? I'm not sure where to start.
Reply
#12
I'm looking/in the process of making my first plugin as well.  I see you have client_secret and client_id and assume you will be using some sort of Oath authentication? If I am incorrect, ignore my question.

Is that an improper way of storing the client_id/secret and if so, would anyone know of a proper way?  From what I have been reading, it sounds like the client_id can be public and built into the code, but the secret seems to be the real issue as it's not suppose to be known by any user/hacker.

Edit: just realized this was back in 2013 :/
Reply

Logout Mark Read Team Forum Stats Members Help
First Plugin - Incorrect Add-on Structure?0