Skip to content

Commit 862d018

Browse files
committed
- config.py: favorites will eliminate trailing commas
- player.py: fixing a crash in _calculate_buffer_size_in_kb
1 parent f303a69 commit 862d018

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

pyradio/config.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -4401,27 +4401,33 @@ def add(self, an_item):
44014401
updated = False
44024402
write_it = True
44034403

4404-
for i, item in enumerate(an_item):
4404+
this_item = an_item[:]
4405+
if this_item[Station.buffering] == '0@128':
4406+
this_item[Station.buffering] = ''
4407+
while this_item[-1] == '':
4408+
this_item.pop()
4409+
4410+
for i, item in enumerate(this_item):
44054411
if item is None:
44064412
if i in range(0, 2):
44074413
return -1, '___Station is invalid!___'
4408-
an_item[i] = ''
4409-
if an_item[0] == '' or \
4410-
an_item[1] == '':
4414+
this_item[i] = ''
4415+
if this_item[0] == '' or \
4416+
this_item[1] == '':
44114417
return -1, '___Station is invalid!___'
4412-
if isinstance(an_item[-1], dict):
4413-
an_item[-1] = an_item[-1]['image']
4418+
if isinstance(this_item[-1], dict):
4419+
this_item[-1] = this_item[-1]['image']
44144420
msg = None
44154421
for i, item in enumerate(items):
44164422
if item[1] == url:
4417-
if item == an_item:
4423+
if item == this_item:
44184424
return 1, '___Already in favorites!___'
4419-
items[i] = an_item
4425+
items[i] = this_item
44204426
msg = '___Station updated!___'
44214427
updated = True
44224428
break
44234429
if not updated:
4424-
items.append(an_item)
4430+
items.append(this_item)
44254431
updated = True
44264432
if updated:
44274433
ret = self._write_csv(items)
@@ -4474,8 +4480,11 @@ def _read_csv(self):
44744480

44754481
station_info = [
44764482
name, url, enc, {'image': icon} if icon else '',
4477-
profile, buffering, http, volume, referer
4483+
profile, '' if buffering == '0@128' else buffering,
4484+
http, volume, referer
44784485
]
4486+
while station_info[-1] == '':
4487+
station_info.pop()
44794488
items.append(station_info)
44804489
except (csv.Error, ValueError):
44814490
return []

pyradio/player.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,9 @@ def _buildStartOpts(self, streamName, streamUrl, station_force_http, streamRefer
28732873
else:
28742874
logger.info('No usable profile found')
28752875

2876+
# TODO: use pyradio-volume profile
2877+
if self.station_volume != -1:
2878+
logger.error('I need to use pyradio-volume profile')
28762879
# logger.error('\n\nself._recording = {}'.format(self._recording))
28772880
if self._recording > 0:
28782881
self.recording_filename = self.get_recording_filename(self.name, '.mkv')
@@ -3321,7 +3324,8 @@ def _calculate_buffer_size_in_kb(self, delay_seconds, bitrate_kbps=None):
33213324
''' return delay in KB for mplayer '''
33223325
if bitrate_kbps is None:
33233326
bitrate_kbps = 128
3324-
if '@' in delay_seconds:
3327+
if isinstance(delay_seconds, str) and \
3328+
'@' in delay_seconds:
33253329
sp = delay_seconds.split('@')
33263330
delay_seconds = sp[0]
33273331
bitrate_kbps = sp[1]
@@ -3415,6 +3419,9 @@ def _buildStartOpts(self, streamName, streamUrl, station_force_http, streamRefer
34153419
else:
34163420
logger.info('No usable profile found')
34173421

3422+
# TODO: use pyradio-volume profile
3423+
if self.station_volume != -1:
3424+
logger.error('I need to use pyradio-volume profile')
34183425

34193426
''' this will set the profile too '''
34203427
params = self.params[self.params[0]]

0 commit comments

Comments
 (0)