Add printPodcastGroups method

This commit is contained in:
Wiktor Zykubek 2023-06-18 16:37:12 +02:00
parent e01edba7f3
commit d02f7302a2
No known key found for this signature in database
GPG Key ID: 0DAA9DC01449FCA2

View File

@ -30,11 +30,15 @@ class MainWindow(QMainWindow):
self.__stations = self.getData( self.__stations = self.getData(
"https://open.fm/radio/api/v2/ofm/stations_slug.json" "https://open.fm/radio/api/v2/ofm/stations_slug.json"
) )
self.__podcasts = self.getData(
"https://open.fm/api/podcasts/categories"
)
self.__player = QMediaPlayer() self.__player = QMediaPlayer()
self.__audio = QAudioOutput() self.__audio = QAudioOutput()
self.__player.setAudioOutput(self.__audio) self.__player.setAudioOutput(self.__audio)
self.setVolume(DEFAULT_VOLUME) self.setVolume(DEFAULT_VOLUME)
self.printRadioGroups() self.printRadioGroups()
self.printPodcastGroups()
self.ui.radioGroupsListWidget.itemClicked.connect(self.printRadioStations) self.ui.radioGroupsListWidget.itemClicked.connect(self.printRadioStations)
self.ui.stationsListWidget.itemClicked.connect(self.playRadio) self.ui.stationsListWidget.itemClicked.connect(self.playRadio)
@ -62,6 +66,12 @@ class MainWindow(QMainWindow):
[e["name"] for e in self.__stations["groups"]] [e["name"] for e in self.__stations["groups"]]
) )
def printPodcastGroups(self) -> None:
"""Print groups (categories) in podcastGroupsListWidget."""
self.ui.podcastGroupsListWidget.addItems(
[e["name"] for e in self.__podcasts]
)
def printRadioStations(self) -> None: def printRadioStations(self) -> None:
"""Print stations (channels) in stationsListWidget.""" """Print stations (channels) in stationsListWidget."""
group = self.ui.radioGroupsListWidget.selectedItems()[0].text() group = self.ui.radioGroupsListWidget.selectedItems()[0].text()