magnetikonline / docker-acestream-server

Ace Stream server Docker image and playback CLI for media players.
https://hub.docker.com/r/magnetikonline/acestream-server/
MIT License
131 stars 35 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte #8

Closed tosiara closed 2 years ago

tosiara commented 2 years ago

Do you know what this error means?

$ python3 ~/bin/playstream.py --player vlc --ace-stream-pid 925393f1fbb771d74e358d0a8c4adcca35addce4

Connecting to program ID [925393f1fbb771d74e358d0a8c4adcca35addce4]
Traceback (most recent call last):
  File "/home/user/bin/playstream.py", line 188, in <module>
    main()
  File "/home/user/bin/playstream.py", line 169, in main
    statistics_url, playback_url = start_stream(
  File "/home/user/bin/playstream.py", line 99, in start_stream
    response = api_request(
  File "/home/user/bin/playstream.py", line 91, in api_request
    return json.load(response).get("response", {})
  File "/usr/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.8/json/__init__.py", line 343, in loads
    s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
tosiara commented 2 years ago

The server logs this error, don't know if that is related:

2022-02-18 14:43:59,026|Thread-599|acestream.RequestBroker|process_dash_request:manifest: error
Traceback (most recent call last):
  File "core.c", line 1093, in 
  File "ACEStream/Core/APIImplementation/LiveDownloadImpl.py", line 672, in update_manifest
  File "ACEStream/Core/APIImplementation/LiveDownloadImpl.py", line 753, in update_manifest_direct
  File "ACEStream/Core/DASH/HLS.py", line 289, in update_manifest
  File "ACEStream/Core/DASH/HLS.py", line 532, in get_sub_manifest
  File "ACEStream/Core/DASH/HLS.py", line 394, in update_sub_manifest_async
AssertionError: segments != len(url_map), 10 != 15
tosiara commented 2 years ago

Did a little digging and found that server may respond with three different types of response:

  1. json
  2. M3U
  3. gzippped M3U

Examples:

M3U:

$ python3 ~/bin/playstream.py --player "ffplay" --ace-stream-pid 925393f1fbb771d74e358d0a8c4adcca35addce4
Connecting to program ID [925393f1fbb771d74e358d0a8c4adcca35addce4]
b'#EXTM3U\n#EXT-X-VERSION:3\n#EXT-X-TARGETDURATION:12\n#EXT-X-MEDIA-SEQUENCE:63192\n#EXT-X-DISCONTINUITY-SEQUENCE:0\n#EXT-X-PROGRAM-DATE-TIME:2022-02-18T14:56:59.887Z\n#EXTINF:10.0,\nmedia_b1600000_63192.ts\n#EXTINF:10.0,\nmedia_b1600000_63193.ts\n#EXTINF:10.0,\nmedia_b1600000_63194.ts\n#EXTINF:10.0,\nmedia_b1600000_63195.ts\n#EXTINF:10.0,\nmedia_b1600000_63196.ts\n#EXTINF:10.0,\nmedia_b1600000_63197.ts\n#EXTINF:10.0,\nmedia_b1600000_63198.ts\n#EXTINF:10.0,\nmedia_b1600000_63199.ts\n#EXTINF:10.0,\nmedia_b1600000_63200.ts\n#EXTINF:10.0,\nmedia_b1600000_63201.ts\n'
Traceback (most recent call last):
  File "/home/user/bin/playstream.py", line 191, in <module>
    main()
  File "/home/user/bin/playstream.py", line 172, in main
    statistics_url, playback_url = start_stream(
  File "/home/user/bin/playstream.py", line 101, in start_stream
    response = api_request(
  File "/home/user/bin/playstream.py", line 93, in api_request
    return json.loads(data).get("response", {})
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

gzipped M3U:

$ python3 ~/bin/playstream.py --player "ffplay" --ace-stream-pid 925393f1fbb771d74e358d0a8c4adcca35addce4
Connecting to program ID [925393f1fbb771d74e358d0a8c4adcca35addce4]
b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x00\x8d\xcd\xb1\x0e\x820\x10\x06\xe0\xdd\xd7`\xb5\xa4-PJ\xb7\x06N\xd2\x81\xa2\xe5j\xd0\x85htpp\xd2\xf7\x8fBB\x1c\xbd[.\xf9\xff\xefr\t\x8c\xd8eq\x93|7\x1b\xd9\x11\xc2\xe0zo\xb25@\x1bZ\xc0&\x06\x8bs.\xe4Zt\xd08\xcb\x068D\xf05\x18\x95\x89J\xac]\xe3\x86\xba\xf7\xe8|tx\xfa\x19\xbe\xf6\xfb\xd0\xb7\xc1v\xac\xb1\x08\x0c]\x07Fr)\x19\x97Lh\x14\xb9)\x94\xc9\xabT\xeb\xf2\xbc\\8\xbf3\x82\xa7|\xbby\xdeo\x8f\xcbt\x15\x8a\xcf3-O\xd3\xf7\xeb\xbf\x92$\x95\x91TNR\x05I)\x92*IJ\x93TEP\x92\xf3Y}\x00\x00\xc2\xf0\xe9\x1c\x02\x00\x00'
Traceback (most recent call last):
  File "/home/user/bin/playstream.py", line 191, in <module>
    main()
  File "/home/user/bin/playstream.py", line 172, in main
    statistics_url, playback_url = start_stream(
  File "/home/user/bin/playstream.py", line 101, in start_stream
    response = api_request(
  File "/home/user/bin/playstream.py", line 93, in api_request
    return json.loads(data).get("response", {})
  File "/usr/lib/python3.8/json/__init__.py", line 343, in loads
    s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

JSON:

$ python3 ~/bin/playstream.py --player "ffplay" --ace-stream-pid 925393f1fbb771d74e358d0a8c4adcca35addce4
Connecting to program ID [925393f1fbb771d74e358d0a8c4adcca35addce4]
b'{"response": {"stat_url": "http://127.0.0.1:6878/ace/stat/df144c90b64eb86e642a6771a9cf164db6c367b0/ea544273d6fa2bfa1d761c22c52b12c7", "playback_session_id": "47c87d36606667086dc9711c0010616f64dd48fb", "is_live": 1, "playback_url": "http://127.0.0.1:6878/ace/r/df144c90b64eb86e642a6771a9cf164db6c367b0/ea544273d6fa2bfa1d761c22c52b12c7", "is_encrypted": 0, "command_url": "http://127.0.0.1:6878/ace/cmd/df144c90b64eb86e642a6771a9cf164db6c367b0/ea544273d6fa2bfa1d761c22c52b12c7", "client_session_id": -1, "infohash": "df144c90b64eb86e642a6771a9cf164db6c367b0"}, "error": null}'
Awaiting successful connection to stream
b'{"response": {}, "error": null}'
Waiting... [Peers: 0 // Down: 0KB // Up: 0KB]
b'{"response": {"status": "dl", "uploaded": 0, "speed_down": 0, "speed_up": 0, "downloaded": 0, "playback_session_id": "47c87d36606667086dc9711c0010616f64dd48fb", "wan_connection_status": 0, "peers": 9, "total_progress": 0, "is_encrypted": 0, "disk_cache_stats": {"avail": 35569221632, "disk_cache_limit": 10737418240, "inactive_inuse": 0, "active_inuse": 0}, "is_live": 1, "debug_level": 0, "client_session_id": -1, "infohash": "df144c90b64eb86e642a6771a9cf164db6c367b0", "selected_stream_index": 0, "selected_file_index": -1, "livepos": {"last": "0", "live_first": "0", "pos": "-1", "first_ts": "0", "last_ts": "0", "is_live": "0", "live_last": "0", "buffer_pieces": "0"}}, "error": null}'
Ready!

Playback available at [http://127.0.0.1:6878/ace/r/df144c90b64eb86e642a6771a9cf164db6c367b0/ea544273d6fa2bfa1d761c22c52b12c7]
Starting media player...
ffplay http://127.0.0.1:6878/ace/r/df144c90b64eb86e642a6771a9cf164db6c367b0/ea544273d6fa2bfa1d761c22c52b12c7