Skip to content

Commit 058bbe3

Browse files
committed
- PyRadio will not crush with mpv 0.30.0
Changing mpv's volume is still possible, but no info will be presented on the Status Bar. Furthermore, saving mpv's volume will not be possible ( mpv issue #7153: mpv-player/mpv#7153 ) - Keep working on www.radio-browser.info integration
1 parent bba6c6e commit 058bbe3

File tree

6 files changed

+28
-19
lines changed

6 files changed

+28
-19
lines changed

Changelog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2019-11-15
2+
* PyRadio will not crush with mpv 0.30.0
3+
Changing mpv's volume is still possible, but no info will be
4+
presented on the Status Bar.
5+
Furthermore, saving mpv's volume will not be possible
6+
( mpv issue #7153: https://github.com/mpv-player/mpv/issues/7153 )
7+
18
2019-11-12
29
* When default played is changed in the config, a message to restart
310
the application is presented to the user

pyradio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 4)
3+
version_info = (0, 8, 5)
44

55
__version__ = version = '.'.join(map(str, version_info))
66
__project__ = __name__

pyradio/browser.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# http://www.radio-browser.info/webservice#Advanced_station_search
33
import json
4-
import requests
4+
try:
5+
import requests
6+
except ImportError:
7+
pass
58
import threading
69
import logging
710
from .widechar import cjklen, PY3

pyradio/log.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ def write(self, msg, thread_lock=None, help_msg=False):
3535
self.msg = msg.strip()[0: self.width].replace("\r", "").replace("\n", "")
3636
self.cursesScreen.addstr(0, 1, self.msg)
3737
except:
38-
logger.error('DE **** status update python 2 ****')
3938
try:
4039
self.msg = msg.encode('utf-8', 'replace').strip()[0: self.width].replace("\r", "").replace("\n", "")
4140
self.cursesScreen.addstr(0, 1, self.msg)
4241
except:
43-
logger.error('DE **** status update ERROR ****')
44-
pass
42+
if logger.isEnabledFor(logging.ERROR):
43+
logger.error('Cannot update the Status Bar...')
4544
if logger.isEnabledFor(logging.DEBUG):
46-
logger.debug('Status: "{}"'.format(self.msg))
45+
try:
46+
logger.debug('Status: "{}"'.format(msg))
47+
except:
48+
pass
4749
self.cursesScreen.refresh()
4850
if thread_lock is not None:
4951
thread_lock.release()

pyradio/player.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,21 @@ def _do_save_volume(self, config_string):
6666
return 'Volume not saved!!!'
6767
ret_strings = ('Volume: already saved...',
6868
'Volume: {}% saved',
69-
'Volume: {}% NOT saved (Error writing file)')
69+
'Volume: {}% NOT saved (Error writing file)',
70+
'Volume: NOT saved!')
7071
log_strings = ('Volume is -1. Aborting...',
7172
'Volume is {}%. Saving...',
72-
'Error saving profile "{}"')
73+
'Error saving profile "{}"',
74+
'Error saving volume...')
7375
if self.volume == -1:
7476
""" inform no change """
7577
if (logger.isEnabledFor(logging.DEBUG)):
7678
logger.debug(log_strings[0])
7779
return ret_strings[0]
80+
elif self.volume == -2:
81+
if (logger.isEnabledFor(logging.DEBUG)):
82+
logger.debug(log_strings[3])
83+
return ret_strings[3]
7884
else:
7985
""" change volume """
8086
if (logger.isEnabledFor(logging.DEBUG)):
@@ -197,7 +203,6 @@ def updateStatus(self, *args):
197203
subsystemOut = subsystemOutRaw.decode("utf-8", "replace")
198204
if subsystemOut == '':
199205
break
200-
logger.error('DE subsystemOut = "{}"'.format(subsystemOut))
201206
if not self._is_accepted_input(subsystemOut):
202207
continue
203208
subsystemOut = subsystemOut.strip()
@@ -347,14 +352,10 @@ def play(self, name, streamUrl, encoding = ''):
347352
logger.error("playback detection thread start failed")
348353
if logger.isEnabledFor(logging.INFO):
349354
logger.info("Player started")
350-
if self.process and self.PLAYER_CMD == 'mpv':
351-
self._sendCommand('{ "command": ["observe_property", 1, "volume"] }')
352355

353356
def _sendCommand(self, command):
354357
""" send keystroke command to player """
355358

356-
logger.error('DE command to execute: "{}"'.format(command))
357-
358359
if(self.process is not None):
359360
try:
360361
if logger.isEnabledFor(logging.DEBUG):
@@ -433,7 +434,6 @@ def _get_volume(self):
433434
def volumeUp(self):
434435
""" increase volume """
435436
if self.muted is not True:
436-
logger.error('DE self._volumeUp')
437437
self._volume_up()
438438

439439
def _volume_up(self):
@@ -502,6 +502,8 @@ class MpvPlayer(Player):
502502
def save_volume(self):
503503
""" Saving Volume in Windows does not work;
504504
Profiles not supported... """
505+
if int(self.volume) > 999:
506+
self.volume = -2
505507
return self._do_save_volume("[pyradio]\nvolume={}\n")
506508

507509
def _configHasProfile(self):
@@ -572,9 +574,7 @@ def _stop(self):
572574

573575
def _volume_up(self):
574576
""" increase mpv's volume """
575-
logger.error('DE mpv volume up')
576577
os.system("echo 'cycle volume' | socat - " + self.mpvsocket + " 2>/dev/null");
577-
os.system("echo '{ \"command\": [\"get_property\", \"volume\"] }' | socat - " + self.mpvsocket + " 2>/dev/null");
578578

579579
def _volume_down(self):
580580
""" decrease mpv's volume """

pyradio/radio.py

-3
Original file line numberDiff line numberDiff line change
@@ -3305,14 +3305,11 @@ def keypress(self, char):
33053305
self.refreshBody()
33063306

33073307
def _volume_up(self):
3308-
logger.error('DE entering radio._volume_up')
33093308
self.jumpnr = ''
33103309
self._random_requested = False
33113310
if self.player.isPlaying():
3312-
logger.error('DE isPlaying radio._volume_up')
33133311
if self.player.playback_is_on:
33143312
self.player.volumeUp()
3315-
logger.error('DE playback_is_on radio._volume_up')
33163313
else:
33173314
if self.ws.operation_mode in self.ws.PASSIVE_WINDOWS:
33183315
self.ws.close_window()

0 commit comments

Comments
 (0)