def GetShowBanner(self, show_id, update=False):
     image = None
     if show_id == '0':
         return ''
     file_path = xbmc.translatePath('special://temp/sb/cache/images/'+show_id+'.banner.jpg')
     if not os.path.exists(file_path) or update:
         # Download image from SB server.
         try:
             image = GetUrlData(url=settings.__url__+'?cmd=show.getbanner&tvdbid='+str(show_id), add_useragent=True, encodeType=None)
             if (image == None) or (len(image) < 1024):
                 # Get generic image instead.
                 with open(xbmc.translatePath('special://home/addons/plugin.video.sickrage/resources/images/missing_banner.jpg'), mode='rb') as f:
                     image = f.read()
         except Exception, e:
             settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
             return ''
         # Write image file to local cache.
         try:
             if not os.path.exists(os.path.dirname(file_path)):
                 os.makedirs(os.path.dirname(file_path))
             f = open(file_path, 'wb+')
             f.write(image)
             f.close()
         except Exception, e:
             settings.errorWindow(sys._getframe().f_code.co_name, str(e))
 def SetShowStatus(self, tvdbid, season, ep, status):
     result = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=episode.setstatus&tvdbid='+str(tvdbid)+'&season='+str(season)+'&episode='+str(ep)+'&status='+status+'&force=True')
         result = json.loads(response)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetShowBanner(self, show_id, update=False):
     image = None
     if show_id == '0':
         return ''
     file_path = xbmc.translatePath('special://temp/sb/cache/images/' +
                                    show_id + '.banner.jpg')
     if not os.path.exists(file_path) or update:
         # Download image from SB server.
         try:
             image = GetUrlData(url=settings.__url__ +
                                '?cmd=show.getbanner&tvdbid=' +
                                str(show_id),
                                add_useragent=True,
                                encodeType=None)
             if (image == None) or (len(image) < 1024):
                 # Get generic image instead.
                 with open(xbmc.translatePath(
                         'special://home/addons/plugin.video.sickrage/resources/images/missing_banner.jpg'
                 ),
                           mode='rb') as f:
                     image = f.read()
         except Exception, e:
             settings.errorWindow(sys._getframe().f_code.co_name,
                                  self.CONNECT_ERROR + str(e))
             return ''
         # Write image file to local cache.
         try:
             if not os.path.exists(os.path.dirname(file_path)):
                 os.makedirs(os.path.dirname(file_path))
             f = open(file_path, 'wb+')
             f.write(image)
             f.close()
         except Exception, e:
             settings.errorWindow(sys._getframe().f_code.co_name, str(e))
 def GetRoodDirs(self):
     directory_result = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=sb.getrootdirs')
         result = json.loads(response)
         result = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetFutureShows(self):
     future_list = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=future&sort=date&type=today|soon|later')
         result = json.loads(response)
         future_list = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def SetPausedState(self, paused, show_id):
     message = ""
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=show.pause&indexerid='+show_id+'&tvdbid='+show_id+'&pause='+paused)
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def ManualSearch(self, tvdbid, season, ep):
     message = ""
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=episode.search&tvdbid='+str(tvdbid)+'&season='+str(season)+'&episode='+str(ep))
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def DeleteShow(self, tvdbid, removefiles):
     message = ""
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=show.delete&tvdbid='+str(tvdbid)+'&removefiles='+str(removefiles))
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetLog(self, min_level):
     log_list = []
     try:
         response = GetUrlData(url=settings.__url__ + '?cmd=logs&min_level=' + str(min_level))
         result = json.loads(response)
         log_list = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetSickRageVersion(self):
     version = ""
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=sb')
         result = json.loads(response)
         version = result['data']['sb_version']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetHistory(self, num_entries):
     history = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=history&limit='+str(num_entries))
         result = json.loads(response)
         history = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetShows(self):
     shows = []
     try:
         response = GetUrlData(url=settings.__url__ + '?cmd=shows')
         result = json.loads(response)
         for each in result['data']:
             show = {}
             # Minimum required fields listed first.
             show['tvdbid'] = str(result['data'][each]['tvdbid'])
             show['show_name'] = FixBadChar(
                 result['data'][each]['show_name'])
             show['paused'] = result['data'][each]['paused']
             show['status'] = result['data'][each]['status']
             try:
                 show['anime'] = result['data'][each]['anime']
             except:
                 show['anime'] = ''
             try:
                 show['indexerid'] = str(result['data'][each]['indexerid'])
             except:
                 show['indexerid'] = ''
             try:
                 show['language'] = result['data'][each]['language']
             except:
                 show['language'] = ''
             try:
                 show['network'] = result['data'][each]['network']
             except:
                 show['network'] = ''
             try:
                 show['next_ep_airdate'] = result['data'][each][
                     'next_ep_airdate']
             except:
                 show['next_ep_airdate'] = ''
             try:
                 show['quality'] = result['data'][each]['quality']
             except:
                 show['quality'] = ''
             try:
                 show['sports'] = result['data'][each]['sports']
             except:
                 show['sports'] = ''
             try:
                 show['subtitles'] = result['data'][each]['subtitles']
             except:
                 show['subtitles'] = ''
             try:
                 show['tvrage_id'] = str(result['data'][each]['tvrage_id'])
             except:
                 show['tvrage_id'] = ''
             try:
                 show['tvrage_name'] = result['data'][each]['tvrage_name']
             except:
                 show['tvrage_name'] = ''
             shows.append(show)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetRoodDirs(self):
     directory_result = []
     try:
         response = GetUrlData(url=settings.__url__ + '?cmd=sb.getrootdirs')
         result = json.loads(response)
         result = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def ForceSearch(self, show_id):
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=show.update&tvdbid='+show_id)
         result = json.loads(response)
         message = result['message']
         success = result['result']
         settings.errorWindow("Force Update", message + " ["+success+"]")
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetSeasonNumberList(self, show_id):
     season_number_list = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=show.seasonlist&tvdbid='+show_id)
         result = json.loads(response)
         season_number_list = result['data']
         season_number_list.sort()
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def AddNewShow(self, tvdbid, location, prev_aired_status, future_status, flatten_folders, quality):
     result = ""
     try:
         url = settings.__url__+'?cmd=show.addnew&tvdbid='+str(tvdbid)+'&location='+urllib.quote(location)+'&status='+prev_aired_status+'&future_status='+future_status+'&flatten_folders='+str(flatten_folders)+'&initial='+quality
         print 'Add Show Request:' + url
         response = GetUrlData(url=url)
         result = json.loads(response)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetSickRageVersion(self):
     version = ""
     try:
         response = GetUrlData(url=settings.__url__ + '?cmd=sb')
         result = json.loads(response)
         version = result['data']['sb_version']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetShowIds(self):
     show_ids=[]
     try:
         response = GetUrlData(url=settings.__url__+"?cmd=shows")
         result = json.loads(response)
         for each in result['data']:
             show_ids.append(each)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetShowIds(self):
     show_ids = []
     try:
         response = GetUrlData(url=settings.__url__ + "?cmd=shows")
         result = json.loads(response)
         for each in result['data']:
             show_ids.append(each)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetLog(self, min_level):
     log_list = []
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=logs&min_level=' + str(min_level))
         result = json.loads(response)
         log_list = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetHistory(self, num_entries):
     history = []
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=history&limit=' + str(num_entries))
         result = json.loads(response)
         history = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetDefaults(self):
     defaults = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=sb.getdefaults')
         result = json.loads(response)
         print result.keys()
         defaults_data = result['data']
         defaults = [defaults_data['status'], defaults_data['flatten_folders'], str(defaults_data['initial'])]
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetShows(self):
     shows=[]
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=shows')
         result = json.loads(response)
         for each in result['data']:
             show = {}
             # Minimum required fields listed first.
             show['tvdbid'] = str(result['data'][each]['tvdbid'])
             show['show_name'] = FixBadChar(result['data'][each]['show_name'])
             show['paused'] = result['data'][each]['paused']
             show['status'] = result['data'][each]['status']
             try:
                 show['anime'] = result['data'][each]['anime']
             except:
                 show['anime'] = ''
             try:
                 show['indexerid'] = str(result['data'][each]['indexerid'])
             except:
                 show['indexerid'] = ''
             try:
                 show['language'] = result['data'][each]['language']
             except:
                 show['language'] = ''
             try:
                 show['network'] = result['data'][each]['network']
             except:
                 show['network'] = ''
             try:
                 show['next_ep_airdate'] = result['data'][each]['next_ep_airdate']
             except:
                 show['next_ep_airdate'] = ''
             try:
                 show['quality'] = result['data'][each]['quality']
             except:
                 show['quality'] = ''
             try:
                 show['sports'] = result['data'][each]['sports']
             except:
                 show['sports'] = ''
             try:
                 show['subtitles'] = result['data'][each]['subtitles']
             except:
                 show['subtitles'] = ''
             try:
                 show['tvrage_id'] = str(result['data'][each]['tvrage_id'])
             except:
                 show['tvrage_id'] = ''
             try:
                 show['tvrage_name'] = result['data'][each]['tvrage_name']
             except:
                 show['tvrage_name'] = ''
             shows.append(show)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def SetPausedState(self, paused, show_id):
     message = ""
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=show.pause&indexerid=' + show_id +
                               '&tvdbid=' + show_id + '&pause=' + paused)
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def ManualSearch(self, tvdbid, season, ep):
     message = ""
     try:
         response = GetUrlData(
             url=settings.__url__ + '?cmd=episode.search&tvdbid=' +
             str(tvdbid) + '&season=' + str(season) + '&episode=' + str(ep))
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def DeleteShow(self, tvdbid, removefiles):
     message = ""
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=show.delete&tvdbid=' + str(tvdbid) +
                               '&removefiles=' + str(removefiles))
         result = json.loads(response)
         message = result['message']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetFutureShows(self):
     future_list = []
     try:
         response = GetUrlData(
             url=settings.__url__ +
             '?cmd=future&sort=date&type=today|soon|later')
         result = json.loads(response)
         future_list = result['data']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetSeasonNumberList(self, show_id):
     season_number_list = []
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=show.seasonlist&tvdbid=' + show_id)
         result = json.loads(response)
         season_number_list = result['data']
         season_number_list.sort()
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def SetShowStatus(self, tvdbid, season, ep, status):
     result = []
     try:
         response = GetUrlData(
             url=settings.__url__ + '?cmd=episode.setstatus&tvdbid=' +
             str(tvdbid) + '&season=' + str(season) + '&episode=' +
             str(ep) + '&status=' + status + '&force=True')
         result = json.loads(response)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def ForceSearch(self, show_id):
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=show.update&tvdbid=' + show_id)
         result = json.loads(response)
         message = result['message']
         success = result['result']
         settings.errorWindow("Force Update",
                              message + " [" + success + "]")
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetShowInfo(self, show_ids):
     show_info={}
     try:
         for id in show_ids:
             response = GetUrlData(url=settings.__url__+'?cmd=show&tvdbid='+id)
             result = json.loads(response)
             name = result['data']['show_name']
             paused = result['data']['paused']
             status = result['data']['status']
             show_info[name] = [id, paused, status]
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def SearchShowName(self, name):
     search_results = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=sb.searchtvdb&name='+name+'&lang=en')
         result = json.loads(response)
         if result['result'] != 'success':
             return search_results
         for each in result['data']['results']:
             # Limit results to segments that contain an attribute 'tvdbid'.  SickRage webapi.py has a bug where it returns both tvdb and tvrage results together, even though they have separate search functions.
             if (each.get('tvdbid') != None):
                 search_results.append(each)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetShowDetails(self, show_id):
     details = []
     total = []
     try:
         response = GetUrlData(url=settings.__url__+'?cmd=show&tvdbid='+show_id)
         result = json.loads(response)
         details = result['data']
         
         response = GetUrlData(url=settings.__url__+'?cmd=show.stats&tvdbid='+show_id)
         result = json.loads(response)
         total = result['data']['total']
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))                   
 def GetShowInfo(self, show_ids):
     show_info = {}
     try:
         for id in show_ids:
             response = GetUrlData(url=settings.__url__ +
                                   '?cmd=show&tvdbid=' + id)
             result = json.loads(response)
             name = result['data']['show_name']
             paused = result['data']['paused']
             status = result['data']['status']
             show_info[name] = [id, paused, status]
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
Exemple #35
0
 def AddNewShow(self, tvdbid, location, prev_aired_status, future_status,
                flatten_folders, quality):
     result = ""
     try:
         url = settings.__url__ + '?cmd=show.addnew&tvdbid=' + str(
             tvdbid
         ) + '&location=' + location + '&status=' + prev_aired_status + '&future_status=' + future_status + '&flatten_folders=' + str(
             flatten_folders) + '&initial=' + quality
         print 'Add Show Request:' + url
         response = GetUrlData(url=url)
         result = json.loads(response)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetDefaults(self):
     defaults = []
     try:
         response = GetUrlData(url=settings.__url__ + '?cmd=sb.getdefaults')
         result = json.loads(response)
         print result.keys()
         defaults_data = result['data']
         defaults = [
             defaults_data['status'], defaults_data['flatten_folders'],
             str(defaults_data['initial'])
         ]
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
 def GetBacklog(self):
     results = [] 
     try:
         response = GetUrlData(url=settings.__url__+"?cmd=backlog")
         result = json.loads(response)
         for show in result['data']:
             show_name = show['show_name']
             status = show['status']
             for episode in show['episodes']:
                 episode['show_name'] = show_name
                 episode['status'] = status
                 results.append(episode)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))
 def GetBacklog(self):
     results = []
     try:
         response = GetUrlData(url=settings.__url__ + "?cmd=backlog")
         result = json.loads(response)
         for show in result['data']:
             show_name = show['show_name']
             status = show['status']
             for episode in show['episodes']:
                 episode['show_name'] = show_name
                 episode['status'] = status
                 results.append(episode)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
    def GetShowDetails(self, show_id):
        details = []
        total = []
        try:
            response = GetUrlData(url=settings.__url__ + '?cmd=show&tvdbid=' +
                                  show_id)
            result = json.loads(response)
            details = result['data']

            response = GetUrlData(url=settings.__url__ +
                                  '?cmd=show.stats&tvdbid=' + show_id)
            result = json.loads(response)
            total = result['data']['total']
        except Exception, e:
            settings.errorWindow(sys._getframe().f_code.co_name,
                                 self.CONNECT_ERROR + str(e))
 def GetSeasonEpisodeList(self, show_id, season):
     season_episodes = []
     try:
         season = str(season)
         response = GetUrlData(url=settings.__url__+'?cmd=show.seasons&tvdbid='+show_id+'&season='+season)
         result = json.loads(response)
         season_episodes = result['data']
           
         for key in season_episodes.iterkeys():
             if int(key) < 10:
                 newkey = '{0}'.format(key.zfill(2))
                 if newkey not in season_episodes:
                     season_episodes[newkey] = season_episodes[key]
                     del season_episodes[key]
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name, self.CONNECT_ERROR+str(e))        
 def SearchShowName(self, name):
     search_results = []
     try:
         response = GetUrlData(url=settings.__url__ +
                               '?cmd=sb.searchtvdb&name=' + name +
                               '&lang=en')
         result = json.loads(response)
         if result['result'] != 'success':
             return search_results
         for each in result['data']['results']:
             # Limit results to segments that contain an attribute 'tvdbid'.  SickRage webapi.py has a bug where it returns both tvdb and tvrage results together, even though they have separate search functions.
             if (each.get('tvdbid') != None):
                 search_results.append(each)
     except Exception, e:
         settings.errorWindow(sys._getframe().f_code.co_name,
                              self.CONNECT_ERROR + str(e))
    def GetSeasonEpisodeList(self, show_id, season):
        season_episodes = []
        try:
            season = str(season)
            response = GetUrlData(url=settings.__url__ +
                                  '?cmd=show.seasons&tvdbid=' + show_id +
                                  '&season=' + season)
            result = json.loads(response)
            season_episodes = result['data']

            for key in season_episodes.iterkeys():
                if int(key) < 10:
                    newkey = '{0}'.format(key.zfill(2))
                    if newkey not in season_episodes:
                        season_episodes[newkey] = season_episodes[key]
                        del season_episodes[key]
        except Exception, e:
            settings.errorWindow(sys._getframe().f_code.co_name,
                                 self.CONNECT_ERROR + str(e))