Skip to content

Commit

Permalink
Restructure Video of the Day related data in strings database
Browse files Browse the repository at this point in the history
Structure the data instead of having multiple separate dicts with the
same keys.
  • Loading branch information
kh31d4r authored and mosbth committed Nov 24, 2024
1 parent 1df42e0 commit 22c5e69
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 25 deletions.
10 changes: 5 additions & 5 deletions marvin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ def videoOfToday():
"""
Check what day it is and provide a url to a suitable video together with a greeting.
"""
day = datetime.date.today().strftime("%A")
msg = getString("weekdays", day)
video = getString("video-of-today", day)
weekday = datetime.date.today().strftime("%A")
day = getString("video-of-today", weekday)
msg = day.get("message")

if video:
msg += " En passande video är " + video
if day:
msg += " En passande video är " + day.get("url")
else:
msg += " Jag har ännu ingen passande video för denna dagen."

Expand Down
46 changes: 28 additions & 18 deletions marvin_strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,35 @@
"#5": "Hey Luke - use the source! https://catb.org/jargon/html/U/UTSL.html"
},


"weekdays": {
"Monday": "Idag är det måndag.",
"Tuesday": "Idag är det tisdag.",
"Wednesday": "Idag är det onsdag.",
"Thursday": "Idag är det torsdag.",
"Friday": "Idag är det fredag.",
"Saturday": "Idag är det lördag.",
"Sunday": "Idag är det söndag."
},

"video-of-today": {
"Monday": "https://www.youtube.com/watch?v=HbJ6Jsy0JfY https://www.youtube.com/watch?v=-Kobdb37Cwc eller https://www.youtube.com/watch?v=d-diB65scQU",
"Tuesday": "https://www.youtube.com/watch?v=sL4znuvCuRg",
"Wednesday": "https://www.youtube.com/watch?v=F3jnymeJof4",
"Thursday": "https://www.youtube.com/watch?v=9Tg_zvDg3Xo",
"Friday": "https://www.youtube.com/watch?v=kfVsfOSbJY0",
"Saturday": "https://www.youtube.com/watch?v=GVCzdpagXOQ",
"Sunday": "https://www.youtube.com/watch?v=c3BvW56tjB0"
"Monday": {
"url": "https://www.youtube.com/watch?v=HbJ6Jsy0JfY https://www.youtube.com/watch?v=-Kobdb37Cwc eller https://www.youtube.com/watch?v=d-diB65scQU",
"message": "Idag är det måndag."
},
"Tuesday": {
"url": "https://www.youtube.com/watch?v=sL4znuvCuRg",
"message": "Idag är det tisdag."
},
"Wednesday": {
"url": "https://www.youtube.com/watch?v=F3jnymeJof4",
"message": "Idag är det onsdag."
},
"Thursday": {
"url": "https://www.youtube.com/watch?v=9Tg_zvDg3Xo",
"message": "Idag är det torsdag."
},
"Friday": {
"url": "https://www.youtube.com/watch?v=kfVsfOSbJY0",
"message": "Idag är det fredag."
},
"Saturday": {
"url": "https://www.youtube.com/watch?v=GVCzdpagXOQ",
"message": "Idag är det lördag."
},
"Sunday": {
"url": "https://www.youtube.com/watch?v=c3BvW56tjB0",
"message": "Idag är det söndag."
}
},

"lunch-message": [
Expand Down
4 changes: 2 additions & 2 deletions test_marvin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ def testVideoOfToday(self):
day = date(2024, 11, 25) + timedelta(days=d)
dt.date.today.return_value = day
weekday = day.strftime("%A")
weekdayPhrase = self.strings.get("weekdays").get(weekday)
videoPhrase = self.strings.get("video-of-today").get(weekday)
weekdayPhrase = self.strings.get("video-of-today").get(weekday).get("message")
videoPhrase = self.strings.get("video-of-today").get(weekday).get("url")
response = f"{weekdayPhrase} En passande video är {videoPhrase}"
self.assertActionOutput(marvin_actions.marvinVideoOfToday, "dagens video", response)
self.assertActionSilent(marvin_actions.marvinVideoOfToday, "videoidag")
Expand Down

0 comments on commit 22c5e69

Please sign in to comment.