Using script.module.googleapi
#1
I've been using the googleapi in my addon. But I've read its best if my addon does not keep its own copy of the google api, but includes script.module.googleapi.

When including this line in my addon.xml:
Code:
        <import addon="script.module.googleapi"   version="1.4.0"/>

And adding
Code:
from apiclient.discovery import build
to my script, results in the following error:

Code:
22:10:41 T:5244   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: No module named oauth2client
                                            Traceback (most recent call last):
                                              File "C:\Users\Mich\AppData\Roaming\Kodi\addons\plugin.video.youtubelibrary\addon.py", line 52, in <module>
                                                from resources.lib import ytube
                                              File "C:\Users\Mich\AppData\Roaming\Kodi\addons\plugin.video.youtubelibrary\resources\lib\ytube.py", line 22, in <module>
                                                from apiclient.discovery import build
                                              File "C:\Users\Mich\AppData\Roaming\Kodi\addons\script.module.googleapi\lib\apiclient\discovery.py", line 53, in <module>
                                                from apiclient.errors import HttpError
                                              File "C:\Users\Mich\AppData\Roaming\Kodi\addons\script.module.googleapi\lib\apiclient\errors.py", line 26, in <module>
                                                from oauth2client import util
                                            ImportError: No module named oauth2client
                                            -->End of Python script error report<--

How should I include script.module.googleapi? As far as I can see, I've included everything as the documentation says.
Reply
#2
Add <import addon="script.module.oauth2client" version="1.4.7"/> to your addon.xml dependencies. I can't remember if there are other modules that need to be added as well.
Reply
#3
(2015-10-28, 01:21)learningit Wrote: Add <import addon="script.module.oauth2client" version="1.4.7"/> to your addon.xml dependencies. I can't remember if there are other modules that need to be added as well.
Thanks for your answer. I've tried this earlier and I've tried it again exactly as you posted it, I still get the exact same error: "ImportError: No module named oauth2client".
Confused

I checked, and i do have script.module.oauth2client in my addons directory.
Reply
#4
(2015-10-28, 01:21)learningit Wrote: Add <import addon="script.module.oauth2client" version="1.4.7"/> to your addon.xml dependencies. I can't remember if there are other modules that need to be added as well.

Sorry, this needs to be added to the script.module.googleapi addon.xml (not your addon's addon.xml), at least that's how I got this working. I can't remember if the correct oauth2client version is 1.4.7 or 1.3.2, it looks like it might make a difference. It was a few months back that I was trying some things out for Google+ and Vevo and really can't remember how I got it working.
Reply
#5
(2015-10-28, 01:56)learningit Wrote:
(2015-10-28, 01:21)learningit Wrote: Add <import addon="script.module.oauth2client" version="1.4.7"/> to your addon.xml dependencies. I can't remember if there are other modules that need to be added as well.

Sorry, this needs to be added to the script.module.googleapi addon.xml (not your addon's addon.xml), at least that's how I got this working. I can't remember if the correct oauth2client version is 1.4.7 or 1.3.2, it looks like it might make a difference. It was a few months back that I was trying some things out for Google+ and Vevo and really can't remember how I got it working.

If that's the case, why has nobody bothered do a PR and fix the module? Sad
https://github.com/robweber/script.module.googleapi
Reply
#6
(2015-10-28, 02:12)Razze Wrote: If that's the case, why has nobody bothered do a PR and fix the module? Sad
https://github.com/robweber/script.module.googleapi

As I said, it was a while ago and I remember having to add a missing dependency, but when I looked at the code it didn't make sense that no one else had spotted this as it looked like nothing would work without. At that point I assumed I was doing something wrong (which is more often than not the case) because I hadn't seen
Code:
from __future__ import absolute_import
before and didn't have the time to read through what all that meant - still not sure I understand when/why it needs to be used. It turned out that Vevo had other issues with a Google+ login so I didn't pursue it. Perhaps I'm not the best one to answer the gentleman's question.
Reply
#7
(2015-10-28, 02:12)Razze Wrote: If that's the case, why has nobody bothered do a PR and fix the module? Sad
https://github.com/robweber/script.module.googleapi

i've pinged robweber, he's a pretty active member of the forum,
so let's just wait a bit for his thoughts.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#8
(2015-10-28, 11:49)ronie Wrote:
(2015-10-28, 02:12)Razze Wrote: If that's the case, why has nobody bothered do a PR and fix the module? Sad
https://github.com/robweber/script.module.googleapi

i've pinged robweber, he's a pretty active member of the forum,
so let's just wait a bit for his thoughts.
Well, yeah, my thought exactly. If I alter script.module.googleapi on my own machine, my addon will not work for others. And then it would be a better option to keep the googleapi in my directory like it is now. That way the addon will at least work for everybody.

Thank you for attracting the attention of the addon dev Smile. Hopefully he can shed some light on this.
Reply
#9
Just wanted to let you know I got ronie's message. I'll take a look. That module is working fine in the "Backup" addon. Give me a bit to try some things and I'll report back tomorrow.
Reply
#10
ok,

Based on what I can tell it seems that adding the oauth2client module as an import for the google drive api may solve the problem. Looking at the page for the google drive api on github it doesn't say anything about using this as a dependency but the import is clearly there in the errors.py file mentioned in your stacktrace.

I was curious why this working on my Backup addon without the import statement but not in your example. I think it's because I'm manually importing the oauth2client library in my filesystem abstraction layer files within the Backup addon so it's accessible when I initialize the Google API module later on. If you're using the drive api directly this import isn't happening so it needs to be imported at the module level.

I've created a branch on github and added the import line. Try it out (or just add it yourself to your local googledrive api addon.xml) and reboot Kodi just to make sure it's all working. Also make sure you do have the oauth2client module downloaded as well. I didn't go through the work of creating a test addon to see if the error persists - guess I'm putting that testing on you! Let me know if anything changes.
Reply
#11
(2015-10-29, 16:25)robweber Wrote: ......
Try it out (or just add it yourself to your local googledrive api addon.xml) ......
Thanks for looking into it!

I've added the import line to the addon.xml of the script.module.googleapi, and the error is gone. I'm not using the googleapi to access Google Drive functions, but to access Youtube. Maybe this is why it works in your backup addon without that import line? I import build from apiclient.discovery, and that wants to import oath2client. Maybe that's why?

If this could be incorporated to the addon, that would be great. Then I can remove the googleapi directorys from my addon and use your script.module.googleapi as a dependency and it will still work for my users Smile.
Reply
#12
Thanks for clarifying this. I wasn't clear on whether the
Code:
from __future__ import absolute_import
had an effect on intra-package imports or whether it was for compatibility purposes between various versions of python. It doesn't seem to play a role here.
Reply
#13
Great, glad to know that worked. I'll update the master branch and push it to the Kodi repo. In my Backup addon I'm leveraging the googleapi but using a wrapper class called "pydrive" that I bundle with the addon. It does all the dirty work so I just interact with the Google Drive stuff directly. Makes sense that this import might be used if you are doing something different. A little weird that the Google documentation didn't mention this dependency but I'm sure it's just an oversight. I'll get it pushed as soon as I can.
Reply

Logout Mark Read Team Forum Stats Members Help
Using script.module.googleapi0