From 72d7753e02b44bd4f37c85484f73d98e780fc3b2 Mon Sep 17 00:00:00 2001 From: Chris Hylen Date: Thu, 3 Mar 2022 08:55:54 -0600 Subject: [PATCH] fix #245 part 1 default save location to common path between all files --- plugins/playlist/playlist.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/playlist/playlist.py b/plugins/playlist/playlist.py index 4f69245a..ae303394 100644 --- a/plugins/playlist/playlist.py +++ b/plugins/playlist/playlist.py @@ -12,7 +12,7 @@ # GNU General Public License for more details. PLUGIN_NAME = "Generate M3U playlist" -PLUGIN_AUTHOR = "Francis Chin, Sambhav Kothari" +PLUGIN_AUTHOR = "Francis Chin, Sambhav Kothari, Chris Hylen" PLUGIN_DESCRIPTION = """Generate an Extended M3U playlist (.m3u8 file, UTF8 encoded text). Relative pathnames are used where audio files are in the same directory as the playlist, otherwise absolute (full) pathnames are used.""" @@ -76,9 +76,15 @@ class GeneratePlaylist(BaseAction): NAME = "Generate &Playlist..." def callback(self, objs): - current_directory = (self.config.persist["current_directory"] - or QtCore.QDir.homePath()) - current_directory = find_existing_path(current_directory) + # Find common path of all files to default where to save playlist + files = [] + for album in objs: + for track in album.tracks: + if track.linked_files: + files.append(track.linked_files[0].filename) + + current_directory = os.path.commonpath(files) + # Default playlist filename set as "%albumartist% - %album%.m3u8", # except where "Various Artists" is suppressed if _debug_level > 1: