The branch, eden has been updated
       via  f0bc61d108f931887ab132d2274202aef0964c69 (commit)
      from  88e7de25dde4d170f5b014231658227730dbfd5e (commit)

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

commit f0bc61d108f931887ab132d2274202aef0964c69
Author: MartijnKaijser <[email protected]>
Date:   Thu Mar 22 00:37:52 2012 +0100

    [script.artwork.downloader] -v1.0.9

diff --git a/script.artwork.downloader/addon.xml 
b/script.artwork.downloader/addon.xml
index 764f688..2179e41 100644
--- a/script.artwork.downloader/addon.xml
+++ b/script.artwork.downloader/addon.xml
@@ -2,7 +2,7 @@
 <addon
        id="script.artwork.downloader"
        name="Artwork Downloader"
-       version="1.0.8"
+       version="1.0.9"
        provider-name="paddycarey, putneyj, Martijn"
     >
   <requires>
diff --git a/script.artwork.downloader/changelog.txt 
b/script.artwork.downloader/changelog.txt
index aa6488a..59e5637 100644
--- a/script.artwork.downloader/changelog.txt
+++ b/script.artwork.downloader/changelog.txt
@@ -1,3 +1,8 @@
+[B]1.0.9[/B]
+- Changed: increase the API cache expire time to stop trashing the fanart.tv 
site
+- Added: Only show artwork types in GUI mode that are avaiable
+- Fixed: Unicode error in custom/gui mode search
+
 [B]1.0.8[/B]
 - Added: Increased speed by using commingcache for library JSON when using 
custom/gui mode (expires after 1 hour)
 - Added: Greek translation (thx CutSickAss)
diff --git a/script.artwork.downloader/default.py 
b/script.artwork.downloader/default.py
index e312e8a..f68945a 100644
--- a/script.artwork.downloader/default.py
+++ b/script.artwork.downloader/default.py
@@ -254,7 +254,7 @@ class Main:
         time.sleep(2)
         dialog_msg('close', background = self.settings.background)
         # Print the self.reportdata log message
-        log('Failed items report: %s' % self.reportdata.replace('[B]', 
'').replace('[/B]', '') )
+        #log('Failed items report: %s' % self.reportdata.replace('[B]', 
'').replace('[/B]', '') )
         # Safe the downloadreport to settings folder using save function
         save_nfo_file(self.reportdata, os.path.join( __addonprofile__ , 
'downloadreport.txt' ) )
         # Some dialog checks
@@ -308,7 +308,7 @@ class Main:
         mediafound = False
         for currentitem in self.Medialist:
             # Check on exact match
-            if itemname in currentitem["name"]:
+            if normalize_string(itemname) == 
normalize_string(currentitem["name"]):
                 # Check on exact path match when provided and normalize the 
path because of unicode issues
                 if normalize_string(itempath) == 
normalize_string(currentitem['path']) or itempath == '':
                     self.Medialist = []
@@ -682,6 +682,17 @@ class Main:
             log('Finished download')
         log('########################################################')
 
+    ### Checks imagelist if it has that type of artwork has got images
+    def _hasimages(self, art_type):
+        found = False
+        for artwork in self.image_list:
+            if  art_type in artwork['type']:
+                found = True
+                break
+            else: pass
+        return found
+
+    ### This handles the GUI image type selector part
     def _gui_mode(self):
         # Close the 'checking for artwork' dialog before opening the GUI list
         dialog_msg('close', background = self.settings.background)
@@ -690,7 +701,7 @@ class Main:
         imagelist = False
         # Fill GUI art type list
         for item in self.settings.available_arttypes:
-            if item['solo_enabled'] == 'true' and self.mediatype == 
item['media_type']:
+            if item['solo_enabled'] == 'true' and self.mediatype == 
item['media_type'] and self._hasimages(item['art_type']):
                 gui = item['gui_string']
                 self.GUI_type_list.append (gui)
         # Not sure what this does again
diff --git a/script.artwork.downloader/resources/lib/provider/fanarttv.py 
b/script.artwork.downloader/resources/lib/provider/fanarttv.py
index 4e93141..676cbf6 100644
--- a/script.artwork.downloader/resources/lib/provider/fanarttv.py
+++ b/script.artwork.downloader/resources/lib/provider/fanarttv.py
@@ -16,107 +16,113 @@ class FTV_TVProvider():
 
     def __init__(self):
         self.name = 'fanart.tv - TV API'
-        self.api_key = '586118be1ac673f74963cc284d46bd8e'
+        self.api_key = '586118be1ac673f74963cc284d46bd8e' # 
ArtworkDownloader-tvshow
         self.url = "http://fanart.tv/webservice/series/%s/%s/json/all/1/2";
         self.imagetypes = ['clearlogo', 'clearart', 'tvthumb', 'seasonthumb', 
'characterart']
 
     def get_image_list(self, media_id):
         data = get_json(self.url % (self.api_key,media_id))
         image_list = []
-        # Get fanart
-        try:
-            # split "name" and "data"
-            for title, value in data.iteritems():
-                # run through specified types
-                for art in self.imagetypes:
-                    # if type has been found
-                    if value.has_key(art):
-                        # Run through all the items
-                        for item in value[art]:
-                            info = {}
-                            info['url']         = urllib.quote(item['url'], 
':/')   # Original image url
-                            info['preview']     = info['url'] + "/preview"     
     # Create a preview url for later use
-                            info['id']          = item['id']
-                            info['type']        = art
-                            if item.has_key('season'):
-                                info['season']  = item['season']
-                            else:
-                                info['season']  = 'n/a'
-                            # language and votes
-                            info['language']    = item['lang']
-                            info['votes']       = item['likes']
-                            
-                            # Create Gui string to display
-                            info['generalinfo'] = '%s: %s  |  ' %( 
__localize__(32141), info['language'])
-                            if info['season'] != 'n/a':
-                                info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32144), info['season'] )
-                            info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32143), info['votes'] )
-                            # Add data to list
-                            if info:
-                                image_list.append(info)
-        except: pass
-        if image_list == []:
-            raise NoFanartError(media_id)
-        else:
-            # Sort the list before return. Last sort method is primary
-            image_list = sorted(image_list, key=itemgetter('votes'), 
reverse=True)
-            image_list = sorted(image_list, key=itemgetter('language'))
+        if data == "Empty":
             return image_list
+        else:
+            # Get fanart
+            try:
+                # split "name" and "data"
+                for title, value in data.iteritems():
+                    # run through specified types
+                    for art in self.imagetypes:
+                        # if type has been found
+                        if value.has_key(art):
+                            # Run through all the items
+                            for item in value[art]:
+                                info = {}
+                                info['url']         = 
urllib.quote(item['url'], ':/')   # Original image url
+                                info['preview']     = info['url'] + "/preview" 
         # Create a preview url for later use
+                                info['id']          = item['id']
+                                info['type']        = art
+                                if item.has_key('season'):
+                                    info['season']  = item['season']
+                                else:
+                                    info['season']  = 'n/a'
+                                # language and votes
+                                info['language']    = item['lang']
+                                info['votes']       = item['likes']
+                                
+                                # Create Gui string to display
+                                info['generalinfo'] = '%s: %s  |  ' %( 
__localize__(32141), info['language'])
+                                if info['season'] != 'n/a':
+                                    info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32144), info['season'] )
+                                info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32143), info['votes'] )
+                                # Add data to list
+                                if info:
+                                    image_list.append(info)
+            except: pass
+            if image_list == []:
+                raise NoFanartError(media_id)
+            else:
+                # Sort the list before return. Last sort method is primary
+                image_list = sorted(image_list, key=itemgetter('votes'), 
reverse=True)
+                image_list = sorted(image_list, key=itemgetter('language'))
+                return image_list
             
 class FTV_MovieProvider():
 
     def __init__(self):
         self.name = 'fanart.tv - Movie API'
-        self.api_key = '586118be1ac673f74963cc284d46bd8e'
+        self.api_key = '586118be1ac673f74963cc284d46bd8e' # 
ArtworkDownloader-movie
         self.url = "http://fanart.tv/webservice/movie/%s/%s/json/all/1/2/";
         self.imagetypes = ['movielogo', 'movieart', 'moviedisc']
 
     def get_image_list(self, media_id):
         data = get_json(self.url % (self.api_key,media_id))
         image_list = []
-        # Get fanart
-        try:
-            # split "name" and "data"
-            for title, value in data.iteritems():
-                # run through specified types
-                for art in self.imagetypes:
-                    # if type has been found
-                    if value.has_key(art):
-                        # Run through all the items
-                        for item in value[art]:
-                            info = {}
-                            info['url']         = urllib.quote(item['url'], 
':/')   # Original image url
-                            info['preview']     = info['url'] + "/preview"     
     # Create a preview url for later use
-                            info['id']          = item['id']
-                            # Check on what type and use the general tag
-                            if art == 'movielogo':
-                                info['type']    = 'clearlogo'
-                            elif art == 'moviedisc':
-                                info['type']    = 'discart'
-                            elif art == 'movieart':
-                                info['type']    = 'clearart'
-                            # Check on disctype
-                            if art == 'moviedisc':
-                                info['disctype']   = item['disc_type']
-                                info['discnumber'] = item['disc']
-                            else:
-                                info['disctype']   = 'n/a'
-                                info['discnumber'] = 'n/a'
-                            # language and votes
-                            info['language']    = item['lang']
-                            info['votes']       = item['likes']
-                            # Create Gui string to display
-                            info['generalinfo'] = '%s: %s  |  ' %( 
__localize__(32141), info['language'])
-                            if info['disctype'] != 'n/a':
-                                info['generalinfo'] += '%s: %s (%s)  |  ' %( 
__localize__(32146), info['discnumber'], info['disctype'] )
-                            info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32143), info['votes'] )
-                            if info:
-                                image_list.append(info)
-        except: pass
-        if image_list == []:
-            raise NoFanartError(media_id)
+        if data == "Empty":
+            return image_list
         else:
-            # Sort the list before return. Last sort method is primary
-            image_list = sorted(image_list, key=itemgetter('votes'), 
reverse=True)
-            image_list = sorted(image_list, key=itemgetter('language'))
-            return image_list
\ No newline at end of file
+            # Get fanart
+            try:
+                # split "name" and "data"
+                for title, value in data.iteritems():
+                    # run through specified types
+                    for art in self.imagetypes:
+                        # if type has been found
+                        if value.has_key(art):
+                            # Run through all the items
+                            for item in value[art]:
+                                info = {}
+                                info['url']         = 
urllib.quote(item['url'], ':/')   # Original image url
+                                info['preview']     = info['url'] + "/preview" 
         # Create a preview url for later use
+                                info['id']          = item['id']
+                                # Check on what type and use the general tag
+                                if art == 'movielogo':
+                                    info['type']    = 'clearlogo'
+                                elif art == 'moviedisc':
+                                    info['type']    = 'discart'
+                                elif art == 'movieart':
+                                    info['type']    = 'clearart'
+                                # Check on disctype
+                                if art == 'moviedisc':
+                                    info['disctype']   = item['disc_type']
+                                    info['discnumber'] = item['disc']
+                                else:
+                                    info['disctype']   = 'n/a'
+                                    info['discnumber'] = 'n/a'
+                                # language and votes
+                                info['language']    = item['lang']
+                                info['votes']       = item['likes']
+                                # Create Gui string to display
+                                info['generalinfo'] = '%s: %s  |  ' %( 
__localize__(32141), info['language'])
+                                if info['disctype'] != 'n/a':
+                                    info['generalinfo'] += '%s: %s (%s)  |  ' 
%( __localize__(32146), info['discnumber'], info['disctype'] )
+                                info['generalinfo'] += '%s: %s  |  ' %( 
__localize__(32143), info['votes'] )
+                                if info:
+                                    image_list.append(info)
+            except: pass
+            if image_list == []:
+                raise NoFanartError(media_id)
+            else:
+                # Sort the list before return. Last sort method is primary
+                image_list = sorted(image_list, key=itemgetter('votes'), 
reverse=True)
+                image_list = sorted(image_list, key=itemgetter('language'))
+                return image_list
\ No newline at end of file
diff --git a/script.artwork.downloader/resources/lib/provider/tmdb.py 
b/script.artwork.downloader/resources/lib/provider/tmdb.py
index 52bdf08..839d03f 100644
--- a/script.artwork.downloader/resources/lib/provider/tmdb.py
+++ b/script.artwork.downloader/resources/lib/provider/tmdb.py
@@ -23,112 +23,115 @@ class TMDBProvider():
     def get_image_list(self, media_id):
         data = get_json(self.url %(media_id, self.api_key))
         image_list = []
-        # Get fanart
-        try:
-            for item in data['backdrops']:
-                info = {}
-                info['url'] = self.imageurl + 'original' + item['file_path']   
 # Original image url
-                info['preview'] = self.imageurl + 'w300' + item['file_path']   
 # Create a preview url for later use
-                info['id'] = item['file_path'].lstrip('/').replace('.jpg', '') 
 # Strip filename to get an ID
-                info['type'] = ['fanart','extrafanart']                        
 # Set standard to 'fanart'
-                info['height'] = item['height']
-                info['width'] = item['width']
-                #info['aspect_ratio'] = item['aspect_ratio']                   
 # Who knows when we may need it
-
-                # Convert the 'None' value to default 'n/a'
-                if item['iso_639_1']:
-                    info['language'] = item['iso_639_1']
-                else:
-                    info['language'] = 'n/a'
-
-                # find image ratings
-                if int(item['vote_count']) >= 1:
-                    info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
-                    info['votes'] = item['vote_count']
-                else:
-                    info['rating'] = 'n/a'
-                    info['votes'] = 'n/a'
-
-                # Create Gui string to display
-                info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  %s: 
%sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
-
-                if info:
-                    image_list.append(info)
-        except Exception, e:
-            log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
-        # Get thumbs
-        try:
-            for item in data['backdrops']:
-                info = {}
-                info['url'] = self.imageurl + 'w780' + item['file_path']    # 
Original image url
-                info['preview'] = self.imageurl + 'w300' + item['file_path']   
 # Create a preview url for later use
-                info['id'] = item['file_path'].lstrip('/').replace('.jpg', '') 
 # Strip filename to get an ID
-                info['type'] = ['thumb','extrathumbs']                         
 # Set standard to 'fanart'
-                info['height'] = item['height']
-                info['width'] = item['width']
-                #info['aspect_ratio'] = item['aspect_ratio']                   
 # Who knows when we may need it
-
-                # Convert the 'None' value to default 'n/a'
-                if item['iso_639_1']:
-                    info['language'] = item['iso_639_1']
-                else:
-                    info['language'] = 'n/a'
-
-                # find image ratings
-                if int(item['vote_count']) >= 1:
-                    info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
-                    info['votes'] = item['vote_count']
-                else:
-                    info['rating'] = 'n/a'
-                    info['votes'] = 'n/a'
-
-                # Create Gui string to display
-                info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  %s: 
%sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
-
-                if info:
-                    image_list.append(info)
-        except Exception, e:
-            log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
-        # Get posters
-        try:
-            for item in data['posters']:
-                info = {}
-                info['url'] = self.imageurl + 'original' + item['file_path']   
 # Original image url
-                info['preview'] = self.imageurl + 'w185' + item['file_path']   
 # Create a preview url for later use
-                info['id'] = item['file_path'].lstrip('/').replace('.jpg', '') 
 # Strip filename to get an ID
-                info['type'] = ['poster']                                      
   # Set standard to 'fanart'
-                info['height'] = item['height']
-                info['width'] = item['width']
-                #info['aspect_ratio'] = item['aspect_ratio']                   
 # Who knows when we may need it
-
-                # Convert the 'None' value to default 'n/a'
-                if item['iso_639_1']:
-                    info['language'] = item['iso_639_1']
-                else:
-                    info['language'] = 'n/a'
-
-                # find image ratings
-                if int(item['vote_count']) >= 1:
-                    info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
-                    info['votes'] = item['vote_count']
-                else:
-                    info['rating'] = 'n/a'
-                    info['votes'] = 'n/a'
-
-                # Create Gui string to display
-                info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  %s: 
%sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
-
-                if info:
-                    image_list.append(info)
-        except Exception, e:
-            log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
-        if image_list == []:
-            raise NoFanartError(media_id)
-        else:
-            # Sort the list before return. Last sort method is primary
-            image_list = sorted(image_list, key=itemgetter('rating'), 
reverse=True)
-            image_list = sorted(image_list, key=itemgetter('language'))
+        if data == "Empty":
             return image_list
+        else:
+            # Get fanart
+            try:
+                for item in data['backdrops']:
+                    info = {}
+                    info['url'] = self.imageurl + 'original' + 
item['file_path']    # Original image url
+                    info['preview'] = self.imageurl + 'w300' + 
item['file_path']    # Create a preview url for later use
+                    info['id'] = item['file_path'].lstrip('/').replace('.jpg', 
'')  # Strip filename to get an ID
+                    info['type'] = ['fanart','extrafanart']                    
     # Set standard to 'fanart'
+                    info['height'] = item['height']
+                    info['width'] = item['width']
+                    #info['aspect_ratio'] = item['aspect_ratio']               
     # Who knows when we may need it
+
+                    # Convert the 'None' value to default 'n/a'
+                    if item['iso_639_1']:
+                        info['language'] = item['iso_639_1']
+                    else:
+                        info['language'] = 'n/a'
+
+                    # find image ratings
+                    if int(item['vote_count']) >= 1:
+                        info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
+                        info['votes'] = item['vote_count']
+                    else:
+                        info['rating'] = 'n/a'
+                        info['votes'] = 'n/a'
+
+                    # Create Gui string to display
+                    info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  
%s: %sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
+
+                    if info:
+                        image_list.append(info)
+            except Exception, e:
+                log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
+            # Get thumbs
+            try:
+                for item in data['backdrops']:
+                    info = {}
+                    info['url'] = self.imageurl + 'w780' + item['file_path']   
 # Original image url
+                    info['preview'] = self.imageurl + 'w300' + 
item['file_path']    # Create a preview url for later use
+                    info['id'] = item['file_path'].lstrip('/').replace('.jpg', 
'')  # Strip filename to get an ID
+                    info['type'] = ['thumb','extrathumbs']                     
     # Set standard to 'fanart'
+                    info['height'] = item['height']
+                    info['width'] = item['width']
+                    #info['aspect_ratio'] = item['aspect_ratio']               
     # Who knows when we may need it
+
+                    # Convert the 'None' value to default 'n/a'
+                    if item['iso_639_1']:
+                        info['language'] = item['iso_639_1']
+                    else:
+                        info['language'] = 'n/a'
+
+                    # find image ratings
+                    if int(item['vote_count']) >= 1:
+                        info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
+                        info['votes'] = item['vote_count']
+                    else:
+                        info['rating'] = 'n/a'
+                        info['votes'] = 'n/a'
+
+                    # Create Gui string to display
+                    info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  
%s: %sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
+
+                    if info:
+                        image_list.append(info)
+            except Exception, e:
+                log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
+            # Get posters
+            try:
+                for item in data['posters']:
+                    info = {}
+                    info['url'] = self.imageurl + 'original' + 
item['file_path']    # Original image url
+                    info['preview'] = self.imageurl + 'w185' + 
item['file_path']    # Create a preview url for later use
+                    info['id'] = item['file_path'].lstrip('/').replace('.jpg', 
'')  # Strip filename to get an ID
+                    info['type'] = ['poster']                                  
       # Set standard to 'fanart'
+                    info['height'] = item['height']
+                    info['width'] = item['width']
+                    #info['aspect_ratio'] = item['aspect_ratio']               
     # Who knows when we may need it
+
+                    # Convert the 'None' value to default 'n/a'
+                    if item['iso_639_1']:
+                        info['language'] = item['iso_639_1']
+                    else:
+                        info['language'] = 'n/a'
+
+                    # find image ratings
+                    if int(item['vote_count']) >= 1:
+                        info['rating'] = float( "%.1f" % float( 
item['vote_average']) ) #output string with one decimal
+                        info['votes'] = item['vote_count']
+                    else:
+                        info['rating'] = 'n/a'
+                        info['votes'] = 'n/a'
+
+                    # Create Gui string to display
+                    info['generalinfo'] = '%s: %s  |  %s: %s  |  %s: %s  |  
%s: %sx%s  |  ' %( __localize__(32141), info['language'], __localize__(32142), 
info['rating'], __localize__(32143), info['votes'], __localize__(32145), 
info['width'], info['height'])
+
+                    if info:
+                        image_list.append(info)
+            except Exception, e:
+                log( 'Problem report: %s' %str( e ), xbmc.LOGNOTICE )
+            if image_list == []:
+                raise NoFanartError(media_id)
+            else:
+                # Sort the list before return. Last sort method is primary
+                image_list = sorted(image_list, key=itemgetter('rating'), 
reverse=True)
+                image_list = sorted(image_list, key=itemgetter('language'))
+                return image_list
 
 
 def _search_movie(medianame,year=''):
@@ -143,10 +146,13 @@ def _search_movie(medianame,year=''):
     log('TMDB API search:   %s ' % json_url)
     try:
         data = get_json(json_url)
-        for item in data['results']:
-            if item['id']:
-                tmdb_id = item['id']
-                break
+        if data == "Empty":
+            tmdb_id = ''
+        else:
+            for item in data['results']:
+                if item['id']:
+                    tmdb_id = item['id']
+                    break
     except Exception, e:
         log( str( e ), xbmc.LOGERROR )
     if tmdb_id == '':
diff --git a/script.artwork.downloader/resources/lib/utils.py 
b/script.artwork.downloader/resources/lib/utils.py
index 87be627..61f7071 100644
--- a/script.artwork.downloader/resources/lib/utils.py
+++ b/script.artwork.downloader/resources/lib/utils.py
@@ -30,7 +30,7 @@ try:
 except:
     import storageserverdummy as StorageServer
 
-cache = StorageServer.StorageServer("ArtworkDownloader",48)
+cache = StorageServer.StorageServer("ArtworkDownloader",96)
 
 ### adjust default timeout to stop script hanging
 timeout = 20
@@ -110,9 +110,9 @@ def get_json(url):
     try:
         result = cache.cacheFunction( get_json_new, url )
     except:
-        result = ''
+        result = 'Empty'
     if len(result) == 0:
-        result = []
+        result = 'Empty'
         return result
     else:
         return result
@@ -120,26 +120,34 @@ def get_json(url):
 # Retrieve JSON data from site
 def get_json_new(url):
     log('Cache expired. Retrieving new data')
+    parsed_json = []
     try:
         request = urllib2.Request(url)
+        # TMDB needs a header to be able to read the data
         if url.startswith("http://api.themoviedb.org";):
             request.add_header("Accept", "application/json")
+        # Add some delay to stop trashing the fanart.tv server for now
+        elif url.startswith("http://fanart.tv/";):
+            xbmc.sleep(2000)
         req = urllib2.urlopen(request)
         json_string = req.read()
         req.close()
+        try:
+            parsed_json = simplejson.loads(json_string)
+        except:
+            parsed_json = 'Empty'
     except HTTPError, e:
-        if e.code == 404:
+        # Add an empty cache to stop trashing the fanart.tv server for now
+        if url.startswith("http://fanart.tv/";):
+            parsed_json = 'Empty'
+        elif e.code == 404:
             raise HTTP404Error(url)
         elif e.code == 503:
             raise HTTP503Error(url)
         else:
             raise DownloadError(str(e))
     except:
-        json_string = []
-    try:
-        parsed_json = simplejson.loads(json_string)
-    except:
-        parsed_json = []
+        parsed_json = 'Empty'
     return parsed_json
 
 # Retrieve XML data from cache function

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

Summary of changes:
 script.artwork.downloader/addon.xml                |    2 +-
 script.artwork.downloader/changelog.txt            |    5 +
 script.artwork.downloader/default.py               |   17 ++-
 .../resources/lib/provider/fanarttv.py             |  176 ++++++++--------
 .../resources/lib/provider/tmdb.py                 |  224 ++++++++++----------
 script.artwork.downloader/resources/lib/utils.py   |   26 ++-
 6 files changed, 243 insertions(+), 207 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to