@@ -310,6 +310,9 @@ class Player():
310310 GET_AUDIO_FORMAT = b'{ "command": ["get_property", "audio-out-params"], "request_id": 200 }\n '
311311 GET_AUDIO_CODEC = b'{ "command": ["get_property", "audio-codec"], "request_id": 300 }\n '
312312 GET_AUDIO_CODEC_NAME = b'{ "command": ["get_property", "audio-codec-name"], "request_id": 400 }\n '
313+ GET_ERROR = b'{"command": ["get_property", "error"]}\n '
314+ GET_ERROR = b'{"command": ["get_property", "http-header-fields"], "request_id": 500 }\n '
315+ INPUT_COMMANDS = b'{"command": ["get_property", "user-data/mpv/ytdl/json-subprocess-result"], "request_id": 600 }\n '
313316
314317 all_config_files = {}
315318
@@ -696,9 +699,12 @@ def get_info_string(self, a_station, max_width, win_width):
696699 ret = '|' + '\n ' .join (a_list ).replace ('Encoding: |' , 'Encoding: ' ).replace ('URL: |' , 'URL: ' ).replace ('\n ' , '\n |' )
697700 tail = ''
698701 if 'icy-name' in self ._icy_data :
699- if a_station [0 ] != self ._icy_data ['icy-name' ] and \
700- self ._icy_data ['icy-name' ] and \
701- self ._icy_data ['icy-name' ] != '(null)' :
702+ if self ._cnf ._online_browser is None and \
703+ (
704+ a_station [0 ] != self ._icy_data ['icy-name' ] and \
705+ self ._icy_data ['icy-name' ] and \
706+ self ._icy_data ['icy-name' ] != '(null)'
707+ ):
702708 tail = '\n \n Press |r| to rename station to |Reported Name|, or'
703709 return ret + '\n \n |Highlighted values| are user specified.\n Other values are station provided (live) data.' , tail
704710
@@ -1319,11 +1325,12 @@ def updateMPVStatus(self, *args):
13191325 if stop ():
13201326 break
13211327 elif b'"file_error":"loading failed"' in a_data :
1322- got_404 = True
1323- logger .error ('\n \n got_404 = {}\n \n ' .format (got_404 ))
1324- if logger .isEnabledFor (logging .INFO ):
1325- logger .info ('----==== playbak stopped, reason: {} ====----' .format (a_data ))
1326- break
1328+ self ._request_mpv_error (sock )
1329+ # got_404 = True
1330+ # logger.error('\n\ngot_404 = {}\n\n'.format(got_404))
1331+ # if logger.isEnabledFor(logging.INFO):
1332+ # logger.info('----==== playbak stopped, reason: {} ====----'.format(a_data))
1333+ # break
13271334 elif a_data == b'' :
13281335 if logger .isEnabledFor (logging .INFO ):
13291336 logger .info ('----==== MPV crashed ====----' )
@@ -1646,6 +1653,16 @@ def do_crash_detection(detect_if_player_exited, stop):
16461653 pass
16471654 self ._clear_empty_mkv ()
16481655
1656+ def _request_mpv_error (self , sock ):
1657+ try :
1658+ if platform .startswith ('win' ):
1659+ win32file .WriteFile (sock , self .GET_ERROR )
1660+ else :
1661+ # sock.sendall(self.GET_ERROR)
1662+ sock .sendall (self .INPUT_COMMANDS )
1663+ except BrokenPipeError :
1664+ pass
1665+
16491666 def _request_mpv_info_data (self , sock ):
16501667 with self .status_update_lock :
16511668 ret = len (self ._icy_data ) == 0
@@ -1656,27 +1673,41 @@ def _request_mpv_info_data(self, sock):
16561673 # if ret == 0 or force:
16571674 if ret :
16581675 # logger.error('\n\nIn _request_mpv_info_data')
1676+ no_get_title_exception = True
16591677 if platform .startswith ('win' ):
16601678 if self ._request_mpv_info_data_counter == 4 :
1661- win32file .WriteFile (sock , self .GET_TITLE )
1662- if 'audio_format' not in self ._icy_data :
1663- win32file .WriteFile (sock , self .GET_AUDIO_FORMAT )
1664- if 'codec' not in self ._icy_data :
1665- win32file .WriteFile (sock , self .GET_AUDIO_CODEC )
1666- if 'codec-name' not in self ._icy_data :
1667- win32file .WriteFile (sock , self .GET_AUDIO_CODEC_NAME )
1679+ try :
1680+ win32file .WriteFile (sock , self .GET_TITLE )
1681+ except BrokenPipeError :
1682+ no_get_title_exception = False
1683+ try :
1684+ if 'audio_format' not in self ._icy_data :
1685+ win32file .WriteFile (sock , self .GET_AUDIO_FORMAT )
1686+ if 'codec' not in self ._icy_data :
1687+ win32file .WriteFile (sock , self .GET_AUDIO_CODEC )
1688+ if 'codec-name' not in self ._icy_data :
1689+ win32file .WriteFile (sock , self .GET_AUDIO_CODEC_NAME )
1690+ except BrokenPipeError :
1691+ pass
16681692 else :
16691693 if self ._request_mpv_info_data_counter == 4 :
1670- sock .sendall (self .GET_TITLE )
1671- if 'audio_format' not in self ._icy_data :
1672- sock .sendall (self .GET_AUDIO_FORMAT )
1673- if 'codec' not in self ._icy_data :
1674- sock .sendall (self .GET_AUDIO_CODEC )
1675- if 'codec-name' not in self ._icy_data :
1676- sock .sendall (self .GET_AUDIO_CODEC_NAME )
1694+ try :
1695+ sock .sendall (self .GET_TITLE )
1696+ except BrokenPipeError :
1697+ no_get_title_exception = False
1698+ try :
1699+ if 'audio_format' not in self ._icy_data :
1700+ sock .sendall (self .GET_AUDIO_FORMAT )
1701+ if 'codec' not in self ._icy_data :
1702+ sock .sendall (self .GET_AUDIO_CODEC )
1703+ if 'codec-name' not in self ._icy_data :
1704+ sock .sendall (self .GET_AUDIO_CODEC_NAME )
1705+ except BrokenPipeError :
1706+ pass
1707+ if no_get_title_exception :
16771708 self ._request_mpv_info_data_counter += 1
1678- if self ._request_mpv_info_data_counter >= 4 :
1679- self ._request_mpv_info_data_counter = 0
1709+ if self ._request_mpv_info_data_counter >= 4 :
1710+ self ._request_mpv_info_data_counter = 0
16801711
16811712 def _get_mpv_metadata (self , * args ):
16821713 ''' Get MPV metadata
@@ -2701,7 +2732,7 @@ def _stop(self):
27012732 self .stop_mpv_status_update_thread = True
27022733 self ._send_mpv_command ('quit' )
27032734 if not platform .startswith ('win' ):
2704- os .system ('rm ' + self .mpvsocket + ' 2>/dev/null' );
2735+ os .system ('rm ' + self .mpvsocket + ' 2>/dev/null' )
27052736 self ._icy_data = {}
27062737 self .monitor = self .monitor_process = self .monitor_opts = None
27072738 if self ._chapters :
0 commit comments