Exemple #1
0
    def __init__(self, name, plugin_id, filepath=None, debug=False):
        '''Initialize a plugin object for an XBMC addon.'''
        self._name = name
        self._filepath = filepath
        self._plugin_id = plugin_id

        # Keeps track of url routes
        self._routes = []
        self._view_functions = {}

        args = self.parse_commandline(sys.argv)

        self._plugin = xbmcaddon.Addon(id=self._plugin_id)
        if self._mode in debug_modes:
            self._plugin._setup(os.path.dirname(self._filepath))

        self._argv0, self._argv1, self._argv2 = args
        self.handle = int(self._argv1)

        self.qs_args = parse_qs(self._argv2.lstrip('?'))

        self.scheme, self.netloc, self.path = urlparse(self._argv0)

        self._cache_path = xbmc.translatePath(
            'special://profile/addon_data/%s/.cache' % self._plugin_id)
 def initCookie(self):
     self.__log('start initCookie')
     addon = xbmcaddon.Addon(self.PLUGINID)
     cookiepath = xbmc.translatePath(addon.getAddonInfo('profile')) 
     cookiepath = cookiepath + self.COOKIEFILE
     cookiepath = xbmc.translatePath(cookiepath)
     #set global
     self.__cookiepath__ = cookiepath
     self.__log('Cookiepath: ' + cookiepath)
     cj = cookielib.LWPCookieJar()
     opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
     urllib2.install_opener(opener)
     #if exist load file and cookie information 
     if (os.path.isfile(cookiepath)):
         cj.load(cookiepath, False, False)
         self.__log('Cookies loaded from file: ' + cookiepath)
         for index, cookie in enumerate(cj):
             self.__log('cookies come here: ')                
     else:               
         self.__log('No cookie file found at: ' + cookiepath)
     #set global object
     self.__cj__ = cj   
     self.__log('Finished initCookie')
     
     '''
Exemple #3
0
#imports
from xbmcswift import Plugin, xbmc, xbmcaddon, xbmcplugin, xbmcgui, clean_dict
from urllib2 import urlopen, HTTPError
import urlparse
import xbmcgui
from pyxbmct.addonwindow import *
import sys
import json
import os.path
from urllib2 import Request
import urllib
import urllib2
import datetime
import time

__addon__ = xbmcaddon.Addon()
__addon_name__ = __addon__.getAddonInfo('name')
__id__ = __addon__.getAddonInfo('id')
__lang__ = __addon__.getLocalizedString
__version__ = __addon__.getAddonInfo('version')
__profile_path__ = xbmc.translatePath(
    __addon__.getAddonInfo('profile')).decode("utf-8")
__token_filepath__ = __profile_path__ + '/token.txt'


# BEGIN # Plugin
class Plugin_mod(Plugin):
    def add_items(self, iterable, is_update=False, sort_method_ids=[]):
        items = []
        urls = []
        for i, li_info in enumerate(iterable):