@@ -310,6 +310,9 @@ class Player():
310
310
GET_AUDIO_FORMAT = b'{ "command": ["get_property", "audio-out-params"], "request_id": 200 }\n '
311
311
GET_AUDIO_CODEC = b'{ "command": ["get_property", "audio-codec"], "request_id": 300 }\n '
312
312
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 '
313
316
314
317
all_config_files = {}
315
318
@@ -696,9 +699,12 @@ def get_info_string(self, a_station, max_width, win_width):
696
699
ret = '|' + '\n ' .join (a_list ).replace ('Encoding: |' , 'Encoding: ' ).replace ('URL: |' , 'URL: ' ).replace ('\n ' , '\n |' )
697
700
tail = ''
698
701
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
+ ):
702
708
tail = '\n \n Press |r| to rename station to |Reported Name|, or'
703
709
return ret + '\n \n |Highlighted values| are user specified.\n Other values are station provided (live) data.' , tail
704
710
@@ -1319,11 +1325,12 @@ def updateMPVStatus(self, *args):
1319
1325
if stop ():
1320
1326
break
1321
1327
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
1327
1334
elif a_data == b'' :
1328
1335
if logger .isEnabledFor (logging .INFO ):
1329
1336
logger .info ('----==== MPV crashed ====----' )
@@ -1646,6 +1653,16 @@ def do_crash_detection(detect_if_player_exited, stop):
1646
1653
pass
1647
1654
self ._clear_empty_mkv ()
1648
1655
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
+
1649
1666
def _request_mpv_info_data (self , sock ):
1650
1667
with self .status_update_lock :
1651
1668
ret = len (self ._icy_data ) == 0
@@ -1656,27 +1673,41 @@ def _request_mpv_info_data(self, sock):
1656
1673
# if ret == 0 or force:
1657
1674
if ret :
1658
1675
# logger.error('\n\nIn _request_mpv_info_data')
1676
+ no_get_title_exception = True
1659
1677
if platform .startswith ('win' ):
1660
1678
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
1668
1692
else :
1669
1693
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 :
1677
1708
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
1680
1711
1681
1712
def _get_mpv_metadata (self , * args ):
1682
1713
''' Get MPV metadata
@@ -2701,7 +2732,7 @@ def _stop(self):
2701
2732
self .stop_mpv_status_update_thread = True
2702
2733
self ._send_mpv_command ('quit' )
2703
2734
if not platform .startswith ('win' ):
2704
- os .system ('rm ' + self .mpvsocket + ' 2>/dev/null' );
2735
+ os .system ('rm ' + self .mpvsocket + ' 2>/dev/null' )
2705
2736
self ._icy_data = {}
2706
2737
self .monitor = self .monitor_process = self .monitor_opts = None
2707
2738
if self ._chapters :
0 commit comments