def append(self, show, altname=None, eps=None): episodes_str = "{} / {}".format(show['my_progress'], show['total'] or '?') if show['total'] and show['my_progress'] <= show['total']: progress = (float(show['my_progress']) / show['total']) * 100 else: progress = 0 title_str = show['title'] if altname: title_str += " [%s]" % altname score_str = "%0.*f" % (self.decimals, show['my_score']) aired_eps = utils.estimate_aired_episodes(show) if eps: available_eps = eps.keys() else: available_eps = [] start_date = self.format_date(show['start_date']) end_date = self.format_date(show['end_date']) my_start_date = self.format_date(show['my_start_date']) my_finish_date = self.format_date(show['my_finish_date']) row = [ show['id'], title_str, show['my_progress'], show['my_score'], episodes_str, score_str, show['total'], aired_eps, available_eps, self._get_color(show, available_eps), progress, start_date, end_date, my_start_date, my_finish_date, show['my_status'], show['status'] ] super().append(row)
def _calculate_eps(self, row, show): aired_eps = utils.estimate_aired_episodes(show) library_eps = self.library.get(show['id']) if library_eps: library_eps = library_eps.keys() if aired_eps or library_eps: self.eps[row] = (aired_eps, library_eps) elif row in self.eps: del self.eps[row]
def _build_episode_menu(self, show): total = show['total'] or utils.estimate_aired_episodes(show) or 0 menu_eps = Gtk.Menu() for i in range(1, total + 1): mb_playep = Gtk.CheckMenuItem(str(i)) if i <= show['my_progress']: mb_playep.set_active(True) mb_playep.connect("activate", self._on_mb_activate, ShowEventType.PLAY_EPISODE, i) menu_eps.append(mb_playep) return menu_eps
def tracker_state(engine, status): """ Update status in thread. """ print(status) if status["state"] in [PLAYING, IGNORED]: show = status["show"][0] title = show["titles"][0] episode = status["show"][-1] total = show["total"] or estimate_aired_episodes( engine.get_show_info(show['id'])) or '?' if status["paused"]: rpc.present(engine, status["viewOffset"], "{}".format(title), "Paused episode {} of {}".format(episode, total)) else: rpc.present(engine, status["viewOffset"], "{}".format(title), "Watching episode {} of {}".format(episode, total)) else: rpc.present(engine)