add duration
This commit is contained in:
parent
b5ef96aedc
commit
d777c3ecbe
@ -76,6 +76,9 @@ class MediathekViewWebAnswer(object):
|
|||||||
return None
|
return None
|
||||||
return dt.datetime.utcfromtimestamp(int(self._timestamp))
|
return dt.datetime.utcfromtimestamp(int(self._timestamp))
|
||||||
|
|
||||||
|
def get_duration(self):
|
||||||
|
return self._duration
|
||||||
|
|
||||||
|
|
||||||
class MediathekViewWebRequest(object):
|
class MediathekViewWebRequest(object):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -76,6 +76,11 @@ class SearchWidget(Gtk.Box):
|
|||||||
description = answer.get_description()
|
description = answer.get_description()
|
||||||
time = answer.get_timestamp()
|
time = answer.get_timestamp()
|
||||||
time_str = "" if time is None else time.strftime('%Y-%m-%d %H:%M:%S')
|
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:
|
if len(description) > 50:
|
||||||
description = description[:50] + "..."
|
description = description[:50] + "..."
|
||||||
@ -88,24 +93,28 @@ class SearchWidget(Gtk.Box):
|
|||||||
|
|
||||||
play_button.connect("clicked", on_click)
|
play_button.connect("clicked", on_click)
|
||||||
|
|
||||||
title_label = Gtk.Label()
|
def create_label(markup_str: str) -> 'Gtk.Label':
|
||||||
title_label.set_markup(f"<b>{title}</b>")
|
label = Gtk.Label()
|
||||||
title_label.set_justify(Gtk.Justification.LEFT)
|
label.set_markup(markup_str)
|
||||||
title_label.set_xalign(0)
|
label.set_justify(Gtk.Justification.LEFT)
|
||||||
description_label = Gtk.Label()
|
label.set_xalign(0)
|
||||||
description_label.set_markup(description)
|
|
||||||
description_label.set_justify(Gtk.Justification.LEFT)
|
return label
|
||||||
description_label.set_xalign(0)
|
|
||||||
time_label = Gtk.Label()
|
title_label = create_label(f"<b>{title}</b>")
|
||||||
time_label.set_markup(time_str)
|
description_label = create_label(description)
|
||||||
time_label.set_justify(Gtk.Justification.LEFT)
|
time_label = create_label(f"📅 {time_str}")
|
||||||
time_label.set_xalign(0)
|
|
||||||
|
|
||||||
text_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
text_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
|
||||||
text_box.pack_start(title_label, False, False, 0)
|
text_box.pack_start(title_label, False, False, 0)
|
||||||
text_box.pack_start(description_label, False, False, 0)
|
text_box.pack_start(description_label, False, False, 0)
|
||||||
text_box.pack_start(time_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 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
card_content.pack_start(play_button, False, False, 10)
|
card_content.pack_start(play_button, False, False, 10)
|
||||||
|
@ -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)
|
icon = Gtk.Image.new_from_icon_name(freedesktop_icon, Gtk.IconSize.LARGE_TOOLBAR)
|
||||||
button.props.image = icon
|
button.props.image = icon
|
||||||
return button
|
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}"
|
||||||
|
Loading…
Reference in New Issue
Block a user