Skip to content

Commit 99f49e7

Browse files
committed
- version 0.9.2.23
- fixing issue #224 - crash when "artist", "album", "year" string in received data
1 parent 53a6674 commit 99f49e7

File tree

6 files changed

+42
-26
lines changed

6 files changed

+42
-26
lines changed

Changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2024-01-11 s-n-g
2+
* version 0.9.2.23
3+
* fixing issue #224 - crash when "artist", "album", "year"
4+
string in received data
5+
16
2024-01-05 s-n-g
27
* version 0.9.2.22
38
* fixing bug #222 - Appending a radio station with A in a playlist

docs/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
176176
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
177177
<pre style="height: 200px;">
178178

179+
2024-01-11 s-n-g
180+
* version 0.9.2.23
181+
* fixing issue #224 - crash when "artist", "album", "year"
182+
string in received data
183+
179184
2024-01-05 s-n-g
180185
* version 0.9.2.22
181186
* fixing bug #222 - Appending a radio station with A in a playlist

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "pyradio"
3-
version = "0.9.2.22"
3+
version = "0.9.2.23"
44
authors = [
55
{ name="Ben Dowling", email="[email protected]" },
66
{ name="Spiros Georgaras", email="[email protected]" },

pyradio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
" pyradio -- Console radio player. "
33

4-
version_info = (0, 9, 2, 22)
4+
version_info = (0, 9, 2, 23)
55

66
# Set it to True if new stations have been
77
# added to the package's stations.csv

pyradio/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
''' This is PyRadio version this
1616
install.py was released for
1717
'''
18-
PyRadioInstallPyReleaseVersion = '0.9.2.22'
18+
PyRadioInstallPyReleaseVersion = '0.9.2.23'
1919

2020
import locale
2121
locale.setlocale(locale.LC_ALL, "")

pyradio/player.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ def _get_mpv_metadata(self, *args):
16461646
icy-br : Station bitrate
16471647
audio_format : XXXXHx stereo/mono 1/2ch format
16481648
artist, title : Artist and Title of song (vorbis stations)
1649+
album, year : Album and Year of song (vorbis stations)
16491650
'''
16501651

16511652
a_data = args[0]
@@ -1663,8 +1664,14 @@ def _get_mpv_metadata(self, *args):
16631664
if logger.isEnabledFor(logging.DEBUG):
16641665
logger.debug('Icy-Title = " - ", not displaying...')
16651666
else:
1666-
if b'artist' in a_data:
1667-
artist = a_data.split(b'"artist":"')[1].split(b'"}')[0].split(b'","')[0]
1667+
if b'"artist":"' in a_data:
1668+
try:
1669+
artist = a_data.split(b'"artist":"')[1].split(b'"}')[0].split(b'","')[0]
1670+
except IndexError:
1671+
artist = None
1672+
else:
1673+
artist = None
1674+
if artist:
16681675
try:
16691676
self.oldUserInput['Title'] = 'Title: ' + artist.decode(self._station_encoding, 'replace') + ' - ' + title.decode(self._station_encoding, 'replace')
16701677
except:
@@ -1674,27 +1681,26 @@ def _get_mpv_metadata(self, *args):
16741681
self.oldUserInput['Title'] = 'Title: ' + title.decode(self._station_encoding, 'replace')
16751682
except:
16761683
self.oldUserInput['Title'] = 'Title: ' + title.decode('utf-8', 'replace')
1677-
string_to_show = self.title_prefix + self.oldUserInput['Title']
1678-
#logger.critical(string_to_show)
1679-
if stop():
1680-
return False
1681-
self.outputStream.write(msg=string_to_show, counter='')
1682-
if not self.playback_is_on:
1683-
if stop():
1684-
return False
1685-
return self._set_mpv_playback_is_on(stop, enable_crash_detection_function)
1686-
else:
1687-
if (logger.isEnabledFor(logging.INFO)):
1688-
logger.info('Icy-Title is NOT valid')
1689-
self.buffering = False
1690-
with self.buffering_lock:
1691-
self.buffering_change_function()
1692-
title = 'Playing: ' + self.name
1693-
string_to_show = self.title_prefix + title
1694-
if stop():
1695-
return False
1696-
self.outputStream.write(msg=string_to_show, counter='')
1697-
self.oldUserInput['Title'] = title
1684+
if b'"album":' in a_data:
1685+
try:
1686+
album = a_data.split(b'"album":"')[1].split(b'"}')[0].split(b'","')[0]
1687+
if album:
1688+
if b'"year":' in a_data:
1689+
year = a_data.split(b'"year":"')[1].split(b'"}')[0].split(b'","')[0]
1690+
else:
1691+
year = None
1692+
if year:
1693+
try:
1694+
self.oldUserInput['Title'] += ' [' + album.decode(self._station_encoding, 'replace') + ', ' + year.decode('utf-8', 'replace') + ']'
1695+
except:
1696+
self.oldUserInput['Title'] += ' [' + album.decode('utf-8', 'replace') + ', ' + year.decode('utf-8', 'replace') + ']'
1697+
else:
1698+
try:
1699+
self.oldUserInput['Title'] += ' [' + album.decode(self._station_encoding, 'replace') + ']'
1700+
except:
1701+
self.oldUserInput['Title'] += ' [' + album.decode('utf-8', 'replace') + ']'
1702+
except IndexError:
1703+
pass
16981704

16991705
# logger.info('DE a_data {}'.format(a_data))
17001706
if b'icy-br' in a_data:

0 commit comments

Comments
 (0)