Browse files

Initial commit

  • Loading branch information...
1 parent afe5992 commit 776c7f88e7640930c3623ce3db68b05443a17f96 @bstrdsmkr committed Apr 20, 2012
Showing with 161 additions and 0 deletions.
  1. +16 −0 addon.xml
  2. +82 −0 default.py
  3. +63 −0 utils.py
View
16 addon.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<addon id="plugin.video.waldo" version="0.0.1" name="Waldo" provider-name="Bstrdsmkr">
+ <requires>
+ <import addon="xbmc.python" version="2.0"/>
+ <import addon="script.module.t0mm0.common" version="1.1.0"/>
+ <import addon="script.module.metahandler" version="1.0.0"/>
+ </requires>
+ <extension point="xbmc.python.pluginsource" library="default.py">
+ <provides>video</provides>
+ </extension>
+ <extension point="xbmc.addon.metadata">
+ <summary>Browse various content indexes and use them to search various sources of content</summary>
+ <description>Waldo allows you to browse various content indexes (such as imdb.com) and search all supported sources (such as your local library and other addons) for that content, all at once.</description>
+ <platform>all</platform>
+ </extension>
+</addon>
View
82 default.py
@@ -0,0 +1,82 @@
+import xbmc
+import xbmcgui
+import xbmcplugin
+import sys
+import imp
+import os
+
+from t0mm0.common.addon import Addon
+from t0mm0.common.net import Net
+from metahandler import metahandlers
+from metahandler import metacontainers
+try: import cPickle as pickle
+except: import pickle
+
+from utils import *
+
+addon = Addon('plugin.video.waldo', sys.argv)
+INDEXES_PATH = os.path.join(addon.get_path(),'indexes')
+PROVIDERS_PATH = os.path.join(addon.get_path(),'providers')
+
+def listIndexes():
+ import indexes
+ for index in indexes.index_list:
+ title = index.display_name
+ addon.add_directory({'mode':'ListIndexBrowsingOptions', 'index': get_index_name(index)}, {'title': title})
+ addon.end_of_directory()
+
+def ListIndexBrowsingOptions(index):
+ index = import_module(index, fromlist=[INDEXES_PATH,])
+ options = index.get_browsing_options()
+ for option in options:
+ callback = pickle.dumps(option['function'])
+ args = pickle.dumps(option['kwargs'])
+ addon.add_directory({'mode':'ActivateCallback', 'function':callback, 'kwargs':args, 'index':get_index_name(index)}, {'title':option['name']})
+ addon.end_of_directory()
+
+def GetAllResults(type,title,year,imdb,tvdb,season,episode):
+ import providers
+ all_results = []
+ for provider in providers.provider_list:
+ results = provider.get_results(type,title,year,imdb,tvdb,season,episode)
+ all_results.extend(results)
+ for result in all_results:
+ callback = pickle.dumps(result['function'])
+ args = pickle.dumps(result['kwargs'])
+ label = '[%s] %s' %(result['tag'],result['title'])
+ addon.add_directory({'mode':'ActivateCallback', 'function':callback, 'kwargs':args}, {'title':label})
+ addon.end_of_directory()
+
+def ActivateCallback(function,kwargs,index):
+ if index:
+ index = import_module(index, fromlist=[INDEXES_PATH,])
+ callback = pickle.loads(function)
+ kwargs = pickle.loads(kwargs)
+ callback(**kwargs)
+
+mode = addon.queries.get('mode', '')
+index = addon.queries.get('index', '')
+name = addon.queries.get('name', '')
+type = addon.queries.get('type', '')
+title = addon.queries.get('title', '')
+year = addon.queries.get('year', '')
+imdb = addon.queries.get('imdb', '')
+tvdb = addon.queries.get('tvdb', '')
+season = addon.queries.get('season', '')
+episode = addon.queries.get('episode', '')
+function = addon.queries.get('function','')
+kwargs = addon.queries.get('kwargs', '')
+receiver = addon.queries.get('receiver','')
+
+addon.log(addon.queries)
+if mode=='main':
+ listIndexes()
+elif mode=='ListIndexBrowsingOptions':
+ ListIndexBrowsingOptions(index)
+elif mode=='GetAllResults':
+ GetAllResults(type,title,year,imdb,tvdb,season,episode)
+elif mode=='ActivateCallback':
+ ActivateCallback(function,kwargs, index)
+elif mode=='CallModule':
+ receiver = import_module(receiver, fromlist=[INDEXES_PATH,PROVIDERS_PATH])
+ receiver.callback(addon.queries)
View
63 utils.py
@@ -0,0 +1,63 @@
+import imp
+import sys
+import xbmc
+try: import cPickle as pickle
+except: import pickle
+
+from t0mm0.common.addon import Addon
+addon = Addon('plugin.video.waldo', sys.argv)
+
+def import_module(name, globals=None, locals=None, fromlist=None):
+ # Fast path: see if the module has already been imported.
+ try: return sys.modules[name]
+ except KeyError:
+ pass
+
+ # If any of the following calls raises an exception,
+ # there's a problem we can't handle -- let the caller handle it.
+
+ fp, pathname, description = imp.find_module(name,fromlist)
+
+ try: return imp.load_module(name, fp, pathname, description)
+ finally:
+ # Since we may exit via an exception, close fp explicitly.
+ if fp: fp.close()
+
+def get_index_name(index):
+ print 'Getting index name of %s' %index
+ return index.__name__.rsplit('.',1)[-1]
+
+def has_requirements(list):
+ for addon in list:
+ condition = 'System.HasAddon(%s)' %addon
+ if not xbmc.getCondVisibility(condition):
+ return False
+ return True
+
+def _update_settings_xml(list):
+ '''
+ This function writes a new ``resources/settings.xml`` file which contains
+ all settings for this addon and its plugins.
+ '''
+ settings_file = os.path.join(addon.get_path(), 'resources', 'settings.xml')
+ try:
+ try:
+ os.makedirs(os.path.dirname(settings_file))
+ except OSError:
+ pass
+
+ f = open(settings_file, 'w')
+ try:
+ f.write('<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n')
+ f.write('<settings>\n')
+ for mod in list:
+ settings_xml = mod.get_settings_xml()
+ if settings_xml:
+ f.write('<category label="%s">\n' % mod.display_name)
+ f.write(settings_xml)
+ f.write('</category>\n')
+ f.write('</settings>')
+ finally:
+ f.close
+ except IOError:
+ addon.log_error('Error writing ' + common.settings_file)

0 comments on commit 776c7f8

Please sign in to comment.