The service will be available via a separate subscription within the Apple TV app and will include all MLS, Leagues Cup and select MLS NEXT Pro and MLS NEXT matches. "No fragmentation, no frustration - just the flexibility to sign up for one convenient service that gives you everything MLS, anywhere and anytime you want to watch." "For the first time in the history of sports, fans will be able to access everything from a major professional sports league in one place," Eddy Cue, Apple's senior vice resident of services said in a statement. This cannot really be done differently without vendoring the whole library as the behavior for parsing status line is deeply hidden in the C code.SANDY - Major League Soccer and Apple announced a partnership Tuesday to stream all MLS matches via the Apple TV app beginning in 2023 and going through 2032. Note that this comes with a performance penalty for requests made with ICYConnector - in order for this to work, I am using the pure Python implementation of HttpResponseParser which is going to be slower than the one that aiohttp uses by default and is written in C. This way, you can dedicate a ClientSession object specifically for requests to servers that respond with the ICY status line. Yes, it's using a few private classes and attributes but this is the only solution to change the handling of something that's part of HTTP spec and (theoretically) should not ever need to be changed by the library's user.Īll things considered, I would say this is still rather clean in comparison to monkey patching which would cause the behavior to be changed for all requests (especially true for asyncio where setting before and resetting after a request does not guarantee that something else won't make a request while request to ICY is being made). This can then be used as follows: session = aiohttp.ClientSession(connector=ICYConnector()) Self._factory = functools.partial(ICYResponseHandler, loop=self._loop) Payload_exception=aiohttp.ClientPayloadError,Ĭlass ICYConnector(aiohttp.TCPConnector): Self._timeout_ceil_threshold = timeout_ceil_threshold # this is a copy of the implementation from here: In line with the answer from ( ), here's how you can achieve the same result with the asynchronous HTTP client library - aiohttp: import functoolsįrom aiohttp.client_proto import ResponseHandlerįrom aiohttp.http_parser import HttpResponseParserPyĬlass ICYHttpResponseParser(HttpResponseParserPy):Ĭlass ICYResponseHandler(ResponseHandler): I have found this to be the simplest way to get round the problem of the status message causing an error. Finally the original is called and the values from that are passed back to the caller and everything else continues as normal. NiceToICY replaces the unrecognised status response, then copies across the relevant bits of the original response which are needed by the 'real' _read_status function. They will override the standard routine (this one time only) and run the NiceToICY function in place of the normal status check when it has opened the stream. ORIGINAL_HTTP_CLIENT_READ_STATUS = .HTTPResponse._read_status Then put these lines at the start of your main routine, before you open the URL. Return ORIGINAL_HTTP_CLIENT_READ_STATUS(InterceptedSelf) InterceptedSelf._close_conn = self._close_conn InterceptedSelf.fp = io.BufferedReader(io.BytesIO(line)) InterceptedSelf = InterceptedHTTPResponse() Simply put a routine like this above your stream opening code. What you can effectively do is intercept the routine that handles reading the status after opening the stream, just before processing the headers. If you find that your requests or urllib.request call in Python 3 fails to save a stream because you receive "ICY 200 OK" in return instead of an "HTTP/1.0 200 OK" header, you need to tell the underlying functions ICY 200 OK is OK!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |