def __init__(self): # i18n languages = [] lc, encoding = locale.getdefaultlocale() if lc: languages = [lc] languages += constants.DEFAULT_LANGUAGES gettext.bindtextdomain(constants.SF_COMPACT_NAME, constants.LOCALE_DIR) gettext.textdomain(constants.SF_COMPACT_NAME) language = gettext.translation(constants.SF_COMPACT_NAME, constants.LOCALE_DIR, languages = languages, fallback = True) _ = language.gettext self.series_manager = SeriesManager() self.settings = Settings() self.settingsWrapper = SettingsWrapper() load_conf_item = AsyncItem(self.settings.load, (constants.SF_CONF_FILE,), self._settings_load_finished) load_shows_item = AsyncItem(self.series_manager.load, (constants.SF_DB_FILE,), self._load_finished) self.request = AsyncWorker(True) self.request.queue.put(load_conf_item) self.request.queue.put(load_shows_item) self.request.start() self.version = constants.SF_VERSION
def _get_complete_show_finished_cb(self, show, error): logging.debug('GET_FULL_SHOW_COMPLETE_SIGNAL') #TODO async_worker = AsyncWorker(True) async_item = AsyncItem( self._set_show_images, (show, ), None, ) async_worker.queue.put(async_item) async_worker.start()
def search_shows(self, terms, language="en"): if not terms: return [] self.search_results = [] self.searching = True pyotherside.send('searching', self.searching) async_worker = AsyncWorker(True) async_item = AsyncItem(self.thetvdb.get_matching_shows, ( terms, language, ), self._search_finished_callback) async_worker.queue.put(async_item) async_worker.start()
def update_all_shows_episodes(self, show_list=[]): self.isUpdating = True pyotherside.send('updating', self.isUpdating) show_list = show_list or self.series_list async_worker = AsyncWorker(False) update_images_worker = AsyncWorker(True) i = 0 n_shows = len(show_list) for i in range(n_shows): update_ended_shows = Settings().getConf( Settings.UPDATE_ENDED_SHOWS) show = show_list[i] if show.status and show.status == 'Ended' and not update_ended_shows: async_item = AsyncItem( self._empty_callback, (), self._set_show_episodes_complete_cb, (show, update_images_worker, i == n_shows - 1)) async_worker.queue.put(async_item) continue pyotherside.send('episodesListUpdating', show.get_name()) show.set_updating(True) async_item = AsyncItem( self.thetvdb.get_show_and_episodes, ( show.thetvdb_id, show.language, ), self._set_show_episodes_complete_cb, (show, update_images_worker, i == n_shows - 1)) async_worker.queue.put(async_item) async_item = AsyncItem( self._set_show_images, (show, ), None, ) update_images_worker.queue.put(async_item) async_worker.start() return async_worker
def closeEvent(self): # If the shows list is empty but the user hasn't deleted # any, then we don't save in order to avoid overwriting # the current db (for the shows list might be empty due # to an error) logging.debug('Going down...') if not self.series_manager.series_list and not self.series_manager.have_deleted: return self.series_manager.auto_save(False) save_shows_item = AsyncItem(self.series_manager.save, (constants.SF_DB_FILE,)) save_conf_item = AsyncItem(self.settings.save, (constants.SF_CONF_FILE,), self._save_finished_cb) async_worker = AsyncWorker(False) async_worker.queue.put(save_shows_item) async_worker.queue.put(save_conf_item) async_worker.start() # Wait for the saving thread to complete. async_worker.join()
def get_complete_show(self, show_name, language="en"): # Test if the show has already been added. for show in self.series_list: if show.name == show_name: pyotherside.send('notification', 'Show already in library') return self.isUpdating = True pyotherside.send('updating', self.isUpdating) show_id = self._cached_tvdb_shows.get(show_name, None) for show_id, show_title in self._cached_tvdb_shows.items(): if show_title == show_name: break if not show_id: return async_worker = AsyncWorker(False) async_item = AsyncItem(self._get_complete_show_from_id, ( show_id, language, ), self._get_complete_show_finished_cb) async_worker.queue.put(async_item) async_worker.start()