Пример #1
0
def main():
    # both functions return a tuple: (days, hours, minutes)
    clock = bingeclock_series("avatar-the-last-airbender")
    print("Aang: {} days, {} hours, and {} minutes".format(
        clock[0], clock[1], clock[2]))

    # request time excluding credits and commercial runtime
    clock = bingeclock_series("avatar-the-last-airbender", commercials=False)
    print("Aang, no commercials/credits: {} days, {} hours, and {} minutes".
          format(clock[0], clock[1], clock[2]))

    # request number of days to binge, 8 hours a day
    clock = bingeclock_series("avatar-the-last-airbender", hours=8)
    print(
        "Aang, 8 hours/day: {} days, {} hours, and {} minutes".format(*clock))

    (days, hours, minutes) = bingeclock_series("tiger-king")
    print("Joe Exotic: {} days, {} hours, and {} minutes".format(
        days, hours, minutes))

    # on error, silently returns an empty tuple
    clock = bingeclock_series("the-chilling-adventures-of-dolph-lundgren")
    if clock:
        print("Dolph found: {} days, {} hours, and {} minutes".format(
            clock[0], clock[1], clock[2]))
    else:
        print("Dolph not found")

    # you can also ask for one of thier movie binge lists, aka marathons
    clock = bingeclock_marathon("marvel-cinematic-universe-2")
    print("MCU movies: {} days, {} hours, and {} minutes".format(*clock))
Пример #2
0
    def generate_message_body(self):
        start_date = datetime.date(2020, 3, 18)

        today = datetime.date.today()

        delta_days = today - start_date

        self.message = "Home since {}\n\n".format(start_date)
        self.message += "  {} days of isolation\n".format(delta_days.days)
        self.message += "  {} weeks of isolation\n\n".format(
            str(int(round(delta_days.days / 7, 2))))

        series = random.choice(series_list)
        self.logger.debug("chose series {}".format(series['title']))

        clock = bingeclock_series(series['url'], hours=8)
        if clock:
            binge_days = clock[0]
            times = int(round(delta_days.days / binge_days))
            self.message += "If you had spent 8 hours a day binging on {},\nyou could have watched the entire series {} times!\n".format(
                series['title'], times)
        else:
            self.logger.debug("failed to get bingeclock for series {}".format(
                series['title']))
Пример #3
0
 def test_series_basic(self):
     clock = bingeclock_series(
         "avatar-the-last-airbender")  # normal, 3 numbers expected
     self.assertEqual(clock, (1, 6, 30))
Пример #4
0
 def test_series_notaseries(self):
     clock = bingeclock_series(
         "the-chilling-adventures-of-dolph-lundgren")  # doesn't exist
     self.assertEqual(clock, ())
Пример #5
0
 def test_series_toomanyoptions(self):
     clock = bingeclock_series("avatar-the-last-airbender",
                               commercials=False,
                               hours=7)  # fail, can't use both optionals
     self.assertEqual(clock, ())
Пример #6
0
 def test_series_commercials(self):
     clock = bingeclock_series("avatar-the-last-airbender",
                               commercials=False)  # cut commerials+credits
     self.assertEqual(clock, (0, 22, 22))
Пример #7
0
 def test_series_nodays(self):
     clock = bingeclock_series("tiger-king")  # 5:17, no days
     self.assertEqual(clock, (0, 5, 17))
Пример #8
0
 def test_series_nomin(self):
     clock = bingeclock_series(
         "legend-of-korra/")  # returns D:H, no minutes
     self.assertEqual(clock, (1, 2, 0))
Пример #9
0
 def test_series_hours(self):
     clock = bingeclock_series(
         "days-of-our-lives",
         hours=4)  # hours per day, will only return answer in days
     self.assertEqual(clock, (2821, 0, 0))