diff --git a/src/gtk_mediathek_player/mediathek_request.py b/src/gtk_mediathek_player/mediathek_request.py
index 9aaaf16..c6da50a 100644
--- a/src/gtk_mediathek_player/mediathek_request.py
+++ b/src/gtk_mediathek_player/mediathek_request.py
@@ -75,6 +75,9 @@ class MediathekViewWebAnswer(object):
if self._timestamp is None:
return None
return dt.datetime.utcfromtimestamp(int(self._timestamp))
+
+ def get_duration(self):
+ return self._duration
class MediathekViewWebRequest(object):
diff --git a/src/gtk_mediathek_player/search_widget.py b/src/gtk_mediathek_player/search_widget.py
index eec422c..99754f3 100644
--- a/src/gtk_mediathek_player/search_widget.py
+++ b/src/gtk_mediathek_player/search_widget.py
@@ -76,6 +76,11 @@ class SearchWidget(Gtk.Box):
description = answer.get_description()
time = answer.get_timestamp()
time_str = "" if time is None else time.strftime('%Y-%m-%d %H:%M:%S')
+ duration = answer.get_duration()
+ if isinstance(duration, int):
+ duration = tools.seconds_to_timestring(duration)
+ else:
+ duration = None
if len(description) > 50:
description = description[:50] + "..."
@@ -88,24 +93,28 @@ class SearchWidget(Gtk.Box):
play_button.connect("clicked", on_click)
- title_label = Gtk.Label()
- title_label.set_markup(f"{title}")
- title_label.set_justify(Gtk.Justification.LEFT)
- title_label.set_xalign(0)
- description_label = Gtk.Label()
- description_label.set_markup(description)
- description_label.set_justify(Gtk.Justification.LEFT)
- description_label.set_xalign(0)
- time_label = Gtk.Label()
- time_label.set_markup(time_str)
- time_label.set_justify(Gtk.Justification.LEFT)
- time_label.set_xalign(0)
+ def create_label(markup_str: str) -> 'Gtk.Label':
+ label = Gtk.Label()
+ label.set_markup(markup_str)
+ label.set_justify(Gtk.Justification.LEFT)
+ label.set_xalign(0)
+
+ return label
+
+ title_label = create_label(f"{title}")
+ description_label = create_label(description)
+ time_label = create_label(f"📅 {time_str}")
+
text_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
text_box.pack_start(title_label, False, False, 0)
text_box.pack_start(description_label, False, False, 0)
text_box.pack_start(time_label, False, False, 0)
+ if duration is not None:
+ duration_label = create_label(f"⌚ {duration}")
+ text_box.pack_start(duration_label, False, False, 0)
+
card_content = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
card_content.pack_start(play_button, False, False, 10)
diff --git a/src/gtk_mediathek_player/tools.py b/src/gtk_mediathek_player/tools.py
index a7c3303..19c7a5a 100644
--- a/src/gtk_mediathek_player/tools.py
+++ b/src/gtk_mediathek_player/tools.py
@@ -17,3 +17,11 @@ def new_radio_button_with_icon(freedesktop_icon: str,
icon = Gtk.Image.new_from_icon_name(freedesktop_icon, Gtk.IconSize.LARGE_TOOLBAR)
button.props.image = icon
return button
+
+
+def seconds_to_timestring(seconds: int) -> str:
+ hours = seconds // 3600
+ minutes = (seconds % 3600) // 60
+ seconds = seconds % 60
+
+ return f"{hours:>02}:{minutes:>02}:{seconds:>02}"