Skip to content

Commit

Permalink
- version 0.9.2.23
Browse files Browse the repository at this point in the history
- fixing issue #224 - crash when "artist", "album", "year" string in received data
  • Loading branch information
s-n-g committed Jan 11, 2024
1 parent 53a6674 commit 99f49e7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
<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>
<pre style="height: 200px;">

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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyradio"
version = "0.9.2.22"
version = "0.9.2.23"
authors = [
{ name="Ben Dowling", email="[email protected]" },
{ name="Spiros Georgaras", email="[email protected]" },
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyradio/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "")
Expand Down
52 changes: 29 additions & 23 deletions pyradio/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 99f49e7

Please sign in to comment.