コード例 #1
0
ファイル: widget.py プロジェクト: rexMingla/my-renamer
  def _loadSettingsConfig(self):
    self._config_manager.loadConfig(self._config_file)

    try:
      data = self._config_manager.getData("mw", config.MainWindowConfig())
      config_version = data.config_version if isinstance(data, config.MainWindowConfig) else "0.0"
      if config_version != config.CONFIG_VERSION:
        utils.logDebug(
            "config version of out date, loading default. old={} new={}".format(config_version, config.CONFIG_VERSION))
        return

      self.restoreGeometry(QtCore.QByteArray.fromBase64(data.geo))
      self.restoreState(QtCore.QByteArray.fromBase64(data.state))
      base_widget.DontShowManager.setConfig(data.dont_shows)
      if not data.mode in base_types.VALID_MODES:
        data.mode = base_types.TV_MODE
      self._setMode(data.mode)
      self._auto_start = data.auto_start

      for module in self._mode_to_module.values():
        for widget in [module.input_widget, module.output_widget, module.work_bench]:
          widget.setConfig(self._config_manager.getData(widget.config_name, None))
    except (AttributeError, ValueError, TypeError, IndexError, KeyError) as ex:
      utils.logWarning("Unable to load config file. reason: {}".format(ex))
      if not self._is_restoring_defaults:
        self._restoreDefaults()
      else:
        QtGui.QMessageBox.warning(self, "Config error", "Default config is in a bad state. Fix me!")
コード例 #2
0
 def loadConfig(self, filename):
   """ deserializes the contents of the file with jsonpickle """
   self._data = {}
   if file_helper.FileHelper.fileExists(filename):
     file_obj = open(filename, "r")
     try:
       self._data = jsonpickle.decode(file_obj.read())
     except (ValueError, TypeError, IndexError, KeyError) as ex:
       utils.logWarning("loadConfig error: {}".format(ex))
   if not isinstance(self._data, dict):
     self._data = {}
コード例 #3
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def getAllInfo(self, search_params):
   """ returns a list of ResultHolder objects for all items matching the search parameters 
   Args: 
     search_params: media.base.BaseSearchParams object used to assist client finding info
   """    
   ret = []
   try:
     ret = self._getAllInfo(search_params) if self.isAvailable() else None
   except Exception as ex:
     utils.logWarning("uncaught exception in lib. lib={} params={} ex={}".format(self.display_name,
         search_params.getKey(), ex))
   return ret
コード例 #4
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret = []
   try:
     source = IMDb("http")
     movie = source.search_movie(str(search_params))
     info = movie_types.MovieInfo(utils.sanitizeString(movie.title or search_params.title), search_params.year)
     ret.append(info)
     info.year = utils.sanitizeString(movie.year or search_params.year)
     info.genres = [utils.sanitizeString(g) for g in movie.genre] or info.genres
   except (AttributeError, pymdb.MovieError) as ex:
     utils.logWarning("Lib: {} Title: {} Error {}: {}".format(self.display_name, search_params.title, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret
コード例 #5
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret = []
   try:
     source = tvrage.api.Show(search_params.show_name)
     season = source.season(search_params.season_num)
     eps = tv_types.SeasonInfo(utils.sanitizeString(source.name) or search_params.show_name, search_params.season_num)
     ret.append(eps)
     for i in season.values():
       show = tv_types.EpisodeInfo(int(i.number), utils.sanitizeString(i.title))
       eps.episodes.append(show)
   except tvrage.exceptions.BaseError as ex:
     utils.logWarning("Lib: {} Show: {} season_num: {} Error {}: {}".format(self.display_name, search_params.show_name,
                                                                           search_params.season_num, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret
コード例 #6
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret  = []
   info = None
   try:
     movie = pymdb.Movie(str(search_params))
     title = utils.sanitizeString(movie.title or search_params.title)
     info = movie_types.MovieInfo(title, search_params.year)
     ret.append(info)
     info.year = utils.sanitizeString(movie.year or search_params.year)
     info.genres = [utils.sanitizeString(g) for g in movie.genre] or info.genres
   except (ValueError, AttributeError) as ex:
     pass
   except pymdb.MovieError as ex:
     utils.logWarning("Lib: {} Title: {} Error {}: {}".format(self.display_name, search_params.title, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret
コード例 #7
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret = []
   try:
     pretty_title = str(search_params)
     source = RT(self.key)
     results = source.search(pretty_title)
     for i in results:
       title = utils.sanitizeString(i.get("title", search_params.title))
       year = str(i.get("year", search_params.year))
       info = movie_types.MovieInfo(title, year)
       #no genre without more effort
       ret.append(info)
   except Exception as ex: #bad need to find a better exception
     utils.logWarning("Lib: {} Title: {} Error {}: {}".format(self.display_name, search_params.title, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret
コード例 #8
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret = []
   try:
     source = tvdb_api.Tvdb()
     season = source[search_params.show_name][search_params.season_num]
     eps = tv_types.SeasonInfo(utils.sanitizeString(source[search_params.show_name]["seriesname"], "") or
                                         search_params.show_name, search_params.season_num)
     ret.append(eps)
     for i in season:
       episode = season[i]
       show = tv_types.EpisodeInfo(int(episode["episodenumber"]),
                                   utils.sanitizeString(episode["episodename"] or ""))
       eps.episodes.append(show)
   except tvdb_exceptions.tvdb_exception as ex:
     utils.logWarning("Lib: {} Show: {} season_num: {} Error {}: {}".format(self.display_name, search_params.show_name,
                                                                           search_params.season_num, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret
コード例 #9
0
ファイル: client.py プロジェクト: rexMingla/my-renamer
 def _getAllInfo(self, search_params):
   ret = []
   try:
     pretty_title = str(search_params)
     source = tmdb.MovieDb()
     results = source.search(pretty_title)
     for result in results:
       title = utils.sanitizeString(result.get("name", search_params.title))
       year = str(result.get("released", search_params.year))[:4]
       info = movie_types.MovieInfo(title, year)
       ret.append(info)
       sub_info = result.info()
       genres = []
       if "categories" in sub_info and "genre" in sub_info["categories"]:
         genres = sub_info["categories"]["genre"].keys()
       info.genres = [utils.sanitizeString(g) for g in genres]
   except tmdb.TmdBaseError as ex:
     utils.logWarning("Lib: {} Title: {} Error {}: {}".format(self.display_name, search_params.title, type(ex), ex),
                      title="{} lookup".format(self.display_name))
   return ret