[gnome-software/1843-gs-screenshot-support-videos-as-screenshot: 32/33] gs-appstream: Read also 'video' screenshots
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1843-gs-screenshot-support-videos-as-screenshot: 32/33] gs-appstream: Read also 'video' screenshots
- Date: Tue, 16 Aug 2022 15:03:10 +0000 (UTC)
commit ecaad3f64aadddbef3d687a6c64561e282c535c8
Author: Milan Crha <mcrha redhat com>
Date: Tue Aug 9 15:54:20 2022 +0200
gs-appstream: Read also 'video' screenshots
lib/gs-appstream.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/lib/gs-appstream.c b/lib/gs-appstream.c
index 4e6a56afd..193a3dbfb 100644
--- a/lib/gs-appstream.c
+++ b/lib/gs-appstream.c
@@ -424,6 +424,39 @@ gs_appstream_refine_add_images (GsApp *app,
return TRUE;
}
+static gboolean
+gs_appstream_refine_add_videos (GsApp *app,
+ AsScreenshot *ss,
+ XbNode *screenshot,
+ gboolean *out_any_added,
+ GError **error)
+{
+ g_autoptr(GError) error_local = NULL;
+ g_autoptr(GPtrArray) videos = NULL;
+
+ videos = xb_node_query (screenshot, "video", 0, &error_local);
+ if (videos == NULL) {
+ if (g_error_matches (error_local, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ return TRUE;
+ g_propagate_error (error, g_steal_pointer (&error_local));
+ return FALSE;
+ }
+ for (guint i = 0; i < videos->len; i++) {
+ XbNode *video = g_ptr_array_index (videos, i);
+ g_autoptr(AsVideo) vid = as_video_new ();
+ as_video_set_height (vid, xb_node_get_attr_as_uint (video, "height"));
+ as_video_set_width (vid, xb_node_get_attr_as_uint (video, "width"));
+ as_video_set_codec_kind (vid, as_video_codec_kind_from_string (xb_node_get_attr (video,
"codec")));
+ as_video_set_container_kind (vid, as_video_container_kind_from_string (xb_node_get_attr
(video, "container")));
+ as_video_set_url (vid, xb_node_get_text (video));
+ as_screenshot_add_video (ss, vid);
+ }
+
+ *out_any_added = *out_any_added || videos->len > 0;
+
+ return TRUE;
+}
+
static gboolean
gs_appstream_refine_add_screenshots (GsApp *app, XbNode *component, GError **error)
{
@@ -442,7 +475,8 @@ gs_appstream_refine_add_screenshots (GsApp *app, XbNode *component, GError **err
XbNode *screenshot = g_ptr_array_index (screenshots, i);
g_autoptr(AsScreenshot) ss = as_screenshot_new ();
gboolean any_added = FALSE;
- if (!gs_appstream_refine_add_images (app, ss, screenshot, &any_added, error))
+ if (!gs_appstream_refine_add_images (app, ss, screenshot, &any_added, error) ||
+ !gs_appstream_refine_add_videos (app, ss, screenshot, &any_added, error))
return FALSE;
if (any_added)
gs_app_add_screenshot (app, ss);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]