From 57b1170b1603c814af6bdb9906581912b6e7c29b Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Mon, 16 Sep 2024 20:45:35 +0200 Subject: browse: Improve handling of browse_filesystem Stop trying to launch the browser if we do not have a path. Redirect stderr and stdout to /dev/null to avoid spurious messages in the terminal. --- beetsplug/browse.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'beetsplug') diff --git a/beetsplug/browse.py b/beetsplug/browse.py index bb06a91..c1d37c7 100644 --- a/beetsplug/browse.py +++ b/beetsplug/browse.py @@ -70,8 +70,17 @@ class BrowseCommand(Subcommand): webbrowser.open(MUSICBRAINZ_LOOKUP + mbid) def browse_filesystem(self, item, _): + path = item.get("path") + + if not path: + return + try: - subprocess.Popen(self.explorer.split(" ") + [item.get("path")]) + subprocess.Popen( + self.explorer.split() + [path.decode()], + stderr=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + ) except OSError as err: raise UserError(err) from err -- cgit v1.2.3-2-gb3c3