diff --git a/app/musicmuster.py b/app/musicmuster.py index fc457f9..23cb4fe 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -139,9 +139,8 @@ class Window(QMainWindow, Ui_MainWindow): self.btnFade.clicked.connect(self.fade) self.btnPlay.clicked.connect(self.play_next) self.btnSetNext.clicked.connect(self.set_next_track) - self.btnSongfacts.clicked.connect(self.songfacts_search) + self.btnSongInfo.clicked.connect(self.song_info_search) self.btnStop.clicked.connect(self.stop) - self.btnWikipedia.clicked.connect(self.wikipedia_search) self.spnVolume.valueChanged.connect(self.change_volume) self.tabPlaylist.currentChanged.connect(self.tab_change) @@ -407,11 +406,28 @@ class Window(QMainWindow, Ui_MainWindow): QMessageBox.warning(None, title, msg, buttons=QMessageBox.Cancel) - def songfacts_search(self): - "Open a browser window in Songfacts searching for selected title" + def song_info_search(self): + """ + Open browser tabs for Wikipedia and Songfacts, searching for + the first that exists of: + - selected track + - current track + - next track + """ title = self.visible_playlist().get_selected_title() + if not title: + if self.current_track: + title = self.current_track.title + if not title: + if self.next_track: + title = self.next_track.title if title: + # Wikipedia + str = urllib.parse.quote_plus(title) + url = f"https://www.wikipedia.org/w/index.php?search={str}" + webbrowser.open(url, new=2) + # Songfacts slug = slugify(title, replacements=([["'", ""]])) url = f"https://www.songfacts.com/search/songs/{slug}" webbrowser.open(url, new=2) @@ -570,15 +586,6 @@ class Window(QMainWindow, Ui_MainWindow): except AttributeError: self.hdrNextTrack.setText("") - def wikipedia_search(self): - "Open a browser window in Wikipedia searching for selected title" - - title = self.visible_playlist().get_selected_title() - if title: - str = urllib.parse.quote_plus(title) - url = f"https://www.wikipedia.org/w/index.php?search={str}" - webbrowser.open(url, new=2) - class DbDialog(QDialog): def __init__(self, parent=None): diff --git a/app/ui/main_window.ui b/app/ui/main_window.ui index 7a81bec..d93641f 100644 --- a/app/ui/main_window.ui +++ b/app/ui/main_window.ui @@ -260,6 +260,36 @@ border: 1px solid rgb(85, 87, 83); + + + + Qt::Horizontal + + + + 68 + 20 + + + + + + + + Song info + + + + :/icons/wikipedia:/icons/wikipedia + + + + 30 + 30 + + + + @@ -278,43 +308,13 @@ border: 1px solid rgb(85, 87, 83); - - - Qt::Horizontal - - - - 68 - 20 - - - - - - + - Wikipedia + Database - :/icons/wikipedia:/icons/wikipedia - - - - 30 - 30 - - - - - - - - Songfacts - - - - :/icons/songsearch:/icons/songsearch + :/icons/search_db:/icons/search_db @@ -368,13 +368,13 @@ border: 1px solid rgb(85, 87, 83); - + - Database + Add note - :/icons/search_db:/icons/search_db + :/icons/note:/icons/note @@ -401,23 +401,6 @@ border: 1px solid rgb(85, 87, 83); - - - - Add note - - - - :/icons/note:/icons/note - - - - 30 - 30 - - - - @@ -751,7 +734,7 @@ border: 1px solid rgb(85, 87, 83); 0 0 1164 - 18 + 26