TOOLSP
"
WELCOME !

Please ! USE [CODE] tags for your LINKS and CODE.

Favor usar balisas [CODE] para sus vínculos y código.

Merci d'utiliser les balises [CODE] pour vos liens et code.


[code]http://Thank.you[/code]
"
*** Doc. Kodi & PYthon ***
.
.
Python & Modules PY
.
.
.
.
(Video) Cache Kodi
.
.
.
Addons Kodi
.
.
.
Addons Kodi
.
.
*** GITHUB ***
.
.
URLresolver (J.S.) [GIT] +
.
.
.
URLresolver (elD.) [GIT] -
.
.
URLresolver (tvA.) [GIT] -
.
.
.
.
Cloudflare (external) [GIT]
.
.
.
*** Associated ***
.
Pastebin Your list online
.
mediafire Upload Files
.
imgur Upload Pics
lyngsat TV logos collection
transparent .png
.
http://hola.org free? VPN
Hola.apk free? VPN App.
.
hidester- free Proxy
.
webgrabplus EPG - Eng
xmltv EPG - Fr
kazer EPG - Fr
.
.wordreference Traduction
.
mail.com (fast sign-in)
.
.
FRIENDS / PARTNERS

£$π community

créer un forum


BUILD AND USE A MEMORY (XML + PYTHON)

Go down

BUILD AND USE A MEMORY (XML + PYTHON)

Post by jujuuj on Sun 28 Jan - 17:22

INFO :
This should work ...



BUILD AND USE a local MEMORY in an online XML LIST   (using python ! for Kodi 17/+)


The idea is to build an item called memory that will be able to Record a data (locally in hard disk),
in order to use this data later (without having to type it again...)

The interesting thing is that this data in memory is NOT shared online ...
(it could be a password, a key, a precious url ...)
So you can call it or use it in an item of a shared-online-list, without sharing it anyway ...





First, we build a window that will ask you to enter a text(password, url, ...) and will save it as "solution".

Code:

  solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  return solution



As option, you can decide to select just a part of the text in memory (so you will use " re.findall(expres, solution) " ; and of course adapt the 'expres'  [in my example, the expres "takes" the whole text].

Code:

 solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  expres = '(.+)'
  return re.findall(expres, solution)
 


Of course we need to define some things, as the path (~repertory) (UP)  & the WindowDialog to write our text (DOWN).

Code:

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt = 'Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
  
  solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  expres = '(.+)'
  return re.findall(expres, solution)

class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False

( note that with this " xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/ " , £$π will find the path in any case,
no matters if windows or linux, android, mac ... etc )

     
     
     
     
and ... don't forget to declare / define / add  everything you will use !    [ in lines ' import ' and  'defLSProData' , plus at the end, Class _input_window , and  def_ ... ]

Code:

import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt='Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
  
  solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  expres = '(.+)'
  return re.findall(expres, solution)

class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
       
 
NOTE : DON'T CHANGE A SPACE AT THE BEGINING OF LINES IN PYTHON OR IT WILL RETURN ERROR. ( This is why I am using the [ code ] tag ... and not simple text )





Let's put all that in a xml item ...


Code:
   
<item>
<title>v1b    MEMORY   </title>
<thumbnail>http://www.iconsplace.com/icons/preview/orange/number-1-256.png</thumbnail>
<link>$doregex[makelist]</link>

<regex>
<name>makelist</name>
      <listrepeat><![CDATA[
      <title>[makelist.param1]</title>
      <link>NA</link>  
      <externallink>http://[makelist.param2]</externallink>  
      ]]></listrepeat>
<expres>((.+))</expres>         <!--at least 2 params-->
<page>$doregex[texte]</page>
</regex>
 
<regex>
<name>texte</name>      
<expres><![CDATA[#$pyFunction      
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt='Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
  
  solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  expres = '(.+)'
  return re.findall(expres, solution)

class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
]]></expres>
<page></page>
</regex>  

</item>

   
depending the type of content of your memory, you will use it differently : in title, in a link, or in externallink, or inside an url if password ...  
so be sure of where you put the [makelist.param1]  (which is the content of the memory ; or part of it sometimes)    


That item will record a text in memory (and "return" it where you want)
after using it, you can see the file here :   /.kodi/userdata/addon_data/plugin.video.live.streamspro/MEMORY.txt
and ... delete it  (to try again ...).
   
   
-

 

OK ... Now , what about if we ALREADY have (entered) a data in memory ?

then, we don't want £$π to ask it again !
and we don't want to erase the first data !

So ... We are going to ask £$π to :
First, check if MEMORY is existing and use the data inside
Two, if not existing, then Yes, we want to Enter a data ...


so we change the
Code:
 
  solver = InputWindow( txt=txt)
  solution = solver.get()
  f = open(path, 'w')
  f.write(solution)
  f.close()
  expres = '(.+)'
  return re.findall(expres, solution)
 

for this :
Code:

  try:
 f = open(path, 'r')
 solution = f.read()
 f.close()
 # sourcecodeexistencetest = requests.get(solution, headers= myheaders).text      
 ## this last line could try to open the url ( if the memory is an url ...)
 
  except:
 solver = InputWindow( txt=txt)
 solution = solver.get()
 f = open(path, 'w')
 f.write(solution)
 f.close()

  expres = '(.+)'
  return re.findall(expres, solution)
     
     




This is our new item ... :


Code:
   
<item>
<title>v2b    MEMORY   </title>
<thumbnail>http://www.iconsplace.com/icons/preview/orange/number-1-256.png</thumbnail>
<link>$doregex[makelist]</link>

<regex>
<name>makelist</name>
      <listrepeat><![CDATA[
      <title>[makelist.param1]</title>
      <link>NA</link>  
      <externallink>http://[makelist.param2]</externallink>  
      ]]></listrepeat>
<expres>((.+))</expres>         <!--at least 2 params-->
<page>$doregex[texte]</page>
</regex>
 
<regex>
<name>texte</name>      
<expres><![CDATA[#$pyFunction      
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt='Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
  
  try:
 f = open(path, 'r')
 solution = f.read()
 f.close()
 # sourcecodeexistencetest = requests.get(solution, headers= myheaders).text      ## this could try to open the url ( if the memory is an url ...)
 
  except:
 solver = InputWindow( txt=txt)
 solution = solver.get()
 f = open(path, 'w')
 f.write(solution)
 f.close()

  expres = '(.+)'
  return re.findall(expres, solution)
  
class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
]]></expres>
<page></page>
</regex>  
  
</item>





Last thing, I want the text in memory to appear in the title of my item MEMORY    (or a [+] , if empty or no file)

So, I modify the title :     <title>   MEMORY     $doregex[show-memo]  </title>
and I build my regex  [show-memo] ...


Here the result :

Code:
   
<item>
<title>v3b   MEMORY    [ $doregex[show-memo] ] </title>
<thumbnail>http://www.iconsplace.com/icons/preview/orange/number-1-256.png</thumbnail>
<link>$doregex[makelist]</link>

<regex>
<name>makelist</name>
      <listrepeat><![CDATA[
      <title>[makelist.param1]</title>
      <link>NA</link>  
      <externallink>http://[makelist.param2]</externallink>  
      ]]></listrepeat>
      <expres>((.+))</expres>          <!--at least 2 params-->
<page>$doregex[texte]</page>
</regex>
 
<regex>
<name>texte</name>      
<expres><![CDATA[#$pyFunction      
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt='Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
  
  try:
 f = open(path, 'r')
 solution = f.read()
 f.close()
 # sourcecodeexistencetest = requests.get(solution, headers= myheaders).text      ## this could try to open the url ( if the memory is an url ...)
 
  except:
 solver = InputWindow( txt=txt)
 solution = solver.get()
 f = open(path, 'w')
 f.write(solution)
 f.close()

  expres = '(.+)'
  return re.findall(expres, solution)
  
class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
]]></expres>
<page></page>
</regex>  
 

<regex>
  <name>show-memo</name>      
  <expres><![CDATA[#$pyFunction
import urllib, xbmc, xbmcaddon
def GetLSProData(page_data,Cookie_Jar,m):
  
  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY.txt")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  try:
 f = open(path, 'r')
 text =  f.read() + '+'
 f.close()
 return text
  except:
 return '+'
]]></expres>
  <page></page>
  </regex>    
  
</item>
 

 
(note:)  
If you are dealing with an url of a list,  you will certainly think about :
use externallink and not link ...
the &amp; or & dilemna  >     return text.replace('&amp;','&')
# sourcecodeexistencetest




OK GUYS !  THAT'S ALL FOLKS (*) , FOR TODAY
I hope yo will enjoy this and you will turn ON
the reverse engineering and the share Buttons !

(*) All this Python stuff is an heritage from Twoguns, who inspired, defined and built large parts, of my Py-codes ...





... and I won't let you without the item to "erase" data in MEMORY.txt ... Here :

[THIS LAST ITEM IS A DIFFERENT THING !]
Code:

<item>
  <title>      [COLOR orange]CLEAR  a  MEMORY [/COLOR] </title>     (V.5)
  <thumbnail>http://i.imgur.com/dCctby2.png</thumbnail>   http://blog.softwaredownloadcentre.com/wp-content/uploads/2014/09/iStock_delete_key_Small.jpg
  <link>NA</link>  
  <externallink>$doregex[clearMEMO]</externallink>
  
  <regex>
  <name>clearMEMO</name>
<expres><![CDATA[#$pyFunction
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  dialog = xbmcgui.Dialog()
  ret = dialog.select('CLEAR  MEMORY  ? ', ['None', 'MEMORY.txt', '# 2', '# 3', '# 4', '# 5', 'ALL  MEMORIES'])
  MEMOrefs = ['MEMORY.0.txt', 'MEMORY.txt', 'MEMORY.2.txt', 'MEMORY.3.txt', 'MEMORY.4.txt', 'MEMORY.5.txt', '']
  selected = MEMOrefs[ret]

  try:
    path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + selected)
    addon = xbmcaddon.Addon('plugin.video.live.streamspro')
    addon_version = addon.getAddonInfo('version')
    profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
    newcontent = ''
    f = open(path, 'w')
    f.write(newcontent)
    f.close()
    xbmc.executebuiltin("XBMC.Notification(Done !, Memory cleared !, 2000)")
    return 'http://pastebin.com/raw/'    ###YOUR URL HERE###

  except:
    xbmc.executebuiltin("XBMC.Notification(... , Clearing all ..., 2000)")
    path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/")
    addon = xbmcaddon.Addon('plugin.video.live.streamspro')
    addon_version = addon.getAddonInfo('version')
    profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
    newcontent = ''
    f = open(path + 'MEMORY.0.txt', 'w')
    f.write(newcontent)
    f.close()
    f = open(path + 'MEMORY.txt', 'w')
    f.write(newcontent)
    f.close()
    f = open(path + 'MEMORY.2.txt', 'w')
    f.write(newcontent)
    f.close()
    f = open(path + 'MEMORY.3.txt', 'w')
    f.write(newcontent)
    f.close()
    f = open(path + 'MEMORY.4.txt', 'w')
    f.write(newcontent)
    f.close()
    f = open(path + 'MEMORY.5.txt', 'w')
    f.write(newcontent)
    f.close()
    xbmc.executebuiltin("XBMC.Notification(Done !, All Memories cleared !, 5000)")
    return 'http://pastebin.com/raw/'   ###YOUR URL HERE###
 
class InputWindow(xbmcgui.WindowDialog):
    def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

    def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
 
]]></expres>
<page></page>
</regex>
  
</item>  

Bye Bye !   ... and  Good Luck !

Smile


Last edited by jujuuj on Mon 29 Jan - 5:36; edited 6 times in total (Reason for editing : debug ... :))
avatar
jujuuj

Messages : 199
Date d'inscription : 2017-03-28

View user profile

Back to top Go down

double entry in Memory

Post by jujuuj on Sun 28 Jan - 20:30

for a double entry,  as user(name) and pass(word)
you will need two question-boxes = 2 Window-Dialog
we will save BOTH entries in a single file called Key.txt ...


like this :
Code:


(...)

 path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/Key.txt")
 
 txt1='User?'
 txt2='Password?'

 solver = InputWindow( txt=txt1)
 u = solver.get()
 solver = InputWindow( txt=txt2)
 p = solver.get()
 key = 'user=' + u + '&pass=' + p
 f = open(path, 'w')
 f.write(key)
 f.close()

 return 'http://not.really.good/' + key

(...)



I let you add the missing parts, as above ... (item V3B)
avatar
jujuuj

Messages : 199
Date d'inscription : 2017-03-28

View user profile

Back to top Go down

Re: BUILD AND USE A MEMORY (XML + PYTHON)

Post by jujuuj on Mon 29 Jan - 5:33

this is live debug !
no time for explanations Wink

Code:



<item>  <title>v44  MEMORY    [ $doregex[show-memo] ] </title>
<thumbnail>http://www.iconsplace.com/icons/preview/orange/number-1-256.png</thumbnail>
<link>$doregex[makelist]</link>

<regex>
<name>makelist</name>
      <listrepeat><![CDATA[
      <title>[makelist.param1]</title>
      <link>NA</link> 
      <externallink>http://[makelist.param2]</externallink> 
      ]]></listrepeat>
      <expres>((.+))</expres>          <!--at least 2 params-->
<page>$doregex[texte]</page>
</regex>
   
<regex>
<name>texte</name>     
<expres><![CDATA[#$pyFunction     
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
def GetLSProData(page_data,Cookie_Jar,m):

  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  txt='Enter URL ?  or password or any text ... '
  myheaders = {'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:34.0) Gecko/20100101 Firefox/34.0', 'Referer': ''}
 
  try:
   f = open(path, 'r')
   solution = f.read()
   f.close()
   # sourcecodeexistencetest = requests.get(solution, headers= myheaders).text      ## this could try to open the url ( if the memory is an url ...)
            
  except:
   solver = InputWindow( txt=txt)
   solution = solver.get()
   f = open(path, 'w')
   f.write(solution)
   f.close()

  expres = '(.+)'
  return re.findall(expres, solution)
 
class InputWindow(xbmcgui.WindowDialog):
  def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

  def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
]]></expres>
<page></page>
</regex> 
 

<regex>
  <name>show-memo</name>     
  <expres><![CDATA[#$pyFunction
import urllib, xbmc, xbmcaddon
def GetLSProData(page_data,Cookie_Jar,m):
 
  path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/" + "MEMORY")
  addon = xbmcaddon.Addon('plugin.video.live.streamspro')
  addon_version = addon.getAddonInfo('version')
  profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
  try:
   f = open(path, 'r')
   text =  f.read()
   f.close()
   return text
  except:
   return '+'
]]></expres>
  <page></page>
  </regex>   
 
</item>
 







<item>  <title> v44    SIMPLE [COLOR orange]  DELETE  a  MEMORY [/COLOR]  </title>   
  <thumbnail>http://i.imgur.com/dCctby2.png</thumbnail>
  <link>NA</link> 
  <externallink>$doregex[clearMEMO]</externallink>
 
  <regex>
  <name>clearMEMO</name>
<expres><![CDATA[#$pyFunction
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
import os
def GetLSProData(page_data,Cookie_Jar,m):

  dialog = xbmcgui.Dialog()
  ret = dialog.select('CLEAR  MEMORY  ? ', ['None', 'MEMORY', '# 2', '# 3', '# 4', '# 5'])
  MEMOrefs = ['MEMORY0', 'MEMORY', 'MEMORY2', 'MEMORY3', 'MEMORY4', 'MEMORY5']
  selected = MEMOrefs[ret]

  try:
    path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/")
    addon = xbmcaddon.Addon('plugin.video.live.streamspro')
    addon_version = addon.getAddonInfo('version')
    profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
     
    os.remove (path + selected)
   
    xbmc.executebuiltin("XBMC.Notification(Done !, Memory cleared !, 2000)")
    return 'https://pastebin.com/raw/k5pFk4pe'    ### YOUR URL HERE ### (or /path/local/file.xml)

  except:
    pass
 
class InputWindow(xbmcgui.WindowDialog):
    def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

    def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
 
]]></expres>
<page></page>
</regex>
 
</item> 









<item>  <title>v44  [COLOR orange]  DELETE  1 or more  MEMORies [/COLOR] </title>   
  <thumbnail>http://i.imgur.com/dCctby2.png</thumbnail>
  <link>NA</link> 
  <externallink>$doregex[clearMEMO]</externallink>
 
  <regex>
  <name>clearMEMO</name>
<expres><![CDATA[#$pyFunction
import urllib, re, requests, xbmcgui, xbmc, xbmcaddon, time
import os
def GetLSProData(page_data,Cookie_Jar,m):

  dialog = xbmcgui.Dialog()
  ret = dialog.select('CLEAR  MEMORY  ? ', ['None', 'MEMORY', '# 2', '# 3', '# 4', '# 5', 'ALL  MEMORIES'])
  MEMOrefs = ['MEMORY0', 'MEMORY', 'MEMORY2', 'MEMORY3', 'MEMORY4', 'MEMORY5', '']
  selected = MEMOrefs[ret]

  try:
    path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/")
    addon = xbmcaddon.Addon('plugin.video.live.streamspro')
    addon_version = addon.getAddonInfo('version')
    profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
     
    f = open(path + selected, 'w')
    f.write(' ')
    f.close()
    os.remove (path + selected)
   
    xbmc.executebuiltin("XBMC.Notification(Done !, Memory cleared !, 2000)")
    return 'https://pastebin.com/raw/k5pFk4pe'    ### YOUR URL HERE ### (or /path/local/file.xml)

  except:
    path = xbmc.translatePath("special://profile/addon_data/" + "plugin.video.live.streamspro/")
    addon = xbmcaddon.Addon('plugin.video.live.streamspro')
    addon_version = addon.getAddonInfo('version')
    profile = xbmc.translatePath(addon.getAddonInfo('profile').decode('utf-8'))
   
    xbmc.executebuiltin("XBMC.Notification(... , Clearing all ..., 2000)")
   
    f = open(path + 'MEMORY0', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY0')
    f = open(path + 'MEMORY', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY')
    f = open(path + 'MEMORY2', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY2')
    f = open(path + 'MEMORY3', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY3')
    f = open(path + 'MEMORY4', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY4')
    f = open(path + 'MEMORY5', 'w')
    f.write(' ')
    f.close()
    os.remove (path + 'MEMORY5')
   
    xbmc.executebuiltin("XBMC.Notification(Done !, All Memories cleared !, 5000)")
    return 'https://pastebin.com/raw/k5pFk4pe'    ### YOUR URL HERE ### (or /path/local/file.xml)
 
class InputWindow(xbmcgui.WindowDialog):
    def __init__(self, *args, **kwargs):
        self.txt = kwargs.get('txt','')
        xbmcgui.WindowXMLDialog.__init__(self)
        #self.addControl(self.txt)
        path = xbmcaddon.Addon().getAddonInfo('path')
        self.kbd = xbmc.Keyboard()
        self.kbd.setHeading( self.txt)

    def get(self):
        self.show()
        time.sleep(2)
        self.kbd.doModal()
        if (self.kbd.isConfirmed()):
            text = self.kbd.getText()
            self.close()
            return text
        self.close()
        return False
 
]]></expres>
<page></page>
</regex>
 
</item> 


avatar
jujuuj

Messages : 199
Date d'inscription : 2017-03-28

View user profile

Back to top Go down

Re: BUILD AND USE A MEMORY (XML + PYTHON)

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum