The branch, dharma has been updated
       via  6395bc10b27f98a3e1bd5040ffb0db9de71bbc23 (commit)
      from  16b9b7a2fab6240d4227ad7b9c0f47afb200a5de (commit)

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

commit 6395bc10b27f98a3e1bd5040ffb0db9de71bbc23
Author: amet <a...@nospam>
Date:   Thu Dec 30 15:45:13 2010 +0400

    [script.trakt] -v 0.1.0
    - added Spanish translation thanks to MaDDoGo!
    - removed check for year since the year is missing if you start a tv 
show/movie in certain manners (ex: android xbmc remote)
    - added urlencoding for httpapi query and removed redundant check for 
tmdb/imdb id

diff --git a/script.trakt/addon.xml b/script.trakt/addon.xml
index f28dafc..83184c1 100644
--- a/script.trakt/addon.xml
+++ b/script.trakt/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="script.trakt"
        name="trakt"
-       version="0.0.9"
+       version="0.1.0"
        provider-name="rudf0rd">
   <requires>
     <import addon="xbmc.python" version="1.0"/>
diff --git a/script.trakt/changelog.txt b/script.trakt/changelog.txt
index b01b4cc..80e8245 100644
--- a/script.trakt/changelog.txt
+++ b/script.trakt/changelog.txt
@@ -1,3 +1,8 @@
+Version 0.1.0
+       - added Spanish translation thanks to MaDDoGo!
+       - removed check for year since the year is missing if you start a tv 
show/movie in certain manners (ex: android xbmc remote)
+       - added urlencoding for httpapi query and removed redundant check for 
tmdb/imdb id
+
 Version 0.0.9
        - adjusted time intervals to be more aggressive if video is not playing
        - corrected bug in title checking
diff --git a/script.trakt/default.py b/script.trakt/default.py
index 222a5b9..e64c657 100644
--- a/script.trakt/default.py
+++ b/script.trakt/default.py
@@ -12,7 +12,7 @@ import re
 __scriptname__ = "trakt"
 __author__ = "Sean Rudford"
 __url__ = "http://trakt.tv/";
-__version__ = "0.0.9"
+__version__ = "0.1.0"
 __XBMC_Revision__ = ""
 
 def addPadding(number):
@@ -30,7 +30,6 @@ def CheckAndSubmit(Manual=False):
         bExcluded = False
         short = ""
         title = ""
-        global getID
         global VideoThreshold
         global lasttitle
         global lastUpdate
@@ -57,9 +56,6 @@ def CheckAndSubmit(Manual=False):
             Debug('Video ended during pause check', False)
             return
         
-        if (xbmc.getInfoLabel("VideoPlayer.Year") == ""):
-            Debug('Video is not in library', False)
-            bLibraryExcluded = True
         if ((xbmc.getInfoLabel("VideoPlayer.mpaa") == "XXX")):
             Debug('Video is with XXX mpaa rating', False)
             bRatingExcluded = True
@@ -100,10 +96,6 @@ def CheckAndSubmit(Manual=False):
             moviename = moviename.replace(",", '')
             
             title = (moviename + ',' + xbmc.getInfoLabel("VideoPlayer.Year"))
-                
-            #don't submit if not in library
-            if (xbmc.getInfoLabel("VideoPlayer.Year") == ""):
-                title = ""
 
         if (bLibraryExcluded or bPathExcluded or bRatingExcluded):
             bExcluded = True
@@ -111,18 +103,17 @@ def CheckAndSubmit(Manual=False):
         
         Debug("Title: " + title)
         
-        if ((title != "" and lasttitle != title) and not bExcluded):           
     
-            get_id(sType)
+        if ((title != "" and lasttitle != title) and not bExcluded):
             
             if (iPercComp > (float(VideoThreshold) / 100)):
                 Debug('Title: ' + title + ', sending watched status, current 
percentage: ' + str(iPercComp), True)
-                SendUpdate(title+","+video_id, int(iPercComp*100), sType, 
"watched")
+                SendUpdate(title, int(iPercComp*100), sType, "watched")
                 lasttitle = title
                 checkTitle = xbmc.getInfoLabel("VideoPlayer.Title")
                 sleepTime = 15
             elif (time.time() - lastUpdate >= 900):
                 Debug('Title: ' + title + ', sending watching status, current 
percentage: ' + str(iPercComp), True)
-                SendUpdate(title+","+video_id, int(iPercComp*100), sType, 
"watching")
+                SendUpdate(title, int(iPercComp*100), sType, "watching")
                 lastUpdate = time.time();
                 checkTitle = xbmc.getInfoLabel("VideoPlayer.Title")
                 sleepTime = 168
@@ -131,36 +122,6 @@ def CheckAndSubmit(Manual=False):
         Debug('Resetting last update timestamp')
         lastUpdate = 0
         sleepTime = 15
-        getID = True
-
-
-def get_id(video_type):
-    global getID
-    global video_id
-    
-    getID = False
-    Debug("Looking up video ID (tvdb or imdb)", False)
-    
-    if video_type == "Movie":
-        try:
-            query = "select case when not movie.c09 is null then movie.c09 
else 'NOTFOUND' end as [MovieID] from movie where movie.c00 = '" + 
xbmc.getInfoLabel("VideoPlayer.Title") + "' limit 1"
-            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")
-            movieid = re.findall('>(.*?)<',res) # find it
-            if len(movieid[1].strip()) >= 1:
-                video_id = str(movieid[1].strip())
-        except:
-            video_id = ""
-            
-    elif video_type == "TVShow":
-        try:
-            query = "select c12 from tvshow where c00 = '" + 
xbmc.getInfoLabel("VideoPlayer.TvShowTitle") + "'"
-            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")
-            tvid = re.findall('[\d.]*\d+',res) # find it
-
-            if len(tvid[0].strip()) >= 1:
-                video_id = tvid[0].strip();
-        except:
-            video_id = ""
 
 
 ###Settings related parsing
@@ -189,7 +150,6 @@ bPassword = False
 lasttitle = ""
 lastUpdate = 0
 video_id = ""
-getID = True
 sleepTime = 168
 checkTitle = ''
 
@@ -244,7 +204,10 @@ if ((bStartup and bAutoStart) or bRun):
         #If Set To AutoSubmit
         if (bAutoSubmitVideo):
             CheckAndSubmit()
-
+        
+        if (xbmc.abortRequested):
+            break
+            
         time.sleep(sleepTime)
 
 Debug( 'Exiting...', False)
diff --git a/script.trakt/resources/language/Dutch/strings.xml 
b/script.trakt/resources/language/Dutch/strings.xml
index 4175d2a..9616597 100644
--- a/script.trakt/resources/language/Dutch/strings.xml
+++ b/script.trakt/resources/language/Dutch/strings.xml
@@ -19,7 +19,7 @@
        
        <string id="45050">Klaar om je media toe te voegen</string>
        <string id="45051">U moet een gebruikersnaam en wachtwoord in te 
voeren!</string>
-       <string id="45052">Toegevoegd %MOVIENAME% (%YEAR%)</string>
-       <string id="45053">Toegevoegd %TVSHOW% %SEASON%x%EPISODE%</string>
+       <string id="45052">Toegevoegd: %MOVIENAME% (%YEAR%)</string>
+       <string id="45053">Toegevoegd: %TVSHOW% %SEASON%x%EPISODE%</string>
 </strings>
 
diff --git a/script.trakt/resources/lib/utilities.py 
b/script.trakt/resources/lib/utilities.py
index 1bba96e..b14f854 100644
--- a/script.trakt/resources/lib/utilities.py
+++ b/script.trakt/resources/lib/utilities.py
@@ -1,241 +1,260 @@
-import sys

-import os

-import xbmc

-import xbmcaddon

-import re

-import string

-import urllib

-import urllib2

-from urllib2 import URLError

-

-# disgracefully stolen from xbmc subtitles

-try:

-  # Python 2.6 +

-  from hashlib import sha as sha

-except ImportError:

-  # Python 2.5 and earlier

-  import sha

-

-__settings__ = xbmcaddon.Addon(id='script.trakt')

-__language__ = __settings__.getLocalizedString

-__version__ = "0.0.9"

-__cwd__ = __settings__.getAddonInfo('path')

-

-#Path handling

-LANGUAGE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __cwd__, 
'resources', 'language' ) )

-CONFIG_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources', 
'settings.cfg' ) )

-AUTOEXEC_PATH = xbmc.translatePath( 'special://home/userdata/autoexec.py' )

-AUTOEXEC_FOLDER_PATH = xbmc.translatePath( 'special://home/userdata/' )

-VERSION_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources', 
'version.cfg' ) )

-

-#Consts

-AUTOEXEC_SCRIPT = '\nimport 
time;time.sleep(5);xbmc.executebuiltin("XBMC.RunScript(special://home/addons/script.trakt/default.py,-startup)")\n'

-

-def SendUpdate(info, progress, sType, status):

-    Debug("Creating data to send", False)

-    

-    bUsername = __settings__.getSetting( "Username" )

-    bPassword = sha.new(__settings__.getSetting( "Password" )).hexdigest()

-    bNotify = __settings__.getSetting( "NotifyOnSubmit" )

-    

-    

-    if (bUsername == '' or bPassword == ''):

-        Debug("Username or password not set", False)

-        notification("Trakt", __language__(45051).encode( "utf-8", "ignore" ), 
5000, __settings__.getAddonInfo("icon"))

-        return False

-    

-    Debug(info, False)

-    

-    if (sType == "TVShow"):

-        ID = getID(sType, 
unicode(xbmc.getInfoLabel("VideoPlayer.TvShowTitle"), 'utf-8'))

-    elif (sType == "Movie"):

-        ID = getID(sType, unicode(xbmc.getInfoLabel("VideoPlayer.Title")))

-    

-    # split on type and create data packet for each type

-    if (sType == "Movie"):

-        Debug("Parsing Movie", False)

-        

-        # format: title, year

-        title, year, ID = info.split(",")

-        

-        # set alert text

-        submitAlert = __language__(45052).encode( "utf-8", "ignore" )

-        submitAlert = submitAlert.replace('%MOVIENAME%', title)

-        submitAlert = submitAlert.replace('%YEAR%', year)

-        

-        toSend = urllib.urlencode({ "type": sType,

-                                    "status": status,

-                                    "title": title, 

-                                    "year": year,

-                                    "imdbid": ID,

-                                    "progress": progress,

-                                    "plugin_version": __version__,

-                                    "media_center": 'xbmc',

-                                    "media_center_version": xbmc.getInfoLabel( 
"system.buildversion" ),

-                                    "media_center_date": xbmc.getInfoLabel( 
"system.builddate" ),

-                                    "username": bUsername, 

-                                    "password": bPassword})

-    elif (sType == "TVShow"):

-        Debug("Parsing TVShow", False)

-        

-        # format: title, year, season, episode

-        title, year, season, episode, ID = info.split(",")

-        

-        # set alert text

-        submitAlert = __language__(45053).encode( "utf-8", "ignore" )

-        submitAlert = submitAlert.replace('%TVSHOW%', title)

-        submitAlert = submitAlert.replace('%SEASON%', season)

-        submitAlert = submitAlert.replace('%EPISODE%', episode)

-        

-        toSend = urllib.urlencode({ "type": sType,

-                                    "status": status,

-                                    "title": title, 

-                                    "year": year, 

-                                    "season": season, 

-                                    "episode": episode,

-                                    "tvdbid": ID,

-                                    "progress": progress,

-                                    "plugin_version": __version__,

-                                    "media_center": 'xbmc',

-                                    "media_center_version": xbmc.getInfoLabel( 
"system.buildversion" ),

-                                    "media_center_date": xbmc.getInfoLabel( 
"system.builddate" ),

-                                    "username": bUsername, 

-                                    "password": bPassword})

-        

-    Debug("Data: "+toSend, False)

-    

-    # send

-    transmit(toSend)

-    # and notify if wanted

-    if (bNotify == "true" and status == "watched"):

-        notification("Trakt", submitAlert, 3000, 
__settings__.getAddonInfo("icon"))

-    

-def transmit(status):

-    bNotify = __settings__.getSetting( "NotifyOnSubmit" )

-

-    req = urllib2.Request("http://api.trakt.tv/post";,

-            status,

-            headers = { "Accept": "*/*",   

-                        "User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; 
Windows NT)", 

-                      })

-

-    try:

-        f = urllib2.urlopen(req)

-        response = f.read()

-        Debug("Return packet: "+response)

-        

-    except URLError, e:

-        if e.code == 401:

-            Debug("Bad username or password", False)

-            if (bNotify == "true"):

-                notification("Trakt: Bad Authentication!", "Check your login 
information", 5000, __settings__.getAddonInfo("icon"))

-                

-    except:

-        # do nothing 'cept spit out error (catch all)

-        if (bNotify == "true"):

-            notification("Trakt", "Error sending status.  API may not be 
reachable", 10000, __settings__.getAddonInfo("icon"))

-

-

-def Debug(message, Verbose=True):

-    message = "TRAKT: " + message

-    bVerbose = __settings__.getSetting( "debug" )

-    if (bVerbose == 'true'):

-        bVerbose = True

-    else:

-        bVerbose = False

-    

-    if (bVerbose and Verbose):

-        # repr() is used, got wierd issues with unicode otherwise, since we 
send mixed string types (eg: unicode and ascii) 

-        print repr(message)

-    elif (not Verbose):

-        # repr() is used, got wierd issues with unicode otherwise, since we 
send mixed string types (eg: unicode and ascii) 

-        print repr(message)

-

-def CalcPercentageRemaining(currenttime, duration):

-    try:

-         iCurrentMinutes = (int(currenttime.split(':')[0]) * 60) + 
int(currenttime.split(':')[1])

-    except:

-        iCurrentMinutes = int(0)

-        

-    try:

-        iDurationMinutes = (int(duration.split(':')[0]) * 60) + 
int(duration.split(':')[1])

-    except:

-        iDurationMinutes = int(0)

-

-    try:

-        Debug( 'Percentage of progress: ' + str(float(iCurrentMinutes) / 
float(iDurationMinutes)), True)

-        return float(iCurrentMinutes) / float(iDurationMinutes) 

-    except:

-        Debug( 'Percentage of progress: null', True)

-        return float(0.0)

-

-def SetAutoStart(bState = True):

-    Debug( '::AutoStart::' + str(bState), True)

-    if (os.path.exists(AUTOEXEC_PATH)):

-        Debug( 'Found Autoexec.py file, checking we''re there', True)

-        bFound = False

-        autoexecfile = file(AUTOEXEC_PATH, 'r')

-        filecontents = autoexecfile.readlines()

-        autoexecfile.close()

-        for line in filecontents:

-            if line.find('trakt') > 0:

-                Debug( 'Found our script, no need to do anything', True)

-                bFound = True

-        if (not bFound):

-            Debug( 'Appending our script to the autoexec.py script', True)

-            autoexecfile = file(AUTOEXEC_PATH, 'w')

-            filecontents.append(AUTOEXEC_SCRIPT)

-            autoexecfile.writelines(filecontents)            

-            autoexecfile.close()

-        if (bFound and not bState):

-            #remove line

-            Debug( 'Removing our script from the autoexec.py script', True)

-            autoexecfile = file(AUTOEXEC_PATH, 'w')

-            for line in filecontents:

-                if not line.find('trakt') > 0:

-                    autoexecfile.write(line)

-            autoexecfile.close()            

-    else:

-        if (os.path.exists(AUTOEXEC_FOLDER_PATH)):

-            Debug( 'File Autoexec.py is missing, creating file with autostart 
script', True)

-            autoexecfile = file(AUTOEXEC_PATH, 'w')

-            autoexecfile.write (AUTOEXEC_SCRIPT.strip())

-            autoexecfile.close()

-        else:

-            Debug( 'Scripts folder is missing, creating folder and autoexec.py 
file with autostart script', True)

-            os.makedirs(AUTOEXEC_FOLDER_PATH)

-            autoexecfile = file(AUTOEXEC_PATH, 'w')

-            autoexecfile.write (AUTOEXEC_SCRIPT.strip())

-            autoexecfile.close()

-    Debug( '::AutoStart::'  , True)

-

-def notification( header="", message="", sleep=5000, 
icon=__settings__.getAddonInfo( "icon" ) ):

-    """ Will display a notification dialog with the specified header and 
message,

-        in addition you can set the length of time it displays in milliseconds 
and a icon image. 

-    """

-    xbmc.executebuiltin( "XBMC.Notification(%s,%s,%i,%s)" % ( header, message, 
sleep, icon ) )

-    

-def getID(sType, title):

-    video_id = ""

-    if (sType == "TVShow"):

-        # get tvdb id

-        try:

-            query = "select c12 from tvshow where c00 = '" + title + "'"

-            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")

-            tvid = re.findall('[\d.]*\d+',res) # find it

-

-            if len(tvid[0].strip()) >= 1:

-                video_id = tvid[0].strip();

-        except:        

-            video_id = ""

-    else:

-        try:

-            query = "select case when not movie.c09 is null then movie.c09 
else 'NOTFOUND' end as [MovieID] from movie where movie.c00 = '" + title + "' 
limit 1"

-            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")

-            movieid = re.findall('>(.*?)<',res) # find it

-            if len(movieid[1].strip()) >= 1:

-                video_id = str(movieid[1].strip())

-        except:

-            video_id = ""

-    

+import sys
+import os
+import xbmc
+import xbmcaddon
+import re
+import string
+import urllib
+import urllib2
+from urllib2 import URLError
+
+# disgracefully stolen from xbmc subtitles
+try:
+  # Python 2.6 +
+  from hashlib import sha as sha
+except ImportError:
+  # Python 2.5 and earlier
+  import sha
+
+__settings__ = xbmcaddon.Addon(id='script.trakt')
+__language__ = __settings__.getLocalizedString
+__version__ = "0.1.0"
+__cwd__ = __settings__.getAddonInfo('path')
+
+#Path handling
+LANGUAGE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __cwd__, 
'resources', 'language' ) )
+CONFIG_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources', 
'settings.cfg' ) )
+AUTOEXEC_PATH = xbmc.translatePath( 'special://home/userdata/autoexec.py' )
+AUTOEXEC_FOLDER_PATH = xbmc.translatePath( 'special://home/userdata/' )
+VERSION_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources', 
'version.cfg' ) )
+
+#Consts
+AUTOEXEC_SCRIPT = '\nimport 
time;time.sleep(5);xbmc.executebuiltin("XBMC.RunScript(special://home/addons/script.trakt/default.py,-startup)")\n'
+
+def SendUpdate(info, progress, sType, status):
+    Debug("Creating data to send", False)
+    
+    bUsername = __settings__.getSetting( "Username" )
+    bPassword = sha.new(__settings__.getSetting( "Password" )).hexdigest()
+    bNotify = __settings__.getSetting( "NotifyOnSubmit" )
+    
+    
+    if (bUsername == '' or bPassword == ''):
+        Debug("Username or password not set", False)
+        notification("Trakt", __language__(45051).encode( "utf-8", "ignore" ), 
5000, __settings__.getAddonInfo("icon"))
+        return False
+    
+    Debug(info, False)
+    
+    if (sType == "TVShow"):
+        ID = getID(sType, 
unicode(xbmc.getInfoLabel("VideoPlayer.TvShowTitle"), 'utf-8'))
+    elif (sType == "Movie"):
+        ID = getID(sType, 
urllib.quote(xbmc.getInfoLabel("VideoPlayer.Title"))) 
+    
+    Debug("IMDB/tvdb id: "+ID);
+    
+    # split on type and create data packet for each type
+    if (sType == "Movie"):
+        Debug("Parsing Movie", False)
+        
+        # format: title, year
+        title, year = info.split(",")
+        
+        # check to make sure the data is there
+        # otherwise return
+        if(title == ''):
+            return
+        
+        # set alert text
+        submitAlert = __language__(45052).encode( "utf-8", "ignore" )
+        submitAlert = submitAlert.replace('%MOVIENAME%', title)
+        submitAlert = submitAlert.replace('%YEAR%', year)
+        
+        toSend = urllib.urlencode({ "type": sType,
+                                    "status": status,
+                                    "title": title, 
+                                    "year": year,
+                                    "imdbid": ID,
+                                    "progress": progress,
+                                    "plugin_version": __version__,
+                                    "media_center": 'xbmc',
+                                    "media_center_version": xbmc.getInfoLabel( 
"system.buildversion" ),
+                                    "media_center_date": xbmc.getInfoLabel( 
"system.builddate" ),
+                                    "duration": 
xbmc.getInfoLabel("VideoPlayer.Duration"),
+                                    "username": bUsername, 
+                                    "password": bPassword})
+    elif (sType == "TVShow"):
+        Debug("Parsing TVShow", False)
+        
+        # format: title, year, season, episode
+        title, year, season, episode = info.split(",")
+        
+        # check to make sure the data is there
+        # otherwise return
+        if(title == '' or season == '' or episode == ''):
+            return
+        
+        # set alert text
+        submitAlert = __language__(45053).encode( "utf-8", "ignore" )
+        submitAlert = submitAlert.replace('%TVSHOW%', title)
+        submitAlert = submitAlert.replace('%SEASON%', season)
+        submitAlert = submitAlert.replace('%EPISODE%', episode)
+        
+        toSend = urllib.urlencode({ "type": sType,
+                                    "status": status,
+                                    "title": title, 
+                                    "year": year, 
+                                    "season": season, 
+                                    "episode": episode,
+                                    "tvdbid": ID,
+                                    "progress": progress,
+                                    "plugin_version": __version__,
+                                    "media_center": 'xbmc',
+                                    "media_center_version": xbmc.getInfoLabel( 
"system.buildversion" ),
+                                    "media_center_date": xbmc.getInfoLabel( 
"system.builddate" ),
+                                    "duration": 
xbmc.getInfoLabel("VideoPlayer.Duration"),
+                                    "username": bUsername, 
+                                    "password": bPassword})
+        
+    Debug("Data: "+toSend, False)
+    
+    # send
+    transmit(toSend)
+    # and notify if wanted
+    if (bNotify == "true" and status == "watched"):
+        notification("Trakt", submitAlert, 3000, 
__settings__.getAddonInfo("icon"))
+    
+def transmit(status):
+    bNotify = __settings__.getSetting( "NotifyOnSubmit" )
+
+    req = urllib2.Request("http://api.trakt.tv/post";,
+            status,
+            headers = { "Accept": "*/*",   
+                        "User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; 
Windows NT)", 
+                      })
+
+    try:
+        f = urllib2.urlopen(req)
+        response = f.read()
+        Debug("Return packet: "+response)
+        
+    except URLError, e:
+        if e.code == 401:
+            Debug("Bad username or password", False)
+            if (bNotify == "true"):
+                notification("Trakt: Bad Authentication!", "Check your login 
information", 5000, __settings__.getAddonInfo("icon"))
+                
+    except:
+        # do nothing 'cept spit out error (catch all)
+        if (bNotify == "true"):
+            notification("Trakt", "Error sending status.  API may not be 
reachable", 10000, __settings__.getAddonInfo("icon"))
+
+
+def Debug(message, Verbose=True):
+    message = "TRAKT: " + message
+    bVerbose = __settings__.getSetting( "debug" )
+    if (bVerbose == 'true'):
+        bVerbose = True
+    else:
+        bVerbose = False
+    
+    if (bVerbose and Verbose):
+        # repr() is used, got wierd issues with unicode otherwise, since we 
send mixed string types (eg: unicode and ascii) 
+        print repr(message)
+    elif (not Verbose):
+        # repr() is used, got wierd issues with unicode otherwise, since we 
send mixed string types (eg: unicode and ascii) 
+        print repr(message)
+
+def CalcPercentageRemaining(currenttime, duration):
+    try:
+        iCurrentMinutes = (int(currenttime.split(':')[0]) * 60) + 
int(currenttime.split(':')[1])
+    except:
+        iCurrentMinutes = int(0)
+        
+    try:
+        iDurationMinutes = (int(duration.split(':')[0]) * 60) + 
int(duration.split(':')[1])
+    except:
+        iDurationMinutes = int(0)
+
+    try:
+        Debug( 'Percentage of progress: ' + str(float(iCurrentMinutes) / 
float(iDurationMinutes)), True)
+        return float(iCurrentMinutes) / float(iDurationMinutes) 
+    except:
+        Debug( 'Percentage of progress: null', True)
+        return float(0.0)
+
+def SetAutoStart(bState = True):
+    Debug( '::AutoStart::' + str(bState), True)
+    if (os.path.exists(AUTOEXEC_PATH)):
+        Debug( 'Found Autoexec.py file, checking we''re there', True)
+        bFound = False
+        autoexecfile = file(AUTOEXEC_PATH, 'r')
+        filecontents = autoexecfile.readlines()
+        autoexecfile.close()
+        for line in filecontents:
+            if line.find('trakt') > 0:
+                Debug( 'Found our script, no need to do anything', True)
+                bFound = True
+        if (not bFound):
+            Debug( 'Appending our script to the autoexec.py script', True)
+            autoexecfile = file(AUTOEXEC_PATH, 'w')
+            filecontents.append(AUTOEXEC_SCRIPT)
+            autoexecfile.writelines(filecontents)            
+            autoexecfile.close()
+        if (bFound and not bState):
+            #remove line
+            Debug( 'Removing our script from the autoexec.py script', True)
+            autoexecfile = file(AUTOEXEC_PATH, 'w')
+            for line in filecontents:
+                if not line.find('trakt') > 0:
+                    autoexecfile.write(line)
+            autoexecfile.close()            
+    else:
+        if (os.path.exists(AUTOEXEC_FOLDER_PATH)):
+            Debug( 'File Autoexec.py is missing, creating file with autostart 
script', True)
+            autoexecfile = file(AUTOEXEC_PATH, 'w')
+            autoexecfile.write (AUTOEXEC_SCRIPT.strip())
+            autoexecfile.close()
+        else:
+            Debug( 'Scripts folder is missing, creating folder and autoexec.py 
file with autostart script', True)
+            os.makedirs(AUTOEXEC_FOLDER_PATH)
+            autoexecfile = file(AUTOEXEC_PATH, 'w')
+            autoexecfile.write (AUTOEXEC_SCRIPT.strip())
+            autoexecfile.close()
+    Debug( '::AutoStart::'  , True)
+
+def notification( header="", message="", sleep=5000, 
icon=__settings__.getAddonInfo( "icon" ) ):
+    """ Will display a notification dialog with the specified header and 
message,
+        in addition you can set the length of time it displays in milliseconds 
and a icon image. 
+    """
+    xbmc.executebuiltin( "XBMC.Notification(%s,%s,%i,%s)" % ( header, message, 
sleep, icon ) )
+    
+def getID(sType, title):
+    Debug("Title sent to getID: "+title, False)
+    video_id = ""
+    if (sType == "TVShow"):
+        # get tvdb id
+        try:
+            query = "select c12 from tvshow where lower(c00) = lower('" + 
title + "') limit 1"
+            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")
+            tvid = re.findall('[\d.]*\d+',res) # find it
+
+            if len(tvid[0].strip()) >= 1:
+                video_id = tvid[0].strip();
+        except:        
+            video_id = ""
+    else:
+        try:
+            query = "select movie.c09 from movie where lower(movie.c00) = 
lower('" + title + "') limit 1"
+            Debug(query)
+            res = xbmc.executehttpapi("queryvideodatabase(" + query + ")")
+            Debug(res)
+            movieid = re.findall('<field>(.*?)</field>',res) # find it
+
+            if len(str(movieid[0])) >= 1:
+                Debug("Final answer (for id!) --> "+str(movieid[0]))
+                video_id = str(movieid[0])
+        except:
+            video_id = ""
+    
     return video_id
\ No newline at end of file
diff --git a/script.trakt/resources/settings.xml 
b/script.trakt/resources/settings.xml
index a0e2b40..f20bc8c 100644
--- a/script.trakt/resources/settings.xml
+++ b/script.trakt/resources/settings.xml
@@ -8,7 +8,7 @@
        <setting type="lsep" label="45013" />
        <setting id="AutoSubmitVideo" type="bool" label="45014" default="true" 
/>
        <setting id="NotifyOnSubmit" type="bool" label="45007" default="true" />
-       <setting id="VideoThreshold" type="enum"  visible= "eq(-2,true)" 
enable="eq(-2,true)" label="45015" values="75%|95%" default="1" />
+       <setting id="VideoThreshold" type="enum"  visible= "eq(-2,true)" 
enable="eq(-2,true)" label="45015" values="70%|85%" default="1" />
 
   <setting type="lsep" label="45002" />
        <setting id="ExcludePathOption" type="bool" label="45009" 
default="false" />

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

Summary of changes:
 script.trakt/addon.xml                             |    2 +-
 script.trakt/changelog.txt                         |    5 +
 script.trakt/default.py                            |   53 +--
 script.trakt/resources/language/Dutch/strings.xml  |    4 +-
 .../resources/language/Spanish/strings.xml         |   24 +
 script.trakt/resources/lib/utilities.py            |  499 ++++++++++----------
 script.trakt/resources/settings.xml                |    2 +-
 7 files changed, 300 insertions(+), 289 deletions(-)
 create mode 100644 script.trakt/resources/language/Spanish/strings.xml


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to