diff --git a/pyradio.1 b/pyradio.1 index 0a205b47..0d22c5ec 100644 --- a/pyradio.1 +++ b/pyradio.1 @@ -1,7 +1,7 @@ .\" Copyright (C) 2011 Ben Dowling .\" This manual is freely distributable under the terms of the GPL. .\" -.TH PYRADIO 1 "November 2020" +.TH PYRADIO 1 "December 2020" .SH NAME .PP diff --git a/pyradio/__init__.py b/pyradio/__init__.py index 8299998d..7bb9f927 100644 --- a/pyradio/__init__.py +++ b/pyradio/__init__.py @@ -1,6 +1,6 @@ " pyradio -- Console radio player. " -version_info = (0, 8, 8) +version_info = (0, 8, 8, 1) # Application state: # New stable version: '' diff --git a/pyradio/browser.py b/pyradio/browser.py index b084ec9d..fff0210d 100644 --- a/pyradio/browser.py +++ b/pyradio/browser.py @@ -148,11 +148,10 @@ def format_station_line(self, id_in_list, pad, width): class PyRadioBrowserInfoBrowser(PyRadioStationsBrowser): - BASE_URL = 'www.radio-browser.info' + BASE_URL = 'api.radio-browser.info' TITLE = 'Radio Browser' - _open_url = \ - 'http://www.radio-browser.info/webservice/json/stations/topvote/100' + _open_url = 'https://de1.api.radio-browser.info/json/stations/topvote/100' _open_headers = {'user-agent': 'PyRadio/dev'} _raw_stations = [] @@ -224,15 +223,15 @@ def url(self, id_in_list): if id_in_list < len(self._raw_stations): if self._raw_stations[id_in_list]['real_url']: if logger.isEnabledFor(logging.DEBUG): - logger.debug('Using existing url: "{}"'.format(self._raw_stations[id_in_list]['url'])) - return self._raw_stations[id_in_list]['url'] + logger.debug('Using existing url: "{}"'.format(self._raw_stations[id_in_list]['url_resolved'])) + return self._raw_stations[id_in_list]['url_resolved'] else: - stationid = self._raw_stations[id_in_list]['id'] + stationid = self._raw_stations[id_in_list]['stationuuid'] url = self.real_url(stationid) if url: if logger.isEnabledFor(logging.DEBUG): logger.debug('URL retrieved: "{0}" <- "{1}'.format(url, self._raw_stations[id_in_list]['url'])) - self._raw_stations[id_in_list]['url'] = url + self._raw_stations[id_in_list]['url_resolved'] = url self._raw_stations[id_in_list]['real_url'] = True self._raw_stations[id_in_list]['played'] = True else: @@ -324,11 +323,14 @@ def search(self, data): post_data['hidebroken'] = 'true' self._last_search = post_data url = 'http://www.radio-browser.info/webservice/json/stations/search' + url = self._open_url try: # r = requests.get(url=url) r = requests.get(url=url, headers=self._open_headers, json=post_data, timeout=self._search_timeout) r.raise_for_status() + logger.error(r.text) self._raw_stations = self._extract_data(json.loads(r.text)) + logger.error('DE {}'.format(self._raw_stations)) except requests.exceptions.RequestException as e: if logger.isEnabledFor(logging.ERROR): logger.error(e) @@ -450,10 +452,12 @@ def _extract_data(self, a_search_result): for n in a_search_result: ret.append({'name': n['name'].replace(',', ' ')}) ret[-1]['url'] = n['url'] - ret[-1]['real_url'] = False + ret[-1]['url_resolved'] = n['url_resolved'] + ret[-1]['real_url'] = True if n['url_resolved'] else False ret[-1]['played'] = False ret[-1]['hls'] = n['hls'] - ret[-1]['id'] = n['id'] + ret[-1]['stationuuid'] = n['stationuuid'] + ret[-1]['countrycode'] = n['countrycode'] ret[-1]['country'] = n['country'] if isinstance(n['clickcount'], int): # old API diff --git a/pyradio/player.py b/pyradio/player.py index b00abf90..b6284488 100644 --- a/pyradio/player.py +++ b/pyradio/player.py @@ -721,23 +721,24 @@ def updateWinVLCStatus(self, *args): if stop(): break subsystemOut = fp.readline() - subsystemOut = subsystemOut.strip() + subsystemOut = subsystemOut.strip().replace(u'\ufeff', '') subsystemOut = subsystemOut.replace("\r", "").replace("\n", "") if subsystemOut == '': continue - logger.error('DE >>> "{}"'.format(subsystemOut)) + # logger.error('DE >>> "{}"'.format(subsystemOut)) if not self._is_accepted_input(subsystemOut): continue - logger.error('DE --- accepted') + # logger.error('DE --- accepted') if self.oldUserInput['Input'] != subsystemOut: if stop(): break if (logger.isEnabledFor(logging.DEBUG)): if version_info < (3, 0): disp = subsystemOut.encode('utf-8', 'replace').strip() - logger.debug("User input: {}".format(disp)) + # logger.debug("User input: {}".format(disp)) else: - logger.debug("User input: {}".format(subsystemOut)) + # logger.debug("User input: {}".format(subsystemOut)) + pass self.oldUserInput['Input'] = subsystemOut if self.volume_string in subsystemOut: if stop(): @@ -1171,8 +1172,10 @@ def close(self): if self.process is not None: if platform.startswith('win'): try: - subprocess.Call(['Taskkill', '/PID', '{}'.format(self.process.pid), '/F']) + subprocess.Call(['Taskkill', '/PID', '{}'.format(self.process.pid), '/F', '/T']) + logger.error('Taskkill killed PID {}'.format(self.process.pid)) self.process = None + logger.error('***** self.process = None') except: logger.error('Taskkill failed to kill PID {}'.format(self.process.pid)) else: @@ -1848,8 +1851,9 @@ def _stop(self): return if self.WIN: if self.process: + logger.error('>>>> Terminating process') self._req('quit') - threading.Thread(target=self._remove_vlc_stdout_log_file, args=()).start() + threading.Thread(target=self._remove_vlc_stdout_log_file, args=()).start() else: self._sendCommand("shutdown\n") self._icy_data = {} @@ -1991,6 +1995,9 @@ def _req(self, msg, ret_function=None, full=True): sock.close() except: pass + if msg == 'quit': + self.process.terminate() + self.process = None if ret_function: ret_function(response) return response @@ -2021,7 +2028,11 @@ def _get_volume_response(self, msg): if ind > -1: vol = vol[:ind] break - self.actual_volume = int(vol) + try: + self.actual_volume = int(vol) + except ValueError: + logger.error('DE _get_volume_response: ValueError: vol = {}'.format(vol)) + return logger.error('DE _get_volume_response: vol = {}'.format(vol)) break if self.actual_volume == 0: diff --git a/pyradio/radio.py b/pyradio/radio.py index 09899fda..0e30de9c 100644 --- a/pyradio/radio.py +++ b/pyradio/radio.py @@ -862,7 +862,9 @@ def setStation(self, number): def playSelectionBrowser(self): self.log.display_help_message = False - self.log.write(msg=player_start_stop_token[0] + self._last_played_station[0] + '"') + + # self.log.write(msg=player_start_stop_token[0] + self._last_played_station[0] + '"') + #### self._cnf.browsing_station_service = True # Add a history item to preserve browsing_station_service # Need to add TITLE, if service found @@ -2842,7 +2844,7 @@ def to_time(secs): delta = (d1 - d2).days # PROGRAM DEBUG: Uncomment this to force check - delta=check_days + # delta=check_days if delta < check_days: clean_date_files(files) if logger.isEnabledFor(logging.INFO):