ecasa: first step towards a gui
[enigma2-plugins.git] / ecasa / src / plugin.py
1 from __future__ import print_function
2
3 #pragma mark - Plugin
4
5 def main(session, *args, **kwargs):
6         import EcasaGui
7         reload(EcasaGui)
8         session.open(EcasaGui.EcasaOverview)
9
10 def Plugins(**kwargs):
11         from Plugins.Plugin import PluginDescriptor
12         return [
13                 PluginDescriptor(
14                         name="eCasa",
15                         description=_("enigma2 picasa client"),
16                         where=PluginDescriptor.WHERE_PLUGINMENU,
17                         fnc=main,
18                         needsRestart=False,
19                 ),
20         ]
21
22 if __name__ == '__main__':
23         import sys
24         import PicasaApi
25         if len(sys.argv) > 2:
26                 un = sys.argv[1]
27                 pw = sys.argv[2]
28         else:
29                 un = pw = None
30                 print("Not using authentication...")
31         api = PicasaApi.PicasaApi(un, pw)
32         try:
33                 l = api.getAlbums()
34         except Exception as e:
35                 # NOTE: assumes 403 and that the following calls would also not succeed
36                 print("Encountered exception:", e)
37         else:
38                 print("List of Albums:", l)
39                 if l:
40                         l = api.getAlbum(l[0][2])
41                         print("Pictures in first album:", l)
42                         print("Thumbnail of first picture could be found under:", l[0].media.thumbnail[0].url)
43                         print("Picture should be:", l[0].media.content[0].url)
44         l = api.getFeatured()
45         print("Featured Pictures:", l)