Skip to content

Commit 1b20bf8

Browse files
committed
- Version 0.8.8.1
- Fixing vlc terminataion on Windows
1 parent fe41bfa commit 1b20bf8

File tree

5 files changed

+38
-21
lines changed

5 files changed

+38
-21
lines changed

pyradio.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH PYRADIO 1 "November 2020"
4+
.TH PYRADIO 1 "December 2020"
55

66
.SH NAME
77
.PP

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, 8)
3+
version_info = (0, 8, 8, 1)
44

55
# Application state:
66
# New stable version: ''

pyradio/browser.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ def format_station_line(self, id_in_list, pad, width):
148148

149149
class PyRadioBrowserInfoBrowser(PyRadioStationsBrowser):
150150

151-
BASE_URL = 'www.radio-browser.info'
151+
BASE_URL = 'api.radio-browser.info'
152152
TITLE = 'Radio Browser'
153153

154-
_open_url = \
155-
'http://www.radio-browser.info/webservice/json/stations/topvote/100'
154+
_open_url = 'https://de1.api.radio-browser.info/json/stations/topvote/100'
156155
_open_headers = {'user-agent': 'PyRadio/dev'}
157156

158157
_raw_stations = []
@@ -224,15 +223,15 @@ def url(self, id_in_list):
224223
if id_in_list < len(self._raw_stations):
225224
if self._raw_stations[id_in_list]['real_url']:
226225
if logger.isEnabledFor(logging.DEBUG):
227-
logger.debug('Using existing url: "{}"'.format(self._raw_stations[id_in_list]['url']))
228-
return self._raw_stations[id_in_list]['url']
226+
logger.debug('Using existing url: "{}"'.format(self._raw_stations[id_in_list]['url_resolved']))
227+
return self._raw_stations[id_in_list]['url_resolved']
229228
else:
230-
stationid = self._raw_stations[id_in_list]['id']
229+
stationid = self._raw_stations[id_in_list]['stationuuid']
231230
url = self.real_url(stationid)
232231
if url:
233232
if logger.isEnabledFor(logging.DEBUG):
234233
logger.debug('URL retrieved: "{0}" <- "{1}'.format(url, self._raw_stations[id_in_list]['url']))
235-
self._raw_stations[id_in_list]['url'] = url
234+
self._raw_stations[id_in_list]['url_resolved'] = url
236235
self._raw_stations[id_in_list]['real_url'] = True
237236
self._raw_stations[id_in_list]['played'] = True
238237
else:
@@ -324,11 +323,14 @@ def search(self, data):
324323
post_data['hidebroken'] = 'true'
325324
self._last_search = post_data
326325
url = 'http://www.radio-browser.info/webservice/json/stations/search'
326+
url = self._open_url
327327
try:
328328
# r = requests.get(url=url)
329329
r = requests.get(url=url, headers=self._open_headers, json=post_data, timeout=self._search_timeout)
330330
r.raise_for_status()
331+
logger.error(r.text)
331332
self._raw_stations = self._extract_data(json.loads(r.text))
333+
logger.error('DE {}'.format(self._raw_stations))
332334
except requests.exceptions.RequestException as e:
333335
if logger.isEnabledFor(logging.ERROR):
334336
logger.error(e)
@@ -450,10 +452,12 @@ def _extract_data(self, a_search_result):
450452
for n in a_search_result:
451453
ret.append({'name': n['name'].replace(',', ' ')})
452454
ret[-1]['url'] = n['url']
453-
ret[-1]['real_url'] = False
455+
ret[-1]['url_resolved'] = n['url_resolved']
456+
ret[-1]['real_url'] = True if n['url_resolved'] else False
454457
ret[-1]['played'] = False
455458
ret[-1]['hls'] = n['hls']
456-
ret[-1]['id'] = n['id']
459+
ret[-1]['stationuuid'] = n['stationuuid']
460+
ret[-1]['countrycode'] = n['countrycode']
457461
ret[-1]['country'] = n['country']
458462
if isinstance(n['clickcount'], int):
459463
# old API

pyradio/player.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -721,23 +721,24 @@ def updateWinVLCStatus(self, *args):
721721
if stop():
722722
break
723723
subsystemOut = fp.readline()
724-
subsystemOut = subsystemOut.strip()
724+
subsystemOut = subsystemOut.strip().replace(u'\ufeff', '')
725725
subsystemOut = subsystemOut.replace("\r", "").replace("\n", "")
726726
if subsystemOut == '':
727727
continue
728-
logger.error('DE >>> "{}"'.format(subsystemOut))
728+
# logger.error('DE >>> "{}"'.format(subsystemOut))
729729
if not self._is_accepted_input(subsystemOut):
730730
continue
731-
logger.error('DE --- accepted')
731+
# logger.error('DE --- accepted')
732732
if self.oldUserInput['Input'] != subsystemOut:
733733
if stop():
734734
break
735735
if (logger.isEnabledFor(logging.DEBUG)):
736736
if version_info < (3, 0):
737737
disp = subsystemOut.encode('utf-8', 'replace').strip()
738-
logger.debug("User input: {}".format(disp))
738+
# logger.debug("User input: {}".format(disp))
739739
else:
740-
logger.debug("User input: {}".format(subsystemOut))
740+
# logger.debug("User input: {}".format(subsystemOut))
741+
pass
741742
self.oldUserInput['Input'] = subsystemOut
742743
if self.volume_string in subsystemOut:
743744
if stop():
@@ -1171,8 +1172,10 @@ def close(self):
11711172
if self.process is not None:
11721173
if platform.startswith('win'):
11731174
try:
1174-
subprocess.Call(['Taskkill', '/PID', '{}'.format(self.process.pid), '/F'])
1175+
subprocess.Call(['Taskkill', '/PID', '{}'.format(self.process.pid), '/F', '/T'])
1176+
logger.error('Taskkill killed PID {}'.format(self.process.pid))
11751177
self.process = None
1178+
logger.error('***** self.process = None')
11761179
except:
11771180
logger.error('Taskkill failed to kill PID {}'.format(self.process.pid))
11781181
else:
@@ -1848,8 +1851,9 @@ def _stop(self):
18481851
return
18491852
if self.WIN:
18501853
if self.process:
1854+
logger.error('>>>> Terminating process')
18511855
self._req('quit')
1852-
threading.Thread(target=self._remove_vlc_stdout_log_file, args=()).start()
1856+
threading.Thread(target=self._remove_vlc_stdout_log_file, args=()).start()
18531857
else:
18541858
self._sendCommand("shutdown\n")
18551859
self._icy_data = {}
@@ -1991,6 +1995,9 @@ def _req(self, msg, ret_function=None, full=True):
19911995
sock.close()
19921996
except:
19931997
pass
1998+
if msg == 'quit':
1999+
self.process.terminate()
2000+
self.process = None
19942001
if ret_function:
19952002
ret_function(response)
19962003
return response
@@ -2021,7 +2028,11 @@ def _get_volume_response(self, msg):
20212028
if ind > -1:
20222029
vol = vol[:ind]
20232030
break
2024-
self.actual_volume = int(vol)
2031+
try:
2032+
self.actual_volume = int(vol)
2033+
except ValueError:
2034+
logger.error('DE _get_volume_response: ValueError: vol = {}'.format(vol))
2035+
return
20252036
logger.error('DE _get_volume_response: vol = {}'.format(vol))
20262037
break
20272038
if self.actual_volume == 0:

pyradio/radio.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,9 @@ def setStation(self, number):
862862

863863
def playSelectionBrowser(self):
864864
self.log.display_help_message = False
865-
self.log.write(msg=player_start_stop_token[0] + self._last_played_station[0] + '"')
865+
866+
# self.log.write(msg=player_start_stop_token[0] + self._last_played_station[0] + '"')
867+
866868
#### self._cnf.browsing_station_service = True
867869
# Add a history item to preserve browsing_station_service
868870
# Need to add TITLE, if service found
@@ -2842,7 +2844,7 @@ def to_time(secs):
28422844
delta = (d1 - d2).days
28432845

28442846
# PROGRAM DEBUG: Uncomment this to force check
2845-
delta=check_days
2847+
# delta=check_days
28462848
if delta < check_days:
28472849
clean_date_files(files)
28482850
if logger.isEnabledFor(logging.INFO):

0 commit comments

Comments
 (0)