The branch, eden has been updated
       via  f5bf890bd47c808cc71c27a40bc069bce9c95cf1 (commit)
       via  32dcbcde9a154d0b7ee3ae64dc24759c4d0581d0 (commit)
      from  c7fe3ee8c47919c00d8d7d0f0703f35e6a28c8d1 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=f5bf890bd47c808cc71c27a40bc069bce9c95cf1

commit f5bf890bd47c808cc71c27a40bc069bce9c95cf1
Author: spiff <[email protected]>
Date:   Sun Jul 29 13:01:48 2012 +0200

    [script.module.parsedom] -v1.1.0

diff --git a/script.module.parsedom/addon.xml b/script.module.parsedom/addon.xml
index 15954c5..ac2404f 100644
--- a/script.module.parsedom/addon.xml
+++ b/script.module.parsedom/addon.xml
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
-<addon id="script.module.parsedom" version="1.0.0" name="Parsedom for xbmc 
plugins" provider-name="TheCollective">
+<addon id='script.module.parsedom' version='1.1.0' name='Parsedom for xbmc 
plugins' provider-name='TheCollective'>
   <requires>
     <import addon='xbmc.python' version='2.0'/>
   </requires>
diff --git a/script.module.parsedom/changelog.txt 
b/script.module.parsedom/changelog.txt
index e7ed26e..7e67f37 100644
--- a/script.module.parsedom/changelog.txt
+++ b/script.module.parsedom/changelog.txt
@@ -1,3 +1,7 @@
+[B]Version 1.1.0[/B]
+- Handle \t that breaks DOM variable extraction
+- Added extractJS function
+
 [B]Version 1.0.0[/B]
 - Minor fixes
 
diff --git a/script.module.parsedom/lib/CommonFunctions.py 
b/script.module.parsedom/lib/CommonFunctions.py
index 21a17e9..c72a571 100644
--- a/script.module.parsedom/lib/CommonFunctions.py
+++ b/script.module.parsedom/lib/CommonFunctions.py
@@ -25,8 +25,7 @@ import inspect
 import time
 import HTMLParser
 
-
-version = "1.0.0"
+version = "1.1.0"
 plugin = "CommonFunctions-" + version
 print plugin
 
@@ -171,7 +170,7 @@ def _getDOMContent(html, name, match, ret):  # Cleanup
 
 def _getDOMAttributes(match, name, ret):
     log("", 3)
-    lst = re.compile('<' + name + '.*? ' + ret + '=(.[^>]*?)>', re.M | 
re.S).findall(match)
+    lst = re.compile('<' + name + '.*?' + ret + '=(.[^>]*?)>', re.M | 
re.S).findall(match)
     ret = []
     for tmp in lst:
         cont_char = tmp[0]
@@ -271,10 +270,86 @@ def parseDOM(html, name="", attrs={}, ret=False):
     return ret_lst
 
 
-def extractJSON(data):
-    lst = re.compile('({.*?})', re.M | re.S).findall(data)
-    return lst
+def extractJS(data, function=False, variable=False, match=False, 
evaluate=False, values=False):
+    log("")
+    scripts = parseDOM(data, "script")
+    if len(scripts) == 0:
+        log("Couldn't find any script tags. Assuming javascript file was 
given.")
+        scripts = [data]
 
+    lst = []
+    log("Extracting", 4)
+    for script in scripts:
+        tmp_lst = []
+        if function:
+            tmp_lst = re.compile(function + '\(.*?\).*?;', re.M | 
re.S).findall(script)
+        elif variable:
+            tmp_lst = re.compile(variable + '[ ]+=.*?;', re.M | 
re.S).findall(script)            
+        else:
+            tmp_lst = [script]
+        if len(tmp_lst) > 0:
+            log("Found: " + repr(tmp_lst), 4)
+            lst += tmp_lst
+        else:
+            log("Found nothing on: " + script, 4)
+
+    test = range(0, len(lst))
+    test.reverse()
+    for i in test:
+        if match and lst[i].find(match) == -1:
+            log("Removing item: " + repr(lst[i]), 10)
+            del lst[i]
+        else:
+            log("Cleaning item: " + repr(lst[i]), 4)
+            if lst[i][0] == "\n":
+                lst[i] == lst[i][1:]
+            if lst[i][len(lst) -1] == "\n":
+                lst[i] == lst[i][:len(lst)- 2]
+            lst[i] = lst[i].strip()
+
+    if values or evaluate:
+        for i in range(0, len(lst)):
+            log("Getting values %s" % lst[i])
+            if function:
+                if evaluate: # include the ( ) for evaluation
+                    data = re.compile("(\(.*?\))", re.M | re.S).findall(lst[i])
+                else:
+                    data = re.compile("\((.*?)\)", re.M | re.S).findall(lst[i])
+            elif variable:
+                tlst = re.compile(variable +".*?=.*?;", re.M | 
re.S).findall(lst[i])
+                data = []
+                for tmp in tlst:
+                    cont_char = tmp[0]
+                    cont_char = tmp[tmp.find("=") + 1:].strip()
+                    cont_char = cont_char[0]
+                    if cont_char in "'\"":
+                        log("Using %s as quotation mark" % cont_char, 3)
+                        tmp = tmp[tmp.find(cont_char) + 1:tmp.rfind(cont_char)]
+                    else:
+                        log("No quotation mark found", 3)
+                        tmp = tmp[tmp.find("=") + 1: tmp.rfind(";")]
+
+                    tmp = tmp.strip()
+                    if len(tmp) > 0:
+                        data.append(tmp)
+            else:
+                log("ERROR: Don't know what to extract values from")
+
+            log("Values extracted: %s" % repr(data))
+            if len(data) > 0:
+                lst[i] = data[0]
+
+    if evaluate:
+        for i in range(0, len(lst)):
+            log("Evaluating %s" % lst[i])
+            data = lst[i].strip()
+            try:
+                lst[i] = eval(data)
+            except:
+                log("Couldn't eval: %s from %s" % (repr(data), repr(lst[i])))
+
+    log("Done: " + str(len(lst)))
+    return lst
 
 def fetchPage(params={}):
     get = params.get

http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=32dcbcde9a154d0b7ee3ae64dc24759c4d0581d0

commit 32dcbcde9a154d0b7ee3ae64dc24759c4d0581d0
Author: spiff <[email protected]>
Date:   Sun Jul 29 13:00:29 2012 +0200

    [script.common.plugin.cache] -v1.1.0

diff --git a/script.common.plugin.cache/addon.xml 
b/script.common.plugin.cache/addon.xml
index be9d0eb..d23abe2 100644
--- a/script.common.plugin.cache/addon.xml
+++ b/script.common.plugin.cache/addon.xml
@@ -1,5 +1,5 @@
 <?xml version='1.0' encoding='UTF-8' standalone='yes'?>
-<addon id='script.common.plugin.cache' version='1.0.0' name='Common plugin 
cache' provider-name='TheCollective'>
+<addon id='script.common.plugin.cache' version='1.1.0' name='Common plugin 
cache' provider-name='TheCollective'>
   <requires>
     <import addon='xbmc.python' version='2.0'/>
   </requires>
diff --git a/script.common.plugin.cache/lib/StorageServer.py 
b/script.common.plugin.cache/lib/StorageServer.py
index c9fcbfa..aaa23bb 100644
--- a/script.common.plugin.cache/lib/StorageServer.py
+++ b/script.common.plugin.cache/lib/StorageServer.py
@@ -33,7 +33,7 @@ except: pass
 
 class StorageServer():
     def __init__(self, table=None, timeout=24, instance=False):
-        self.version = "1.0.0"
+        self.version = "1.1.0"
         self.plugin = "StorageClient-" + self.version
         self.instance = instance
         self.die = False

-----------------------------------------------------------------------

Summary of changes:
 script.common.plugin.cache/addon.xml            |    2 +-
 script.common.plugin.cache/lib/StorageServer.py |    2 +-
 script.module.parsedom/addon.xml                |    2 +-
 script.module.parsedom/changelog.txt            |    4 +
 script.module.parsedom/lib/CommonFunctions.py   |   87 +++++++++++++++++++++--
 5 files changed, 88 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to