The branch, frodo has been updated
       via  a44aac04d6bef609be9aefd255e8f31aa9229cf2 (commit)
      from  e7d6304ad7a594e7214deca75472d020f7c9a60f (commit)

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

commit a44aac04d6bef609be9aefd255e8f31aa9229cf2
Author: Martijn Kaijser <[email protected]>
Date:   Mon Aug 19 18:09:24 2013 +0200

    [script.module.universal] 1.0.1

diff --git a/script.module.universal/addon.xml 
b/script.module.universal/addon.xml
index ca6da1b..509b9de 100644
--- a/script.module.universal/addon.xml
+++ b/script.module.universal/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <addon id="script.module.universal"
        name="Universal - An Addons Toolkit"
-       version="1.0.0"
+       version="1.0.1"
        provider-name="the-one">
   <requires>
     <import addon="xbmc.python" version="2.1.0"/>
diff --git a/script.module.universal/changelog.txt 
b/script.module.universal/changelog.txt
index 585e34a..0c1c2a4 100644
--- a/script.module.universal/changelog.txt
+++ b/script.module.universal/changelog.txt
@@ -1,5 +1,11 @@
+[B]v1.0.1[/B]
+Bug Fix: Unicode UTF8 to string ASCII conversion
+Bug Fix: Favorites - Read from database, convert <dquot> to "
+Bug Fix: Favorites - Apostrphe issues in database queries
+Update: Favorites - Notification messages format
+
 [B]v1.0.0[/B]
 Initial Release
-Playback Engine - Implement playback with bookmarking and queuing support
-Favorites - Implement FAVORITES functionality in video addons
-Watch History - Keep track of users' watched videos
\ No newline at end of file
+New Feature: Playback Engine - Implement playback with bookmarking and queuing 
support
+New Feature: Favorites - Implement FAVORITES functionality in video addons
+New Feature: Watch History - Keep track of users' watched videos
\ No newline at end of file
diff --git a/script.module.universal/lib/universal/_common.py 
b/script.module.universal/lib/universal/_common.py
index 870e55f..b669a77 100644
--- a/script.module.universal/lib/universal/_common.py
+++ b/script.module.universal/lib/universal/_common.py
@@ -55,12 +55,15 @@ def str2bool(myinput):
     elif myinput == 'true': return True
     
 def str_conv(data):
-    if isinstance(data, unicode):
-        data = data.encode('utf8')
-    elif isinstance(data, str):
+    if isinstance(data, str):
         # Must be encoded in UTF-8
-        data.decode('utf8')
+        data = data.decode('utf8')
+       
+    import unicodedata
+    data = unicodedata.normalize('NFKD', data).encode('ascii','ignore')
+       
     data = data.decode('string-escape')
+        
     return data
         
 def encode_dict(dict):
@@ -91,7 +94,7 @@ def decode_dict(dict):
         if v.find("<squot>") >= 0:
             v = v.replace("<squot>", "'")
         if v.find('<dquot>') >= 0:
-            v = v.replace("<dquot>", "'")
+            v = v.replace("<dquot>", '"')
         if v.find('<ltbrc>') >= 0:
             v = v.replace('<ltbrc>', '{')
         if v.find('<rtbrc>') >= 0:
@@ -116,7 +119,8 @@ def dict_to_paramstr(dict):
     
 def notify(addon_id, typeq, title, message, times, line2='', line3=''):
     addon_tmp = Addon(addon_id)
-    title=addon_tmp.get_name() + title
+    if title == '' :
+        title='[B]' + addon_tmp.get_name() + '[/B]'
     if typeq == 'small':
         if times == '':
            times='5000'
diff --git a/script.module.universal/lib/universal/favorites.py 
b/script.module.universal/lib/universal/favorites.py
index 9dedfb5..eab6dcf 100644
--- a/script.module.universal/lib/universal/favorites.py
+++ b/script.module.universal/lib/universal/favorites.py
@@ -179,7 +179,8 @@ class Favorites:
                        
         sql_insert = ''
         if self.is_already_in_favorites(section_title, section_addon_title, 
sub_section_title, sub_section_addon_title, title) == True:
-            common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - already exists in Favorites.', '8000')
+            #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - already exists in Favorites.', '8000')
+            common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', 
'[B]Already exists in Favorites.[/B]', '8000')
         else:
             if DB == 'mysql':
                 sql_insert = "INSERT INTO favorites(addon_id, hash_title, 
title, fmtd_title, url, section_title, section_addon_title, sub_section_title, 
sub_section_addon_title, infolabels, image_url, fanart_url, isfolder, 
isplayable ) VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
@@ -194,10 +195,12 @@ class Favorites:
             try:
                 self.dbcur.execute(sql_insert, (self.addon_id, hash_title, 
title, fmtd_title, url, section_title, section_addon_title, sub_section_title, 
sub_section_addon_title, str(infolabels), img, fanart, 
common.bool2str(is_folder), common.bool2str(is_playable) ))            
                 self.dbcon.commit()
-                common.notify(self.addon_id, 'small', '', 'Item: ' + 
fmtd_title + ' - added successfully to Favorites.', '8000')
+                #common.notify(self.addon_id, 'small', '', 'Item: ' + 
fmtd_title + ' - added successfully to Favorites.', '8000')
+                common.notify(self.addon_id, 'small', '[B]' + fmtd_title + 
'[/B]', '[B]Added to Favorites.[/B]', '8000')
             except:
-                common.notify(self.addon_id, 'small', '', 'Item: ' + 
fmtd_title + ' - unable to add to Favorites.', '8000')                
-                raise
+                #common.notify(self.addon_id, 'small', '', 'Item: ' + 
fmtd_title + ' - unable to add to Favorites.', '8000')                
+                common.notify(self.addon_id, 'small', '[B]' + fmtd_title + 
'[/B]', '[B]Unable to add to Favorites.[/B]', '8000')
+                pass
                 
     def delete_item_from_db(self, title, fmtd_title, section_title, 
section_addon_title, sub_section_title, sub_section_addon_title, 
item_mode='main'):
     
@@ -223,9 +226,11 @@ class Favorites:
         try:
             self.dbcur.execute(sql_delete, (self.addon_id, section_title, 
sub_section_title, hash_title) )            
             self.dbcon.commit()
-            common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - removed successfully from Favorites.', '8000')
+            #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - removed successfully from Favorites.', '8000')
+            common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', 
'[B]Removed from Favorites.[/B]', '8000')
         except:
-            common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - unable to remove from Favorites.', '8000')                
+            #common.notify(self.addon_id, 'small', '', 'Item: ' + fmtd_title + 
' - unable to remove from Favorites.', '8000')                
+            common.notify(self.addon_id, 'small', '[B]' + fmtd_title + '[/B]', 
'[B]Unable to remove from Favorites.[/B]', '8000')
             pass
         
     def build_url(self, queries):
@@ -308,12 +313,20 @@ class Favorites:
         elif item_mode == 'addon':
             item_column_section = 'section_addon_title'
             item_column_sub_section = 'sub_section_addon_title'
+            
+        if DB == 'mysql':
+            params_var = "%s"
+        else:
+            params_var = "?"
+            
+        params = []
 
-        sql_select = "SELECT DISTINCT %s FROM favorites" % 
item_column_sub_section
+        sql_select = "SELECT DISTINCT " + item_column_sub_section + " FROM 
favorites"
         
         whereadded = False
         if addon_id != 'all':
-            sql_select = sql_select + ' WHERE addon_id = \'' + addon_id + '\''
+            params.append(addon_id)
+            sql_select = sql_select + ' WHERE addon_id = ' + params_var
             whereadded = True
             
         if whereadded == False:
@@ -321,12 +334,16 @@ class Favorites:
             whereadded = True
         else:
             sql_select = sql_select + ' AND '        
-        sql_select = sql_select + " %s = '%s' AND %s != '' ORDER BY %s ASC" % 
(item_column_section, section_title, item_column_sub_section, 
item_column_sub_section)
             
-        common.addon.log('-' + HELPER + '- -' + sql_select, 2)
-
-        self.dbcur.execute(sql_select)
+        params.append(section_title)
+        sql_select = sql_select + item_column_section + " = " + params_var + " 
AND " + item_column_sub_section + " != '' ORDER BY " + item_column_sub_section 
+ " ASC" 
         
+        params = tuple(params)
+        
+        common.addon.log('-' + HELPER + '- -' + sql_select + ":" + (" %s," * 
len(params)) % params, 2)
+
+        self.dbcur.execute(sql_select, params)
+                    
         for matchedrow in self.dbcur.fetchall():
         
             match = dict(matchedrow)
@@ -344,19 +361,29 @@ class Favorites:
             item_column_section = 'section_title'
         elif item_mode == 'addon':
             item_column_section = 'section_addon_title'
+            
+        if DB == 'mysql':
+            params_var = "%s"
+        else:
+            params_var = "?"
+        
+        params = []
         
-        sql_select = "SELECT DISTINCT %s FROM favorites" % item_column_section
+        sql_select = "SELECT DISTINCT " + item_column_section + " FROM 
favorites"
         
         whereadded = False
         if addon_id != 'all':
-            sql_select = sql_select + ' WHERE addon_id = \'' + addon_id + '\''
+            params.append(addon_id)
+            sql_select = sql_select + ' WHERE addon_id = ' + params_var
             whereadded = True
         
-        sql_select = sql_select + " ORDER BY %s ASC" % item_column_section
-            
-        common.addon.log('-' + HELPER + '- -' + sql_select, 2)
+        sql_select = sql_select + " ORDER BY " + item_column_section + " ASC"
+        
+        params = tuple(params)
+        
+        common.addon.log('-' + HELPER + '- -' + sql_select + ":" + (" %s," * 
len(params)) % params, 2)
 
-        self.dbcur.execute(sql_select)
+        self.dbcur.execute(sql_select, params)
         
         for matchedrow in self.dbcur.fetchall():
         
@@ -380,35 +407,49 @@ class Favorites:
         elif item_mode == 'addon':
             item_column_section = 'section_addon_title'
             item_column_sub_section = 'sub_section_addon_title'
+            
+        if DB == 'mysql':
+            params_var = "%s"
+        else:
+            params_var = "?"
         
         try:
             import json
         except:
             import simplejson as json
+            
+        params = []
 
         sql_select = "SELECT * FROM favorites"
+                
         
         whereadded = False
         if addon_id != 'all':
-            sql_select = sql_select + ' WHERE addon_id = \'' + addon_id + '\''
+            params.append(addon_id)
+            sql_select = sql_select + ' WHERE addon_id = ' + params_var
             whereadded = True
         
         if section_title != 'all':
+            params.append(section_title)
             if whereadded == False:
                 sql_select = sql_select + ' WHERE '
                 whereadded = True
             else:
                 sql_select = sql_select + ' AND '        
-            sql_select = sql_select + " %s = '%s' " % (item_column_section, 
section_title)
+            sql_select = sql_select + item_column_section + " = " + params_var 
            
             
             if sub_section_title != 'all':
-                sql_select = sql_select + " AND %s = '%s' " % 
(item_column_sub_section, sub_section_title)
+                params.append(sub_section_title)
+                sql_select = sql_select + " AND " + item_column_sub_section + 
" = " + params_var 
+        
         
         sql_select = sql_select + " ORDER BY title ASC"
+        
+        params = tuple(params)
             
-        common.addon.log('-' + HELPER + '- -' + sql_select, 2)
+        common.addon.log('-' + HELPER + '- -' + sql_select + ":" + (" %s," * 
len(params)) % params, 2)
 
-        self.dbcur.execute(sql_select)
+        self.dbcur.execute(sql_select, params)
         
         for matchedrow in self.dbcur.fetchall():
         

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

Summary of changes:
 script.module.universal/addon.xml                  |    2 +-
 script.module.universal/changelog.txt              |   12 ++-
 script.module.universal/lib/universal/_common.py   |   16 ++--
 script.module.universal/lib/universal/favorites.py |   87 ++++++++++++++-----
 4 files changed, 84 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to