From df371c698add3598a4e2b94f6bf3a1f939706fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 7 Jun 2024 10:37:24 +0200 Subject: [PATCH] clapper-app: Fix opened file content type detection Fixes issues with detecting whether file has one of supported subtitles mime types --- src/bin/clapper-app/clapper-app-utils.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-utils.c b/src/bin/clapper-app/clapper-app-utils.c index 6852d152..6816ea2c 100644 --- a/src/bin/clapper-app/clapper-app-utils.c +++ b/src/bin/clapper-app/clapper-app-utils.c @@ -86,9 +86,21 @@ clapper_app_utils_is_subtitles_file (GFile *file) G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL))) { - is_subs = g_strv_contains ( + const gchar *content_type = NULL; + + if (g_file_info_has_attribute (info, + G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE)) { + content_type = g_file_info_get_content_type (info); + } else if (g_file_info_has_attribute (info, + G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)) { + content_type = g_file_info_get_attribute_string (info, + G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE); + } + + is_subs = (content_type && g_strv_contains ( clapper_app_utils_get_subtitles_mime_types (), - g_file_info_get_content_type (info)); + content_type)); + g_object_unref (info); }