diff --git a/Changelog b/Changelog index b1e941fd..f59f854a 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +2024-01-11 s-n-g + * version 0.9.2.23 + * fixing issue #224 - crash when "artist", "album", "year" + string in received data + 2024-01-05 s-n-g * version 0.9.2.22 * fixing bug #222 - Appending a radio station with A in a playlist diff --git a/docs/index.html b/docs/index.html index 5f8093e7..24eea43f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -176,6 +176,11 @@
+2024-01-11 s-n-g + * version 0.9.2.23 + * fixing issue #224 - crash when "artist", "album", "year" + string in received data + 2024-01-05 s-n-g * version 0.9.2.22 * fixing bug #222 - Appending a radio station with A in a playlist diff --git a/pyproject.toml b/pyproject.toml index c42cfed8..5a885df7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyradio" -version = "0.9.2.22" +version = "0.9.2.23" authors = [ { name="Ben Dowling", email="ben.m.dowling@gmail.com" }, { name="Spiros Georgaras", email="sng@hellug.gr" }, diff --git a/pyradio/__init__.py b/pyradio/__init__.py index a62da435..6fbc6e40 100644 --- a/pyradio/__init__.py +++ b/pyradio/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- " pyradio -- Console radio player. " -version_info = (0, 9, 2, 22) +version_info = (0, 9, 2, 23) # Set it to True if new stations have been # added to the package's stations.csv diff --git a/pyradio/install.py b/pyradio/install.py index 35b83c6e..432f35f1 100644 --- a/pyradio/install.py +++ b/pyradio/install.py @@ -15,7 +15,7 @@ ''' This is PyRadio version this install.py was released for ''' -PyRadioInstallPyReleaseVersion = '0.9.2.22' +PyRadioInstallPyReleaseVersion = '0.9.2.23' import locale locale.setlocale(locale.LC_ALL, "") diff --git a/pyradio/player.py b/pyradio/player.py index 7f7df0f0..fcd54ddc 100644 --- a/pyradio/player.py +++ b/pyradio/player.py @@ -1646,6 +1646,7 @@ def _get_mpv_metadata(self, *args): icy-br : Station bitrate audio_format : XXXXHx stereo/mono 1/2ch format artist, title : Artist and Title of song (vorbis stations) + album, year : Album and Year of song (vorbis stations) ''' a_data = args[0] @@ -1663,8 +1664,14 @@ def _get_mpv_metadata(self, *args): if logger.isEnabledFor(logging.DEBUG): logger.debug('Icy-Title = " - ", not displaying...') else: - if b'artist' in a_data: - artist = a_data.split(b'"artist":"')[1].split(b'"}')[0].split(b'","')[0] + if b'"artist":"' in a_data: + try: + artist = a_data.split(b'"artist":"')[1].split(b'"}')[0].split(b'","')[0] + except IndexError: + artist = None + else: + artist = None + if artist: try: self.oldUserInput['Title'] = 'Title: ' + artist.decode(self._station_encoding, 'replace') + ' - ' + title.decode(self._station_encoding, 'replace') except: @@ -1674,27 +1681,26 @@ def _get_mpv_metadata(self, *args): self.oldUserInput['Title'] = 'Title: ' + title.decode(self._station_encoding, 'replace') except: self.oldUserInput['Title'] = 'Title: ' + title.decode('utf-8', 'replace') - string_to_show = self.title_prefix + self.oldUserInput['Title'] - #logger.critical(string_to_show) - if stop(): - return False - self.outputStream.write(msg=string_to_show, counter='') - if not self.playback_is_on: - if stop(): - return False - return self._set_mpv_playback_is_on(stop, enable_crash_detection_function) - else: - if (logger.isEnabledFor(logging.INFO)): - logger.info('Icy-Title is NOT valid') - self.buffering = False - with self.buffering_lock: - self.buffering_change_function() - title = 'Playing: ' + self.name - string_to_show = self.title_prefix + title - if stop(): - return False - self.outputStream.write(msg=string_to_show, counter='') - self.oldUserInput['Title'] = title + if b'"album":' in a_data: + try: + album = a_data.split(b'"album":"')[1].split(b'"}')[0].split(b'","')[0] + if album: + if b'"year":' in a_data: + year = a_data.split(b'"year":"')[1].split(b'"}')[0].split(b'","')[0] + else: + year = None + if year: + try: + self.oldUserInput['Title'] += ' [' + album.decode(self._station_encoding, 'replace') + ', ' + year.decode('utf-8', 'replace') + ']' + except: + self.oldUserInput['Title'] += ' [' + album.decode('utf-8', 'replace') + ', ' + year.decode('utf-8', 'replace') + ']' + else: + try: + self.oldUserInput['Title'] += ' [' + album.decode(self._station_encoding, 'replace') + ']' + except: + self.oldUserInput['Title'] += ' [' + album.decode('utf-8', 'replace') + ']' + except IndexError: + pass # logger.info('DE a_data {}'.format(a_data)) if b'icy-br' in a_data: