[7cb676d57114874e00c536916e6dcad2a5d3cb8c9a5abc06335df359cd9a6ef9/wip/mschraal/utils-media-title-except: 1/2] utils: Catch file info query error
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [7cb676d57114874e00c536916e6dcad2a5d3cb8c9a5abc06335df359cd9a6ef9/wip/mschraal/utils-media-title-except: 1/2] utils: Catch file info query error
- Date: Tue, 7 Jul 2020 22:11:21 +0000 (UTC)
commit f59a8e9bf7b37bd6b9eab15111efc87c3312b67c
Author: Marinus Schraal <mschraal gnome org>
Date: Wed Jul 8 00:07:13 2020 +0200
utils: Catch file info query error
Related: #401
gnomemusic/utils.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/utils.py b/gnomemusic/utils.py
index 1e265a0b..5817f240 100644
--- a/gnomemusic/utils.py
+++ b/gnomemusic/utils.py
@@ -27,9 +27,11 @@ import re
import unicodedata
from gettext import gettext as _
-from gi.repository import Gio
+from gi.repository import Gio, GLib
from gi._gi import pygobject_new_full
+from gnomemusic.musiclogger import MusicLogger
+
class ArtSize(Enum):
"""Enum for icon sizes"""
@@ -116,8 +118,13 @@ def get_media_title(item):
if url is None:
return "NO URL"
file_ = Gio.File.new_for_uri(url)
- fileinfo = file_.query_info(
- "standard::display-name", Gio.FileQueryInfoFlags.NONE, None)
+ try:
+ fileinfo = file_.query_info(
+ "standard::display-name", Gio.FileQueryInfoFlags.NONE, None)
+ except GLib.Error as error:
+ MusicLogger().warning(
+ "Error: {}, {}".format(error.domain, error.message))
+ return "NO URL"
title = fileinfo.get_display_name()
title = title.replace("_", " ")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]