def time_str(self) -> str: """str: the formatted time and duration of the player""" result = "00:00:00/00:00:00" if self._player is not None: time_seconds = int(self.time / constants.MILLISECONDS_IN_SECOND) length_seconds = int(self.duration / constants.MILLISECONDS_IN_SECOND) t = helpers.seconds_to_time(time_seconds) d = helpers.seconds_to_time(length_seconds) result = "%s/%s" % (t, d) return result
def metadata(self) -> str: """str: the user-displayed metadata of the episode""" description = (helpers.html_to_plain(self.description) if helpers.is_true(Config["clean_html_descriptions"]) else self.description) description = description.replace("\n", "") progress = helpers.seconds_to_time(self.progress / constants.MILLISECONDS_IN_SECOND) downloaded = ("Episode downloaded and available for offline playback." if self.downloaded else "Episode not downloaded.") metadata = ("!cb{title}\n" "{pubdate}\n\n" "{link}\n\n" "!cbCopyright:\n" "{copyright}\n\n" "!cbDownloaded:\n" "{downloaded}\n\n" "!cbDescription:\n" "{description}\n\n" "!cbTime Played:\n" "{progress}\n".format( title=self.title, pubdate=self.pubdate, link=self.link, copyright=self.copyright, downloaded=downloaded, description=description, progress=progress, )) return metadata
def play_from(self, seconds) -> None: """play media from point.""" if self._player is None: self._create_player() timestamp = helpers.seconds_to_time(seconds) self._player.start = timestamp self.play()
def play_from(self, seconds) -> None: """play media from point. Overrides method from Player; see documentation in that class. """ if self._player is None: self._create_player() timestamp = helpers.seconds_to_time(seconds) self._player.start = timestamp self.play()
def test_negative_seconds_to_time(): result = helpers.seconds_to_time(-10) assert result == "00:00:00"
def test_seconds_to_time(): seconds = (60 * 60) + (60 * 23) + 45 result = helpers.seconds_to_time(seconds) assert result == "01:23:45"