@@ -547,13 +547,13 @@ def socket_request(self, Method, Handler, Params, Binary, TimeoutSend, TimeoutRe
547
547
try :
548
548
return StatusCode , IncomingDataHeader , json .loads (PayloadTotal )
549
549
except Exception as error :
550
- xbmc .log (f"EMBY.emby.http: Invalid json content { ConnectionId } : { IncomingDataHeader } error: { error } " , 3 ) # LOGERROR
550
+ xbmc .log (f"EMBY.emby.http: Invalid json content { ConnectionId } : { IncomingDataHeader } error: { error } payload: { PayloadTotal } " , 3 ) # LOGERROR
551
551
return 612 , {}, ""
552
552
else :
553
553
try :
554
554
return StatusCode , IncomingDataHeader , PayloadTotal .decode ("UTF-8" )
555
555
except Exception as error :
556
- xbmc .log (f"EMBY.emby.http: Invalid text content { ConnectionId } : { IncomingDataHeader } error: { error } " , 3 ) # LOGERROR
556
+ xbmc .log (f"EMBY.emby.http: Invalid text content { ConnectionId } : { IncomingDataHeader } error: { error } payload: { PayloadTotal } " , 3 ) # LOGERROR
557
557
return 612 , {}, ""
558
558
559
559
def download_file (self ):
@@ -652,19 +652,22 @@ def download_file(self):
652
652
653
653
break
654
654
655
- def request (self , Method , Handler , Params , RequestHeader , Binary , ConnectionString , CloseConnection , BusyFunction = None ):
656
- if CloseConnection :
657
- ConnectionId = str (uuid .uuid4 ())
658
- elif self .RequestBusy ["MAIN" ].locked ():
659
- if self .RequestBusy ["MAINFALLBACK" ].locked ():
655
+ def request (self , Method , Handler , Params , RequestHeader , Binary , ConnectionString , CloseConnection , BusyFunction = None , ConnectionId = "" ):
656
+ if not ConnectionId :
657
+ if CloseConnection :
660
658
ConnectionId = str (uuid .uuid4 ())
661
- CloseConnection = True
659
+ elif self .RequestBusy ["MAIN" ].locked ():
660
+ if self .RequestBusy ["MAINFALLBACK" ].locked ():
661
+ ConnectionId = str (uuid .uuid4 ())
662
+ CloseConnection = True
663
+ else :
664
+ ConnectionId = "MAINFALLBACK"
665
+ self .RequestBusy ["MAINFALLBACK" ].acquire ()
662
666
else :
663
- ConnectionId = "MAINFALLBACK "
664
- self .RequestBusy ["MAINFALLBACK " ].acquire ()
667
+ ConnectionId = "MAIN "
668
+ self .RequestBusy ["MAIN " ].acquire ()
665
669
else :
666
- ConnectionId = "MAIN"
667
- self .RequestBusy ["MAIN" ].acquire ()
670
+ self .RequestBusy [ConnectionId ].acquire ()
668
671
669
672
RequestId = f"REQUEST{ ConnectionId } "
670
673
@@ -779,7 +782,7 @@ def send_request(self, Method, Handler, Params, RequestHeader, Binary, Connectio
779
782
elif "Subtitles" in Handler :
780
783
StatusCode , Header , Payload = self .socket_request (Method , Handler , Params , Binary , 12 , 30 , ConnectionId , "" , 0 , "" )
781
784
else :
782
- StatusCode , Header , Payload = self .socket_request (Method , Handler , Params , Binary , 12 , 300 , ConnectionId , "" , 0 , "" )
785
+ StatusCode , Header , Payload = self .socket_request (Method , Handler , Params , Binary , 12 , 1200 , ConnectionId , "" , 0 , "" )
783
786
784
787
# Redirects
785
788
if StatusCode in (301 , 302 , 307 , 308 ):
@@ -1117,11 +1120,11 @@ def Ping(self):
1117
1120
1118
1121
# Main connection ping
1119
1122
if Counter == 1 and not self .RequestBusy ["MAIN" ].locked ():
1120
- self .send_request ("POST" , "System/Ping" , {}, {}, True , "" , False , "MAIN" , "MAINPING " )
1123
+ self .request ("POST" , "System/Ping" , {}, {}, True , "" , False , None , "MAIN " )
1121
1124
1122
1125
# Mainfallback connection ping
1123
1126
if Counter == 2 and not self .RequestBusy ["MAINFALLBACK" ].locked ():
1124
- self .send_request ("POST" , "System/Ping" , {}, {}, True , "" , False , "MAINFALLBACK" , "MAINFALLBACKPING " )
1127
+ self .request ("POST" , "System/Ping" , {}, {}, True , "" , False , None , "MAINFALLBACK " )
1125
1128
1126
1129
# Async connection ping
1127
1130
if Counter == 3 and not self .RequestBusy ["ASYNC" ].locked ():
0 commit comments