Skip to content

Commit

Permalink
- version 0.8.9.13 (0.9-beta10)
Browse files Browse the repository at this point in the history
- fixing #148
- fixing a potential psutil crash
  • Loading branch information
s-n-g committed Feb 13, 2022
1 parent 6bafa23 commit b213f48
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 15 deletions.
5 changes: 5 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2022-0213 s-n-g
* version 0.8.9.13 (0.9-beta10)
* fixing #148
* fixing a potential psutil crash

2022-01-26 s-n-g
* version 0.8.9.12 (0.9-beta9)
* Fixing install.py
Expand Down
5 changes: 5 additions & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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></style></h2>
<pre style="height: 200px;">

2022-0213 s-n-g
* version 0.8.9.13 (0.9-beta10)
* fixing #148
* fixing a potential psutil crash

2022-01-26 s-n-g
* version 0.8.9.12 (0.9-beta9)
* Fixing install.py
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" pyradio -- Console radio player. "

version_info = (0, 8, 9, 12)
version_info = (0, 8, 9, 13)

# Application state:
# New stable version: ''
Expand Down
68 changes: 54 additions & 14 deletions pyradio/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
pass
if platform.startswith('win'):
import win32pipe, win32file, pywintypes

try:
from urllib import unquote
except:
from urllib.parse import unquote
from .cjkwrap import wrap
from .encodings import get_encodings

''' In case of import from win.py '''
try:
from .cjkwrap import wrap
except:
pass
''' In case of import from win.py '''
try:
from .encodings import get_encodings
except:
pass

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -120,6 +128,25 @@ def find_vlc_on_windows(config_dir=None):
# result.append(os.path.join(root, name))
#return result

def find_mpv_on_windows():
for a_path in (
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mpv', 'mpv.exe'),
os.path.join(os.getenv('APPDATA'), 'mpv', 'mpv.exe'),
os.path.join(expanduser("~"), 'mpv', 'mpv.exe')
):
if os.path.exists(a_path):
return a_path
return 'mpv'

def find_mplayer_on_windows():
for a_path in (
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mplayer', 'mplayer.exe'),
os.path.join(os.getenv('APPDATA'), 'mplayer', 'mplayer.exe'),
os.path.join(expanduser("~"), 'mplayer', 'mplayer.exe')
):
if os.path.exists(a_path):
return a_path
return 'mplayer'

def info_dict_to_list(info, fix_highlight, max_width):
max_len = 0
Expand Down Expand Up @@ -620,7 +647,7 @@ def updateStatus(self, *args):
self.GET_AUDIO_CODEC_NAME):
response = self._send_mpv_command( a_cmd, return_response=True)
if response:
self._get_mpv_metadata(response, lambda: False)
self._get_mpv_metadata(response, lambda: False, enable_crash_detection_function)
self.info_display_handler()
else:
if logger.isEnabledFor(logging.INFO):
Expand Down Expand Up @@ -787,7 +814,7 @@ def updateMPVStatus(self, *args):
if a_data:
all_data = a_data.split(b'\n')
for n in all_data:
if self._get_mpv_metadata(n, stop):
if self._get_mpv_metadata(n, stop, enable_crash_detection_function):
self._request_mpv_info_data(sock)
else:
try:
Expand Down Expand Up @@ -1094,7 +1121,7 @@ def _get_mpv_metadata(self, *args):

a_data = args[0]
stop = args[1]

enable_crash_detection_function = [2]
if b'"icy-title":"' in a_data:
if version_info > (3, 0):
title = a_data.split(b'"icy-title":"')[1].split(b'"}')[0]
Expand Down Expand Up @@ -1421,18 +1448,21 @@ def _kill_process_tree(self, pid):
if logger.isEnabledFor(logging.DEBUG):
logger.debug('PID {} does not exist...'.format(pid))
return
children = parent.children(recursive=True)
try:
os.kill(parent.pid, 9)
except:
pass
for child in children:
children = parent.children(recursive=True)
try:
os.kill(child.pid, 9)
os.kill(parent.pid, 9)
except:
pass
if logger.isEnabledFor(logging.DEBUG):
logger.debug('PID {} (and its children) killed...'.format(pid))
for child in children:
try:
os.kill(child.pid, 9)
except:
pass
if logger.isEnabledFor(logging.DEBUG):
logger.debug('PID {} (and its children) killed...'.format(pid))
except psutil.NoSuchProcess:
pass

def _killall(self, name):
if name:
Expand Down Expand Up @@ -1524,6 +1554,11 @@ class MpvPlayer(Player):

PLAYER_NAME = 'mpv'
PLAYER_CMD = 'mpv'
WIN = False
if platform.startswith('win'):
WIN = True
if WIN:
PLAYER_CMD = find_mpv_on_windows()
NEW_PROFILE_STRING = 'volume=50\n\n'
if pywhich(PLAYER_CMD):
executable_found = True
Expand Down Expand Up @@ -1951,6 +1986,11 @@ class MpPlayer(Player):

PLAYER_NAME = 'mplayer'
PLAYER_CMD = 'mplayer'
WIN = False
if platform.startswith('win'):
WIN = True
if WIN:
PLAYER_CMD = find_mplayer_on_windows()
NEW_PROFILE_STRING = 'softvol=1\nsoftvol-max=300\nvolstep=1\nvolume=50\n\n'
if pywhich(PLAYER_CMD):
executable_found = True
Expand Down

0 comments on commit b213f48

Please sign in to comment.