Ejemplo n.º 1
0
    def onClick(self, controlID):
        """
            Notice: onClick not onControl
            Notice: it gives the ID of the control not the control object
        """
        #action sur la liste
        print "Control %d clicked" % controlID
        if controlID == 200:
            print "Processing control 200"
            #Renvoie le numéro de l'item sélectionné
            num = self.xml_list.getSelectedPosition()
            print "got xml list"
            #Traitement de l'information
            if self.list_items[num]['selection'] == "false":
                self.list_items[num]['selection'] = "true"
            else:
                self.list_items[num]['selection'] = "false"

            print "updating list"
            self.listItems(self.list_items)
            print "list updated"
            self.xml_list.selectItem(num)
            print "done processing 200"

        if controlID == 9001:
            print "processing 9001"
            matchfilter = []
            for item in self.list_items:
                if item['selection'] == "true":
                    matchfilter.append(str(item['genreid']))

            xbmcplugin.setSetting('genreignore', ",".join(matchfilter))
            self.close()
            print "done with 9001"
        print "done with control"
Ejemplo n.º 2
0
def set_setting(name, value, channel=""):
    """
    Fija el valor de configuracion del parametro indicado.

    Establece 'value' como el valor del parametro 'name' en la configuracion global o en la configuracion propia del
    canal 'channel'.
    Devuelve el valor cambiado o None si la asignacion no se ha podido completar.

    Si se especifica el nombre del canal busca en la ruta \addon_data\plugin.video.pelisalacarta\settings_channels el
    archivo channel_data.json y establece el parametro 'name' al valor indicado por 'value'. Si el archivo
    channel_data.json no existe busca en la carpeta channels el archivo channel.xml y crea un archivo channel_data.json
    antes de modificar el parametro 'name'.
    Si el parametro 'name' no existe lo añade, con su valor, al archivo correspondiente.


    Parametros:
    name -- nombre del parametro
    value -- valor del parametro
    channel [opcional] -- nombre del canal

    Retorna:
    'value' en caso de que se haya podido fijar el valor y None en caso contrario

    """
    if channel:
        from core import channeltools
        return channeltools.set_channel_setting(name, value, channel)
    else:
        try:
            xbmcplugin.setSetting(name, value)
        except:
            return None

        return value
Ejemplo n.º 3
0
    def __init__( self, *args, **kwargs ):
        if True: #self._check_compatible():
            self.pluginMgr = PluginMgr()
            self.parameters = self.pluginMgr.parse_params()

            # if 1st start create missing directories
            self.fileMgr = fileMgr()
            self.fileMgr.verifrep( DIR_ADDON_MODULE )
            self.fileMgr.verifrep( DIR_ADDON_REPO )
            self.fileMgr.verifrep( DIR_CACHE )
            self.fileMgr.verifrep( DIR_CACHE_ADDONS )

            # Check settings
            if xbmcplugin.getSetting('first_run') == 'true':
                # Check (only the 1st time) is xbmcaddon module is available
                print( "     **First run")
                if self._check_addon_lib():
                    print( "         XBMC Addon 4 XBOX Addon Library already installed")
                    print( "         Installing default repositories")
                    if ( self._installRepos() ):
                        xbmcplugin.setSetting('first_run','false')
                        self._createRootDir()
                else:
                    print( "         ERROR - XBMC Addon 4 XBOX Addon Library MISSING")
                    dialog = xbmcgui.Dialog()
                    dialog.ok( __language__(30000), __language__(30091) ,__language__(30092))
            else:
                self._createRootDir()

        self.pluginMgr.add_sort_methods( False )
        self.pluginMgr.end_of_directory( True, update=False )
Ejemplo n.º 4
0
def editB(name, url):
    type = 'presets_' + url
    presets = xbmcplugin.getSetting(type)
    save = presets.split(" | ")
    del save[save.index(name)]
    x = 0
    for item in save:
        if x == 0:
            sets = item
        else:
            sets = sets + ' | ' + item
        x = x + 1
    searchStr = name
    keyboard = xbmc.Keyboard(searchStr, "Edit user name")
    keyboard.doModal()
    if (keyboard.isConfirmed() == False):
        return
    searchstring = keyboard.getText()
    newStr = searchstring
    if len(newStr) == 0:
        return
    if len(save) == 0:
        sets = newStr
    else:
        sets = sets + ' | ' + newStr
    xbmcplugin.setSetting(type, sets)
    xbmc.executebuiltin("Container.Refresh")
Ejemplo n.º 5
0
 def _run_once(self):
     # is this the first time plugin was run and user has not set email
     if (not sys.argv[2] and xbmcplugin.getSetting("user_id") == ""
             and xbmcplugin.getSetting("runonce") != "1"
             and xbmcplugin.getSetting("runonce") != "2"):
         # set runonce
         xbmcplugin.setSetting("runonce", "1")
         # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
         if (os.environ.get("OS", "n/a") == "xbox"):
             xbmc.sleep(2000)
         # open settings
         xbmcplugin.openSettings(sys.argv[0])
     # check again to see if authentication is necessary
     if (not sys.argv[2] and xbmcplugin.getSetting("user_id") != ""
             and xbmcplugin.getSetting("runonce") != "2"
             and xbmcplugin.getSetting("authtoken") == ""):
         # set runonce
         xbmcplugin.setSetting("runonce", "2")
         # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
         if (os.environ.get("OS", "n/a") == "xbox"):
             xbmc.sleep(2000)
         # ask user if they want to authorize
         ok = xbmcgui.Dialog().yesno(xbmc.getLocalizedString(30907),
                                     xbmc.getLocalizedString(30908), "",
                                     xbmc.getLocalizedString(30909),
                                     xbmc.getLocalizedString(30910),
                                     xbmc.getLocalizedString(30911))
         # authorize
         if (ok):
             self._authorize()
Ejemplo n.º 6
0
    def onClick(self, controlID):
        """
            Notice: onClick not onControl
            Notice: it gives the ID of the control not the control object
        """
        #action sur la liste
        print "Control %d clicked" % controlID
        if controlID == 200 :
            print "Processing control 200"
            #Renvoie le numéro de l'item sélectionné
            num = self.xml_list.getSelectedPosition()
            print "got xml list"
            #Traitement de l'information
            if self.list_items[num]['selection'] == "false" :
                self.list_items[num]['selection'] = "true"
            else :
                self.list_items[num]['selection'] = "false"

            print "updating list"
            self.listItems(self.list_items)
            print "list updated"
            self.xml_list.selectItem(num)
            print "done processing 200"
            
        if controlID == 9001 :
            print "processing 9001"
            matchfilter=[]
            for item in self.list_items:
                if item['selection'] == "true" :
                    matchfilter.append(str(item['genreid']))

            xbmcplugin.setSetting('genreignore', ",".join(matchfilter))
            self.close()
            print "done with 9001"
        print "done with control"
Ejemplo n.º 7
0
def setSetting(name,value):
	# Nuevo XBMC
	if DHARMA:
		__settings__.setSetting( name,value ) # this will return "foo" setting value
	# Antiguo XBMC
	else:
		xbmcplugin.setSetting(name,value)
Ejemplo n.º 8
0
 def save_as_preset(self):
     # select correct query
     query = (
         self.args.pq,
         self.args.user_id,
     )[self.args.issearch - 1]
     # fetch saved presets
     try:
         # read the queries
         presets = eval(
             xbmcplugin.getSetting(
                 "presets_%s" % (
                     "photos",
                     "users",
                 )[self.args.issearch - 1], ))
         # if this is an existing search, move it up
         for count, preset in enumerate(presets):
             if (repr(query + " | ")[:-1] in repr(preset)):
                 del presets[count]
                 break
         # limit to number of searches to save
         if (len(presets) >= self.settings["saved_searches"]):
             presets = presets[:self.settings["saved_searches"] - 1]
     except:
         # no presets found
         presets = []
     # insert our new search
     presets = [query + " | " + self.query_thumbnail] + presets
     # save search query
     xbmcplugin.setSetting(
         "presets_%s" % (
             "photos",
             "users",
         )[self.args.issearch - 1], repr(presets))
Ejemplo n.º 9
0
def editB(name,url):
	type = 'presets_' + url
	presets = xbmcplugin.getSetting( type )
	save = presets.split( " | " )
	del save[save.index(name)]
	x=0
	for item in save:
		if x == 0:
			sets = item
		else:
			sets = sets + ' | ' + item
		x=x+1
	searchStr = name
	keyboard = xbmc.Keyboard(searchStr, "Edit user name")
	keyboard.doModal()
	if (keyboard.isConfirmed() == False):
		return
	searchstring = keyboard.getText()
	newStr = searchstring
	if len(newStr) == 0:
		return
	if len(save) == 0:
		sets = newStr
	else:
		sets = sets + ' | ' + newStr
	xbmcplugin.setSetting(type, sets)
	xbmc.executebuiltin( "Container.Refresh" )
Ejemplo n.º 10
0
def set_setting(name, value, channel=""):
    """
    Fija el valor de configuracion del parametro indicado.

    Establece 'value' como el valor del parametro 'name' en la configuracion global o en la configuracion propia del
    canal 'channel'.
    Devuelve el valor cambiado o None si la asignacion no se ha podido completar.

    Si se especifica el nombre del canal busca en la ruta \addon_data\plugin.video.pelisalacarta\settings_channels el
    archivo channel_data.json y establece el parametro 'name' al valor indicado por 'value'. Si el archivo
    channel_data.json no existe busca en la carpeta channels el archivo channel.xml y crea un archivo channel_data.json
    antes de modificar el parametro 'name'.
    Si el parametro 'name' no existe lo añade, con su valor, al archivo correspondiente.


    Parametros:
    name -- nombre del parametro
    value -- valor del parametro
    channel [opcional] -- nombre del canal

    Retorna:
    'value' en caso de que se haya podido fijar el valor y None en caso contrario

    """
    if channel:
        from core import channeltools
        return channeltools.set_channel_setting(name, value, channel)
    else:
        try:
            xbmcplugin.setSetting(name, value)
        except:
            # xbmc.log("[config.py] ERROR al fijar el parametro global {0}= {1}".format(name, value))
            return None

        return value
Ejemplo n.º 11
0
 def _authorize( self ):
     # flickr client
     client = FlickrClient( api_key=True, secret=True )
     # authenticate
     authtoken = client.authenticate()
     # write it to the settings file
     if ( authtoken ):
         xbmcplugin.setSetting( "authtoken", authtoken )
Ejemplo n.º 12
0
 def _authorize(self):
     # flickr client
     client = FlickrClient(api_key=True, secret=True)
     # authenticate
     authtoken = client.authenticate()
     # write it to the settings file
     if (authtoken):
         xbmcplugin.setSetting("authtoken", authtoken)
Ejemplo n.º 13
0
def setSetting(name,value):
	# Nuevo XBMC
	if DHARMA:
		__settings__.setSetting( name,value ) # this will return "foo" setting value
	# Antiguo XBMC
	else:
		try:
			import xbmcplugin
			xbmcplugin.setSetting(name,value)
		except:
			pass
Ejemplo n.º 14
0
def fetchLoggedIn(url):
    req = requests.get(url, cookies=sessionCookies)
    soup = BeautifulSoup(req.text, 'html.parser')
    loginUser = soup.findAll("ul", {"class":"user-menu-dropdown"})
    if loginUser:
        profileLink = loginUser[0].findAll("a",{"class":"dropdown-item", "href":"/profile/"})
        if profileLink:
            return req
    #Our cookies have gone stale, clear them out.
    xbmcplugin.setSetting(_handle, id='cookies', value='')
    raise ValueError("Not currently logged in.")
Ejemplo n.º 15
0
def setSetting(name, value):
    # Nuevo XBMC
    if DHARMA:
        __settings__.setSetting(name,
                                value)  # this will return "foo" setting value
    # Antiguo XBMC
    else:
        try:
            import xbmcplugin
            xbmcplugin.setSetting(name, value)
        except:
            pass
Ejemplo n.º 16
0
 def openSettings( self ):
     # is this the first time plugin was run and user has not set email
     if ( not sys.argv[ 2 ] and xbmcplugin.getSetting( "username" ) == "" and xbmcplugin.getSetting( "runonce" ) == "" ):
         # set runonce
         xbmcplugin.setSetting( "runonce", "1" )
         # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
         if ( os.environ.get( "OS", "n/a" ) == "xbox" ):
             xbmc.sleep( 2000 )
         # open settings
         xbmcplugin.openSettings( sys.argv[ 0 ] )
     # we need to get the users email
     self.username = xbmcplugin.getSetting( "username" )
 def openSettings(self):
     try:
         # is this the first time plugin was run and user has not set email
         if not sys.argv[2] and xbmcplugin.getSetting("username") == "" and xbmcplugin.getSetting("runonce") == "":
             # set runonce
             xbmcplugin.setSetting("runonce", "1")
             # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
             if os.environ.get("OS", "n/a") == "xbox":
                 xbmc.sleep(2000)
             # open settings
             xbmcplugin.openSettings(sys.argv[0])
     except:
         # new methods not in build
         pass
Ejemplo n.º 18
0
    def __init__( self, *args, **kwargs ):
        #
        # User to choose an address...
        #
        
        # Previously pinged addresses...
        try :
            ping_addrs = eval( xbmcplugin.getSetting( "ping_addrs" ) )
        except :
            ping_addrs = []

        # Insert entry for "New address"...
        ping_addrs.insert(0, xbmc.getLocalizedString(30302))

        # User choice...
        dialogAddrs    = xbmcgui.Dialog()
        index          = dialogAddrs.select( xbmc.getLocalizedString(30201), ping_addrs )
        self.ping_addr = ""
        
        # New address...
        if index == 0 :            
            keyboard = xbmc.Keyboard( "", xbmc.getLocalizedString( 30301 ) )
            keyboard.doModal()
            if keyboard.isConfirmed() :
                self.ping_addr = keyboard.getText()                

        # Previous address..
        if index > 0 :
            self.ping_addr = ping_addrs[ index ]

        #
        # User made a choice...
        #
        if self.ping_addr > "" :
            #
            # Save address for future use...
            #
            ping_addrs.pop( 0 )
            try :
                ping_addrs.index ( self.ping_addr )
            except :
                ping_addrs.append( self.ping_addr )
            ping_addrs.sort()
            xbmcplugin.setSetting( "ping_addrs", repr( ping_addrs ))
            
            #
            # Show text window (+ pinging, see onInit)...
            #            
            self.doModal()
Ejemplo n.º 19
0
def removeB(name, url):
    type = 'presets_' + url
    presets = xbmcplugin.getSetting(type)
    save = presets.split(" | ")
    del save[save.index(name)]
    sets = ''
    x = 0
    for item in save:
        if x == 0:
            sets = sets + item
        else:
            sets = sets + ' | ' + item
        x = x + 1
    xbmcplugin.setSetting(type, sets)
    xbmc.executebuiltin("Container.Refresh")
Ejemplo n.º 20
0
def removeB(name,url):
	type = 'presets_' + url
	presets = xbmcplugin.getSetting( type )
	save = presets.split( " | " )
	del save[save.index(name)]
	sets = ''
	x=0
	for item in save:
		if x == 0:
			sets = sets + item
		else:
			sets = sets + ' | ' + item
		x=x+1
	xbmcplugin.setSetting(type, sets)
	xbmc.executebuiltin( "Container.Refresh" )
Ejemplo n.º 21
0
 def delete_preset( self ):
     try:
         # read the queries
         presets = eval( xbmcplugin.getSetting( "presets_%s" % ( "videos", "users", "categories", )[ self.args.issearch - 1  ], ) )
         # if this is an existing search, move it up
         for count, preset in enumerate( presets ):
             if ( self.args.query in repr( preset ) ):
                 del presets[ count ]
                 break
     except:
         # no presets found
         presets = []
     # save presets
     xbmcplugin.setSetting( "presets_%s" % ( "videos", "users", "categories", )[ self.args.issearch - 1  ], repr( presets ) )
     # refresh container so item is removed
     xbmc.executebuiltin( "Container.Refresh" )
Ejemplo n.º 22
0
	def authenticate( self ):
		log( " > authenticate()")
		ok = False
		# make the authentication call
		try:
			authkey = self.client.authenticate( self.email, self.password )
			if authkey and authkey.startswith("ERROR"): raise "neterror", authkey
			if not authkey:
				messageOK(__plugin__, __lang__(30904))
			else:
				try:
					xbmcplugin.setSetting( "authkey", authkey )
					ok = True
				except: pass
		except "neterror", e:
			messageOK(__plugin__, e)
Ejemplo n.º 23
0
 def authenticate(self):
     # if this is first run open settings
     self.openSettings()
     # authentication is not permanent, so do this only when first launching plugin
     if (not sys.argv[2]):
         # get the users settings
         password = xbmcplugin.getSetting("user_password")
         # we can only authenticate if both email and password are entered
         if (self.email and password):
             # our client api
             from PicasaAPI.PicasaClient import PicasaClient
             client = PicasaClient()
             # make the authentication call
             authkey = client.authenticate(self.email, password)
             # if authentication succeeded, save it for later
             if (authkey):
                 xbmcplugin.setSetting("authkey", authkey)
Ejemplo n.º 24
0
 def authenticate( self ):
     # if this is first run open settings
     self.openSettings()
     # authentication is not permanent, so do this only when first launching plugin
     if ( not sys.argv[ 2 ] ):
         # get the users settings
         password = xbmcplugin.getSetting( "user_password" )
         # we can only authenticate if both email and password are entered
         self.authkey = ""
         if ( self.username and password ):
             # our client api
             from YoutubeAPI.YoutubeClient import YoutubeClient
             client = YoutubeClient()
             # make the authentication call
             self.authkey, userid = client.authenticate( self.username, password )
         # save authkey even if failed, so no token expired error
         xbmcplugin.setSetting( "authkey", self.authkey )
Ejemplo n.º 25
0
 def authenticate( self ):
     # if this is first run open settings
     self.openSettings()
     # authentication is not permanent, so do this only when first launching plugin
     if ( not sys.argv[ 2 ] ):
         # get the users settings
         password = xbmcplugin.getSetting( "user_password" )
         # we can only authenticate if both email and password are entered
         if ( self.email and password ):
             # our client api
             from PicasaAPI.PicasaClient import PicasaClient
             client = PicasaClient()
             # make the authentication call
             authkey = client.authenticate( self.email, password )
             # if authentication succeeded, save it for later
             if ( authkey ):
                 xbmcplugin.setSetting( "authkey", authkey )
Ejemplo n.º 26
0
def set_setting(name, value, channel="", server=""):
    """
    Fija el valor de configuracion del parametro indicado.

    Establece 'value' como el valor del parametro 'name' en la configuracion global o en la configuracion propia del
    canal 'channel'.
    Devuelve el valor cambiado o None si la asignacion no se ha podido completar.

    Si se especifica el nombre del canal busca en la ruta \addon_data\plugin.video.pelisalacarta\settings_channels el
    archivo channel_data.json y establece el parametro 'name' al valor indicado por 'value'. Si el archivo
    channel_data.json no existe busca en la carpeta channels el archivo channel.xml y crea un archivo channel_data.json
    antes de modificar el parametro 'name'.
    Si el parametro 'name' no existe lo añade, con su valor, al archivo correspondiente.


    Parametros:
    name -- nombre del parametro
    value -- valor del parametro
    channel [opcional] -- nombre del canal

    Retorna:
    'value' en caso de que se haya podido fijar el valor y None en caso contrario

    """
    if channel:
        from core import channeltools
        return channeltools.set_channel_setting(name, value, channel)
    elif server:
        from core import servertools
        return servertools.set_server_setting(name, value, server)
    else:
        try:
            if isinstance(value, bool):
                if value:
                    value = "true"
                else:
                    value = "false"
            elif isinstance(value, (int, long)):
                value = str(value)

            import xbmcplugin
            xbmcplugin.setSetting(name, value)
        except:
            return None

        return value
Ejemplo n.º 27
0
    def rememberRecentFile(self, filename):
        try:
            recent_files = eval(xbmcplugin.getSetting("recent_files"))
        except:
            recent_files = []

        # Add the entry to the list...
        try:
            # ... if not already in the list...
            recent_files.index(filename)
        except:
            recent_files.append(filename)

            # Sort the list...
            recent_files.sort()

            # Save queries...
            xbmcplugin.setSetting("recent_files", repr(recent_files))
Ejemplo n.º 28
0
 def authenticate(self):
     log(" > authenticate()")
     ok = False
     # make the authentication call
     try:
         authkey = self.client.authenticate(self.email, self.password)
         if authkey and authkey.startswith("ERROR"):
             raise "neterror", authkey
         if not authkey:
             messageOK(__plugin__, __lang__(30904))
         else:
             try:
                 xbmcplugin.setSetting("authkey", authkey)
                 ok = True
             except:
                 pass
     except "neterror", e:
         messageOK(__plugin__, e)
Ejemplo n.º 29
0
def runKeyboard3():
	searchStr = ''
	keyboard = xbmc.Keyboard(searchStr, "Enter the exact user name")
	keyboard.doModal()
	if (keyboard.isConfirmed() == False):
			return
	searchstring = keyboard.getText()
	newStr = searchstring.replace(' ','+')
	if len(newStr) == 0:
			return
	presets = xbmcplugin.getSetting( "presets_users" )
	if presets == '':
		save_str = newStr
	else:
		save_str = presets + " | " + newStr
	xbmcplugin.setSetting("presets_users", save_str)
	if len(newStr) != 0:
		thumb = xbmc.getInfoImage( "ListItem.Thumb" )
		playVideo(newStr, 'get_cat', thumb)
Ejemplo n.º 30
0
 def save_as_preset(self):
     # select correct query
     query = (
         self.args.vq,
         self.args.username,
         self.args.vq,
     )[self.args.issearch - 1]
     # if user or category search and query was found then proceed, should never be an issue for video search
     if (query or self.args.cat):
         # fetch saved presets
         try:
             # read the queries
             presets = eval(
                 xbmcplugin.getSetting(
                     "presets_%s" % (
                         "videos",
                         "users",
                         "categories",
                     )[self.args.issearch - 1], ))
             # if this is an existing search, move it up
             for count, preset in enumerate(presets):
                 if (repr(query + " | " + self.args.title + " | ")[:-1]
                         in repr(preset)):
                     del presets[count]
                     break
             # limit to number of searches to save
             if (len(presets) >= self.settings["saved_searches"]):
                 presets = presets[:self.settings["saved_searches"] - 1]
         except:
             # no presets found
             presets = []
         # insert our new search
         presets = [
             query + " | " + self.args.title + " | " + self.args.cat +
             " | " + self.query_thumbnail
         ] + presets
         # save search query
         xbmcplugin.setSetting(
             "presets_%s" % (
                 "videos",
                 "users",
                 "categories",
             )[self.args.issearch - 1], repr(presets))
Ejemplo n.º 31
0
def runKeyboard3():
    searchStr = ''
    keyboard = xbmc.Keyboard(searchStr, "Enter the exact user name")
    keyboard.doModal()
    if (keyboard.isConfirmed() == False):
        return
    searchstring = keyboard.getText()
    newStr = searchstring.replace(' ', '+')
    if len(newStr) == 0:
        return
    presets = xbmcplugin.getSetting("presets_users")
    if presets == '':
        save_str = newStr
    else:
        save_str = presets + " | " + newStr
    xbmcplugin.setSetting("presets_users", save_str)
    if len(newStr) != 0:
        thumb = xbmc.getInfoImage("ListItem.Thumb")
        playVideo(newStr, 'get_cat', thumb)
Ejemplo n.º 32
0
def runKeyboard4():
    searchStr = ''
    keyboard = xbmc.Keyboard(searchStr, "Search")
    keyboard.doModal()
    if (keyboard.isConfirmed() == False):
        return
    searchstring = keyboard.getText()
    newStr = searchstring.replace(' ', '+')
    if len(newStr) == 0:
        return
    presets = xbmcplugin.getSetting("presets_search")
    if presets == '':
        save_str = newStr
    else:
        save_str = presets + " | " + newStr
    xbmcplugin.setSetting("presets_search", save_str)
    if len(newStr) != 0:
        url = 'http://www.justin.tv/search?q=' + newStr
        runSearch(url)
Ejemplo n.º 33
0
def runKeyboard4():
	searchStr = ''
	keyboard = xbmc.Keyboard(searchStr, "Search")
	keyboard.doModal()
	if (keyboard.isConfirmed() == False):
		return
	searchstring = keyboard.getText()
	newStr = searchstring.replace(' ','+')
	if len(newStr) == 0:
		return
	presets = xbmcplugin.getSetting( "presets_search" )
	if presets == '':
		save_str = newStr
	else:
		save_str = presets + " | " + newStr
	xbmcplugin.setSetting("presets_search", save_str)
	if len(newStr) != 0:
		url = 'http://www.justin.tv/search?q='+newStr
		runSearch(url)
def setSetting(*args, **kwargs):
    """Sets a plugin setting for the current running plugin.

    handle: integer - handle the plugin was started with.
    id: string - id of the setting that the module needs to access.
    value: string or unicode - value of the setting.

    Example:
        xbmcplugin.setSetting(int(sys.argv[1]), id='username', value='teamxbmc')
    """
    return mundane_xbmcplugin.setSetting(*args, **kwargs)
Ejemplo n.º 35
0
 def _run_once( self ):
     # is this the first time plugin was run and user has not set email
     if ( not sys.argv[ 2 ] and xbmcplugin.getSetting( "user_id" ) == "" and xbmcplugin.getSetting( "runonce" ) != "1" and xbmcplugin.getSetting( "runonce" ) != "2" ):
         # set runonce
         xbmcplugin.setSetting( "runonce", "1" )
         # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
         if ( os.environ.get( "OS", "n/a" ) == "xbox" ):
             xbmc.sleep( 2000 )
         # open settings
         xbmcplugin.openSettings( sys.argv[ 0 ] )
     # check again to see if authentication is necessary
     if ( not sys.argv[ 2 ] and xbmcplugin.getSetting( "user_id" ) != "" and xbmcplugin.getSetting( "runonce" ) != "2" and xbmcplugin.getSetting( "authtoken" ) =="" ):
         # set runonce
         xbmcplugin.setSetting( "runonce", "2" )
         # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?)
         if ( os.environ.get( "OS", "n/a" ) == "xbox" ):
             xbmc.sleep( 2000 )
         # ask user if they want to authorize
         ok = xbmcgui.Dialog().yesno( xbmc.getLocalizedString( 30907 ), xbmc.getLocalizedString( 30908 ), "", xbmc.getLocalizedString( 30909 ), xbmc.getLocalizedString( 30910 ), xbmc.getLocalizedString( 30911 ) )
         # authorize
         if (ok ):
             self._authorize()
Ejemplo n.º 36
0
 def save_as_preset( self ):
     # select correct query
     query = ( self.args.pq, self.args.gq, self.args.uq )[ self.args.issearch - 1 ]
     # fetch saved presets
     try:
         # read the queries
         presets = eval( xbmcplugin.getSetting( "presets_%s" % ( "photos", "groups", "users", )[ self.args.issearch - 1  ], ) )
         # if this is an existing search, move it up
         for count, preset in enumerate( presets ):
             if ( repr( query + " | " )[ : -1 ] in repr( preset ) ):
                 del presets[ count ]
                 break
         # limit to number of searches to save
         if ( len( presets ) >= self.settings[ "saved_searches" ] ):
             presets = presets[ : self.settings[ "saved_searches" ] - 1 ]
     except:
         # no presets found
         presets = []
     # insert our new search
     presets = [ self.args.title + " | " + query + " | " + self.query_thumbnail ] + presets
     # save search query
     xbmcplugin.setSetting( "presets_%s" % ( "photos", "groups", "users", )[ self.args.issearch - 1  ], repr( presets ) )
Ejemplo n.º 37
0
def getDownloadListPath():
	
	# La ruta de la lista de descargas es un parámetro
	downloadpath = xbmcplugin.getSetting("downloadlistpath")
	
	# No está fijada, intenta forzarla
	try:
		if downloadpath == "":
			xbmc.output("[downloadtools.py] downloadpath está vacio")
			
			# Busca un setting del skin (Telebision)
			downloadpath = xbmc.getInfoLabel('Skin.String(downloadpath)')
			xbmc.output("[downloadtools.py] downloadpath en el skin es "+downloadpath)
			
			# No es Telebision, fuerza el directorio home de XBMC
			if downloadpath == "":
				downloadpath = xbmc.translatePath( "special://home/downloads/list")
				xbmc.log("[downloadtools.py] getDownloadPath: downloadpath=%s" % downloadpath)
				xbmcplugin.setSetting("downloadlistpath",downloadpath)
			
			# Es Telebision, lo pone en el skin
			else:
				# guardar setting del skin en setting del plugin
				downloadpath = os.path.join( downloadpath , "list" )
				downloadpath = xbmc.translatePath( downloadpath )
				xbmc.output("[downloadtools.py] downloadpath nativo es "+downloadpath)
				xbmcplugin.setSetting("downloadlistpath", downloadpath)
	except:
		pass
	
	xbmc.output("[downloadtools.py] downloadlistpath="+downloadpath)
	
	try:
		os.mkdir(downloadpath)
	except:
		pass

	return downloadpath
Ejemplo n.º 38
0
    def __init__(self, *args, **kwargs):
        if True:  #self._check_compatible():
            self.pluginMgr = PluginMgr()
            self.parameters = self.pluginMgr.parse_params()

            # if 1st start create missing directories
            self.fileMgr = fileMgr()
            self.fileMgr.verifrep(DIR_ADDON_MODULE)
            self.fileMgr.verifrep(DIR_ADDON_REPO)
            self.fileMgr.verifrep(DIR_CACHE)
            self.fileMgr.verifrep(DIR_CACHE_ADDONS)

            # Check settings
            if xbmcplugin.getSetting('first_run') == 'true':
                # Check (only the 1st time) is xbmcaddon module is available
                print("     **First run")
                if self._check_addon_lib():
                    print(
                        "         XBMC Addon 4 XBOX Addon Library already installed"
                    )
                    print("         Installing default repositories")
                    if (self._installRepos()):
                        xbmcplugin.setSetting('first_run', 'false')
                        self._createRootDir()
                else:
                    print(
                        "         ERROR - XBMC Addon 4 XBOX Addon Library MISSING"
                    )
                    dialog = xbmcgui.Dialog()
                    dialog.ok(__language__(30000), __language__(30091),
                              __language__(30092))
            else:
                self._createRootDir()

        self.pluginMgr.add_sort_methods(False)
        self.pluginMgr.end_of_directory(True, update=False)
Ejemplo n.º 39
0
 def save_as_preset( self ):
     # select correct query
     query = ( self.args.vq, self.args.username, self.args.vq, )[ self.args.issearch - 1 ]
     # if user or category search and query was found then proceed, should never be an issue for video search
     if ( query or self.args.cat ):
         # fetch saved presets
         try:
             # read the queries
             presets = eval( xbmcplugin.getSetting( "presets_%s" % ( "videos", "users", "categories", )[ self.args.issearch - 1  ], ) )
             # if this is an existing search, move it up
             for count, preset in enumerate( presets ):
                 if ( repr( query + " | " + self.args.title + " | " )[ : -1 ] in repr( preset ) ):
                     del presets[ count ]
                     break
             # limit to number of searches to save
             if ( len( presets ) >= self.settings[ "saved_searches" ] ):
                 presets = presets[ : self.settings[ "saved_searches" ] - 1 ]
         except:
             # no presets found
             presets = []
         # insert our new search
         presets = [ query + " | " + self.args.title + " | " + self.args.cat + " | " + self.query_thumbnail ] + presets
         # save search query
         xbmcplugin.setSetting( "presets_%s" % ( "videos", "users", "categories", )[ self.args.issearch - 1  ], repr( presets ) )
Ejemplo n.º 40
0
    def __init__( self ) :
        #
        # Init
        #
        IMAGES_PATH        = xbmc.translatePath( os.path.join( os.getcwd(), 'resources', 'images' ) )
        sublightWebService = SublightUtils.SublightWebService()
        
        #
        # Parse parameters...
        #
        params   = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&'))        
        searchBy = params[ "search_by" ]

        #
        # Playing movie...
        #
        if searchBy == "playing" :
            movieFullPath = xbmc.Player().getPlayingFile()
        #
        # Browse for movie file...
        #
        else :
            # Get last location (get up one level if path doesn't exist anymore)...
            lastMoviePath = xbmcplugin.getSetting ("lastMoviePath")
            while lastMoviePath != ""   and         \
                  lastMoviePath != "\\" and         \
                  not os.path.exists(lastMoviePath) :
                lastMoviePath = os.path.dirname(lastMoviePath)
            
            # Browse dialog...
            browse = xbmcgui.Dialog()
            movieFullPath = browse.browse(1, xbmc.getLocalizedString(30200), "video", ".avi|.mp4|.mpg|.mpeg|.wmv|.asf|.divx|.mov|.m2p|.moov|.omf|.qt|.rm|.vob|.dat|.dv|.3ivx|.mkv|.ogm", False, False, lastMoviePath)
            
            # No file selected (exit)...
            if not os.path.isfile(movieFullPath) :
                xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=False )
                return

            # Save last location...
            lastMoviePath = os.path.join(os.path.dirname(movieFullPath), "")
            xbmcplugin.setSetting("lastMoviePath", lastMoviePath)

        # Split in dir and filename...
        movie_dir  = os.path.dirname  (movieFullPath)
        movie_file = os.path.basename (movieFullPath)
        
        #
        # (By Title) Confirm movie title...
        #
        movie_title, movie_year = "", ""
        if searchBy == "title" :
            # Attempt to extract the movie title and year from the file name... 
            movie_title, movie_year = SublightUtils.getMovieTitleAndYear( movie_file )            
            
            #
            # Get a list of similar titles from the webservice...
            #
            movies = sublightWebService.SuggestTitles( movie_title )

            # Ask the user to choose a movie entry...
            if len( movies ) > 0:
                options = []
                for movie in movies :
                   option = "%s (%s)" % ( movie[ "title" ], movie [ "year" ] )
                   options.append( option )
                   
                dialog = xbmcgui.Dialog()
                choice = dialog.select( xbmc.getLocalizedString(30307), options )
                dialog = None
                
                # User made a choice...
                if choice > -1 :
                    movie       = movies[ choice ];
                    movie_title = movie[ "title"]
                    movie_year  = movie[ "year" ]
                # User cancelled...
                else :
                    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=False )
                    return
            #             
            # No matching results...
            #
            else :
                #
                # Ask the user to confirm movie title and year...
                #
                if movie_year != "" :
                    text = "%s (%s)" % ( movie_title, movie_year )
                else :
                    text = "%s"      % ( movie_title )
                            
                keyboard = xbmc.Keyboard( text )
                keyboard.doModal()
                if keyboard.isConfirmed() :
                    movie_title, movie_year = SublightUtils.getMovieTitleAndYear( keyboard.getText() )
                else :
                    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=False )
                    return
        
        #
        # (WebService) Login...
        #
        dp = xbmcgui.DialogProgress()
        dp.create("Sublight" )
        dp.update( 33, xbmc.getLocalizedString(30300), " ", " " )        
        
        # Get session id...
        session_id = sublightWebService.LogInAnonymous()

        #
        # (By video hash) Calculate video hash...
        #
        video_hash = "0000000000000000000000000000000000000000000000000000"
        if searchBy == "hash" :
            video_hash     = SublightUtils.calculateVideoHash( movieFullPath, False )
        
        #
        # (By playing movie) Calculate video hash...
        #
        if searchBy == "playing" :
            videoInfoTag = xbmc.Player().getVideoInfoTag()
            movie_title = videoInfoTag.getTitle()
            movie_year  = ( videoInfoTag.getYear(), "" ) [ videoInfoTag.getYear() == 0 ]
            
            # No movie title, ask user...
            if movie_title == "" :
                keyboard = xbmc.Keyboard( "", xbmc.getLocalizedString(30107) )
                keyboard.doModal()
                if keyboard.isConfirmed() :
                    movie_title, movie_year = SublightUtils.getMovieTitleAndYear( keyboard.getText() )
            
            # Calculate hash...
            video_hash  = SublightUtils.calculateVideoHash( movieFullPath, True )
        
        #
        # (WebService) Search...
        #
        if searchBy == "hash" :
            message = movie_file
        elif searchBy == "title" :                                                            
            message = ( "%s (%s)" % ( movie_title, movie_year ), "%s" % ( movie_title ) ) [ movie_year == "" ]
        elif searchBy == "playing" :
            message = ( "%s (%s)" % ( movie_title, movie_year ), "%s" % ( movie_file ) )  [ movie_year == "" ]
        dp.update( 66, xbmc.getLocalizedString(30301), message, " " )

        # Searching...
        subtitles = []
        language1 = SublightUtils.toSublightLanguage( str( int( xbmcplugin.getSetting ("language1") ) + 1 ) )
        language2 = SublightUtils.toSublightLanguage(           xbmcplugin.getSetting ("language2") )
        language3 = SublightUtils.toSublightLanguage(           xbmcplugin.getSetting ("language3") )
        subtitles = sublightWebService.SearchSubtitles(session_id, video_hash, movie_title, movie_year, language1, language2, language3 )
        
        #
        # No subtitles found...
        #
        if len(subtitles) == 0 :
            # Close dialog progress...
            dp.close()
            
            # Message...
            dialog = xbmcgui.Dialog()
            dialog.ok("Sublight", xbmc.getLocalizedString(30305))
            dialog = None

            # End of directory...
            xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=False )
            
        #
        # Subtitles found...
        #
        else:
            for subtitle in subtitles:
                subtitle_id   =                          subtitle[ "subtitleID" ]
                title         =                          subtitle[ "title" ]
                year          = SublightUtils.toInteger( subtitle[ "year" ] )
                release       =                          subtitle[ "release" ]
                language      =                          subtitle[ "language" ]
                mediaType     =                          subtitle[ "mediaType" ]
                numberOfDiscs = SublightUtils.toInteger( subtitle[ "numberOfDiscs" ] )
                downloads     =                          subtitle[ "downloads" ]
                isLinked      =                          subtitle[ "isLinked" ]                
                icon_flag     = os.path.join( IMAGES_PATH, "flag_%s.gif" % language.lower())
                
                # Add directory entry...
                label  = "[%s]  %s" % ( language, release )
                if isLinked == "true" :
                    label2 = "[COLOR=FF00FF00]%s downloads [%u x %s][/COLOR]" % ( downloads, numberOfDiscs, mediaType )
                else:
                    label2 = "%s downloads [%u x %s]" % ( downloads, numberOfDiscs, mediaType )
                
                listitem = xbmcgui.ListItem( label, label2, "DefaultVideoBig.png", icon_flag )
                listitem.setInfo( type="Video", infoLabels={ "Title" : label, "Genre" : label2, "Year" : year  } )
                url = "%s?action=download&session_id=%s&subtitle_id=%s&subtitle_lang=%s&movie_dir=%s&movie_file=%s&number_of_discs=%u" % \
                    ( sys.argv[ 0 ], urllib.quote_plus( session_id ), urllib.quote_plus( subtitle_id ), urllib.quote_plus( language ), urllib.quote_plus( movie_dir ), urllib.quote_plus( movie_file ), numberOfDiscs )
                xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1 ]), url=url, listitem=listitem, isFolder=False)
    
            # Allow sort by Genre (for list2 labels)...
            xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_GENRE )            
        
            # End of directory...
            xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
Ejemplo n.º 41
0
def set_config(key, value):
    addon_handle = int(sys.argv[1])
    return xbmcplugin.setSetting(addon_handle, key, value)
Ejemplo n.º 42
0
 def setSetting(self, key, value):
     return xbmcplugin.setSetting(key, value)
Ejemplo n.º 43
0
    movieList(SQL.ALL_MOVIES, clause=SQL.YEAR_WHERE % int(movieid))
elif mode==MOVIES_BY_DIRECTOR:
    movieList(SQL.ALL_MOVIES, clause=SQL.DIRECTOR_WHERE % movieid)
elif mode==MOVIES_BY_STUDIO:
    movieList(SQL.ALL_MOVIES, clause=SQL.STUDIO_WHERE % movieid)
elif mode==MOVIES_BY_WRITER:
    movieList(SQL.ALL_MOVIES, clause=SQL.WRITER_WHERE % movieid)
elif mode==MOVIES_BY_LETTER:
    if len(filter_list) == 0:
        f = '-1'
    else:
        f = ",".join(filter_list)
    if movieid == '.': movieid = '\\\\.'
    lclause = SQL.MOVIE_BY_LETTER % (f, movieid)
    print "Clause: %s" % lclause
    movieList(SQL.ALL_MOVIES, clause=lclause, nomax=True)
elif mode==PLAY_ALL_LINKS or mode==PLAY_RANDOM_LINK or mode==PLAY_ALL_RANDOM_LINKS:
    playLinks(mode, movieid)
elif mode==GENRE_TOGGLE:
    if str(movieid) in filter_list:
        filter_list.remove(movieid)
    else:
        filter_list.append(movieid)
    xbmcplugin.setSetting('genreignore', ",".join(filter_list))
    xbmc.executebuiltin('Container.Refresh')
elif mode==MOVIE_LINK_LIST:
    linkList(movieid)

if mode != GENRE_FILTER and mode != GENRE_TOGGLE:
    xbmcplugin.endOfDirectory(int(sys.argv[1]))
Ejemplo n.º 44
0
def VSsetsetting(label,value):
    return xbmcplugin.setSetting(int(sys.argv[1]), label, value)
Ejemplo n.º 45
0
 def setSetting(self, sName, sValue):
     if (self.__bIsDharma):
         return self.__oSettings.setSetting(sName, sValue)
     else:
         return xbmcplugin.setSetting(sName, sValue)
     return
Ejemplo n.º 46
0
def set_setting(name,value):
    try:
        xbmcplugin.setSetting(name,value)
    except:
        pass
Ejemplo n.º 47
0
def setSetting(k,v):
	return xbmcplugin.setSetting(int(sys.argv[1]), k, v)
Ejemplo n.º 48
0
def set_setting(name,value):
    xbmcplugin.setSetting(name,value)
Ejemplo n.º 49
0
def set_setting(name, value):
    try:
        xbmcplugin.setSetting(name, value)
    except:
        pass
Ejemplo n.º 50
0
    li = xbmcgui.ListItem('NEXT PAGE >', iconImage='DefaultVideo.png')
    xbmcplugin.addDirectoryItem(handle=addon_handle,
                                url=url,
                                listitem=li,
                                isFolder=True)

    xbmcplugin.endOfDirectory(addon_handle)

elif mode[0] == 'video_info':
    content = readURL('https://www.newgrounds.com/portal/view/' +
                      args['videoID'][0])
    file = re.compile('uploads.ungrounded.net(.*?)"').findall(content)
    #xbmcgui.Dialog().ok('DEBUG', 'http://uploads.ungrounded.net' + file[0].replace('\\', ''))

    if xbmcplugin.getSetting(addon_handle, 'vquality') == "":
        xbmcplugin.setSetting(addon_handle, 'vquality', '720p')

    for f in file:
        if not ".swf" in f:
            extension = os.path.splitext(f)[1]
            f = f.replace(
                extension,
                '.' + xbmcplugin.getSetting(addon_handle, 'vquality') + '.mp4')
            xbmc.log('https://uploads.ungrounded.net' + f.replace('\\', ''))
            xbmc.Player().play(
                'https://uploads.ungrounded.net' +
                f.replace('\\', ''))  #file 3 is always mobile compatible?

elif mode[0] == 'audio_list':
    content = readURL('https://www.newgrounds.com/audio/browse/genre/' +
                      args['cat'][0] + '/page/' + args['page'][0])
Ejemplo n.º 51
0
 def _parse_trailers( self, xmlSource, category ):
     try:
         # set our post dates for the recently added list
         old_postdate_min = new_postdate_min = xbmcplugin.getSetting( "postdate_min" )
         old_postdate_max = new_postdate_max = xbmcplugin.getSetting( "postdate_max" )
         # set our ratings
         mpaa_ratings = { "G": 0, "PG": 1, "PG-13": 2, "R": 3, "NC-17": 4, None: 5 }
         # encoding
         encoding = re.findall( "<\?xml version=\"[^\"]*\" encoding=\"([^\"]*)\"\?>", xmlSource[ 0 ] )[ 0 ]
         # split category
         if ( category is not None ):
             category, category_value = category.split( ": " )
         # gather all trailer records <movieinfo>
         trailers = re.findall( "<movieinfo id=\"(.+?)\"><info><title>(.+?)</title><runtime>(.*?)</runtime><rating>(.*?)</rating><studio>(.*?)</studio><postdate>(.*?)</postdate><releasedate>(.*?)</releasedate><copyright>(.*?)</copyright><director>(.*?)</director><description>(.*?)</description></info>(?:<cast>(.+?)</cast>)?(?:<genre>(.+?)</genre>)?<poster><location>(.*?)</location>(?:</poster><poster>)?<xlarge>(.*?)</xlarge></poster><preview><large filesize=\"(.+?)\">(.+?)</large></preview></movieinfo>", xmlSource[ 0 + ( 2 * ( self.settings[ "trailer_quality" ] > 1 and self.settings[ "trailer_hd_only" ] ) ) ] )
         trailers_480p = dict( re.findall( "<movieinfo id=\"(.+?)\">.+?<preview><large filesize=\"(.+?\">.+?)</large></preview></movieinfo>", xmlSource[ 1 ] ) )
         trailers_720p = dict( re.findall( "<movieinfo id=\"(.+?)\">.+?<preview><large filesize=\"(.+?\">.+?)</large></preview></movieinfo>", xmlSource[ 2 ] ) )
         # enumerate thru the movies list and gather info
         for trailer in trailers:
             # encode/clean title
             title = unicode( unescape( trailer[ 1 ] ), encoding, "replace" )
             # format post date, we do this here so filtered lists won't affect the actual results
             postdate = trailer[ 5 ]
             # check if this is a new trailer
             if ( postdate > old_postdate_max ):
                 if ( not new_postdate_min or postdate < new_postdate_min or new_postdate_min == old_postdate_min ):
                     new_postdate_min = postdate
                 if ( postdate > new_postdate_max ):
                     new_postdate_max = postdate
             if ( category == "recent" and postdate < old_postdate_min ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s [RECENT]" % ( repr( title ).ljust( 50 ), old_postdate_min, postdate, ) )
                 continue
             # check for valid mpaa rating
             if ( self.settings[ "rating" ] < mpaa_ratings.get( trailer[ 3 ], self.settings[ "not_rated_rating" ] ) ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s" % ( repr( title ).ljust( 50 ), ( "G", "PG", "PG-13", "R", "NC-17", "--", )[ self.settings[ "rating" ] ], ( "%s (%s)" % ( ( "G", "PG", "PG-13", "R", "NC-17", "--", )[ self.settings[ "not_rated_rating" ] ], trailer[ 3 ], ), trailer[ 3 ], )[ trailer[ 3 ] != "Not yet rated" ] , ) )
                 continue
             mpaa = ( trailer[ 3 ], "Rated %s" % ( trailer[ 3 ], ), )[ trailer[ 3 ] != "" and trailer[ 3 ] != "Not yet rated" ]
             # parse genres 
             genres = re.findall( "<name>(.+?)</name>", trailer[ 11 ] )
             # if a genre based category, check it
             if ( category == "genres" and category_value not in genres ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s [GENRE]" % ( repr( title ).ljust( 50 ), category_value, " / ".join( genres ), ) )
                 continue
             # encode/clean studio
             studio = unicode( unescape( trailer[ 4 ] ), encoding, "replace" )
             # if a studio based category, check it
             if ( category == "studios" and studio != category_value ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s [STUDIO]" % ( repr( title ).ljust( 50 ), repr( category_value ), repr( studio ), ) )
                 continue
             # encode/clean director
             director = unicode( unescape( trailer[ 8 ].replace( ", ", " | " ) ), encoding, "replace" )
             # if a director based category, check it
             if ( category == "directors" and category_value not in director ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s [DIRECTOR]" % ( repr( title ).ljust( 50 ), repr( category_value ), repr( director ), ) )
                 continue
             # parse actors 
             actors = unicode( unescape( " / ".join( re.findall( "<name>(.+?)</name>", trailer[ 10 ] ) ) ), encoding, "replace" ).split( " / " )
             # if a actor based category, check it
             if ( category == "actors" and category_value not in " / ".join( actors ) ):
                 LOG( "* Skipping *: %s   Preferred: %s, Trailer: %s [ACTOR]" % ( repr( title ).ljust( 50 ), repr( category_value ), repr( " / ".join( actors ) ), ) )
                 continue
             # encode/clean copyright
             copyright = unicode( unescape( trailer[ 7 ] ), encoding, "replace" )
             # convert size to long
             size = long( trailer[ 14 ] )
             # add User-Agent to correct poster url
             poster = ( trailer[ 13 ] or trailer[ 12 ] ) + "?|User-Agent=%s" % ( urllib.quote_plus( sys.modules[ "__main__" ].__useragent__ ), )
             # set initial trailer url
             trailer_url = unicode( trailer[ 15 ], "utf-8" )
             # select preferred trailer quality
             if ( self.settings[ "trailer_quality" ] > 0 ):
                 if ( self.settings[ "trailer_quality" ] > 1 and trailers_720p.has_key( trailer[ 0 ] ) ):
                     if ( not self.settings[ "trailer_hd_only" ] ):
                         size, trailer_url = trailers_720p[ trailer[ 0 ] ].split( "\">" )
                     # replace with 1080p if user preference is 1080p
                     if ( self.settings[ "trailer_quality" ] == 3 ):
                         trailer_url = trailer_url.replace( "a720p.m4v", "h1080p.mov" )
                 elif ( trailers_480p.has_key( trailer[ 0 ] ) ):
                     size, trailer_url = trailers_480p[ trailer[ 0 ] ].split( "\">" )
                 # convert size to long
                 size = long( size )
             # add User-Agent to trailer url
             trailer_url += "?|User-Agent=%s" % ( urllib.quote_plus( sys.modules[ "__main__" ].__useragent__ ), )
             # encode/clean plot
             plot = unicode( unescape( trailer[ 9 ] ), encoding, "replace" )
             # duration of trailer
             # this displays right in video info dialog, but not in the lists (the formula xbmc uses does not accept seconds)
             #duration = xbmc.getLocalizedString( 14044 ).replace( "%i", "%s" ) % ( trailer[ 2 ], )
             duration = "%s:%s" % ( trailer[ 2 ].replace( ":", "" ).rjust( 4, "0" )[ : 2 ], trailer[ 2 ].replace( ":", "" ).rjust( 4, "0" )[ 2 : ], )
             # format release date
             releasedate = trailer[ 6 ]
             # add the item to our media list
             ok = self._add_video( { "title": title, "duration": duration, "mpaa": mpaa, "studio": studio, "postdate": postdate, "releasedate": releasedate, "copyright": copyright, "director": director, "plot": plot, "cast": actors, "genre": " / ".join( genres ), "poster": poster, "trailer": trailer_url, "size": size } )
             # if error adding video, raise an exeption
             if ( not ok ): raise
         # set our new postdate
         xbmcplugin.setSetting( "postdate_min", new_postdate_min )
         xbmcplugin.setSetting( "postdate_max", new_postdate_max )
     except Exception, e:
         # oops, notify user what error occurred
         LOG( str( e ), xbmc.LOGERROR )
         self.success = False
Ejemplo n.º 52
0
Archivo: brtv.py Proyecto: akgdrg/ru
 def setSetting(self, key, value):
     return xbmcplugin.setSetting(key, value)
Ejemplo n.º 53
0
def set_config(key, value):
    addon_handle = int(sys.argv[1])
    return xbmcplugin.setSetting(addon_handle, key, value)
Ejemplo n.º 54
0
def save_settings():
    xbmcplugin.setSetting("session_key", settings[SESSION_KEY])
    xbmcplugin.setSetting("uid", settings[UID])
Ejemplo n.º 55
0
 def setSetting(self, sName, sValue):
     if (self.__bIsDharma):
         return self.__oSettings.setSetting(sName, sValue)
     else:
         return xbmcplugin.setSetting(sName, sValue)
     return
Ejemplo n.º 56
0
def save_settings():
        xbmcplugin.setSetting( "session_key", settings[SESSION_KEY] )
        xbmcplugin.setSetting( "uid", settings[UID] )