示例#1
0
 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
示例#2
0
文件: episode.py 项目: xgi/castero
    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
示例#3
0
    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()
示例#4
0
    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()
示例#5
0
def test_negative_seconds_to_time():
    result = helpers.seconds_to_time(-10)
    assert result == "00:00:00"
示例#6
0
def test_seconds_to_time():
    seconds = (60 * 60) + (60 * 23) + 45
    result = helpers.seconds_to_time(seconds)
    assert result == "01:23:45"