2bc4 / streamlink-ttvlol

Streamlink Twitch plugin modified to work with the TTV.LOL API
BSD 2-Clause "Simplified" License
158 stars 6 forks source link

--twitch-reexec-on-ad Doesn't work with Streamlink Twitch GUI #31

Closed retraenn closed 1 year ago

retraenn commented 1 year ago

Streams just close without error when viewing in Streamlink Twitch GUI. I'm using mpv and I think it's to do with the order of arguments when playing from Streamlink Twitch GUI. It works from the command line if the arguments are in a specific order, I'll give an example..

This fails:

C:\Users\name>streamlink --player "C:\Program Files (x86)\mpv\mpv.exe" twitch.tv/gothamchess best --twitch-proxy-playlist=https://api.ttv.lol --twitch-reexec-on-ad --loglevel trace [16:27:12.733982][cli][debug] OS: Windows 10 [16:27:12.733982][cli][debug] Python: 3.10.8 [16:27:12.734982][cli][debug] Streamlink: 5.1.2 [16:27:12.734982][cli][debug] Dependencies: [16:27:12.736989][cli][debug] certifi: 2022.9.24 [16:27:12.736989][cli][debug] isodate: 0.6.1 [16:27:12.737985][cli][debug] lxml: 4.9.1 [16:27:12.738986][cli][debug] pycountry: 22.3.5 [16:27:12.738986][cli][debug] pycryptodome: 3.16.0 [16:27:12.739987][cli][debug] PySocks: 1.7.1 [16:27:12.739987][cli][debug] requests: 2.28.1 [16:27:12.741989][cli][debug] urllib3: 1.26.13 [16:27:12.741989][cli][debug] websocket-client: 1.4.2 [16:27:12.748995][cli][debug] Arguments: [16:27:12.748995][cli][debug] url=twitch.tv/gothamchess [16:27:12.748995][cli][debug] stream=['best'] [16:27:12.748995][cli][debug] --loglevel=trace [16:27:12.749997][cli][debug] --player=C:\Program Files (x86)\mpv\mpv.exe [16:27:12.749997][cli][debug] --ffmpeg-ffmpeg=C:\Users\name\AppData\Local\Streamlink\ffmpeg\ffmpeg.exe [16:27:12.749997][cli][debug] --twitch-proxy-playlist=['https://api.ttv.lol'] [16:27:12.749997][cli][debug] --twitch-reexec-on-ad=True [16:27:12.750997][cli][info] Found matching plugin twitch for URL twitch.tv/gothamchess [16:27:12.750997][plugins.twitch][debug] Getting live HLS streams for gothamchess [16:27:12.751998][plugins.twitch][info] Using playlist proxy 'https://api.ttv.lol' [16:27:12.751998][plugins.twitch][debug] Raw playlist proxy URL: 'https://api.ttv.lol/playlist/gothamchess.m3u8%3Fplayer%3Dtwitchweb%26type%3Dany%26allow_source%3Dtrue%26allow_audio_only%3Dtrue%26allow_spectre%3Dfalse%26fast_bread%3Dtrue' [16:27:12.785028][utils.l10n][debug] Language code: en_US [16:27:17.375197][cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 1080p (best) [16:27:17.375197][cli][info] Opening stream: 1080p (hls) [16:27:17.376198][cli][info] Starting player: C:\Program Files (x86)\mpv\mpv.exe [16:27:17.377200][stream.hls][debug] Reloading playlist [16:27:17.377200][cli][debug] Pre-buffering 8192 bytes [16:27:17.818601][stream.hls][debug] First Sequence: 4092; Last Sequence: 4105 [16:27:17.818601][stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 4103; End Sequence: None [16:27:17.819601][stream.hls][debug] Adding segment 4103 to queue [16:27:17.820602][stream.hls][debug] Adding segment 4104 to queue [16:27:17.820602][stream.hls][debug] Adding segment 4105 to queue [16:27:19.003677][stream.hls][debug] Writing segment 4103 to output [16:27:19.005679][stream.hls][debug] Segment 4103 complete [16:27:19.005679][cli.output][debug] Opening subprocess: C:\Program Files (x86)\mpv\mpv.exe --force-media-title=twitch.tv/gothamchess - [16:27:19.241894][stream.hls][debug] Writing segment 4104 to output [16:27:19.242895][stream.hls][debug] Segment 4104 complete [16:27:19.399036][stream.hls][debug] Writing segment 4105 to output [16:27:19.400037][stream.hls][debug] Segment 4105 complete [16:27:19.513140][cli][debug] Writing stream to output [16:27:23.837127][stream.hls][debug] Reloading playlist [16:27:24.268404][stream.hls][debug] Adding segment 4106 to queue [16:27:24.268404][stream.hls][debug] Adding segment 4107 to queue [16:27:24.269404][stream.hls][debug] Adding segment 4108 to queue [16:27:24.270405][stream.hls][debug] Adding segment 4109 to queue [16:27:24.270405][stream.hls][debug] Adding segment 4110 to queue [16:27:24.271406][stream.hls][debug] Adding segment 4111 to queue [16:27:24.425259][stream.hls][debug] Writing segment 4106 to output [16:27:24.427262][stream.hls][debug] Segment 4106 complete [16:27:24.558283][plugins.twitch][info] Encountered an ad segment, re-execing to retrieve a new playlist C:\Users\name>usage: streamlink [OPTIONS] [STREAM] streamlink: error: unrecognized arguments: twitch.tv/gothamchess best

This works:

C:\Users\name>streamlink twitch.tv/symfuhny best --twitch-proxy-playlist=https://api.ttv.lol --twitch-reexec-on-ad --loglevel trace [16:48:09.520325][cli][debug] OS: Windows 10 [16:48:09.521325][cli][debug] Python: 3.10.8 [16:48:09.521325][cli][debug] Streamlink: 5.1.2 [16:48:09.522327][cli][debug] Dependencies: [16:48:09.523328][cli][debug] certifi: 2022.9.24 [16:48:09.524329][cli][debug] isodate: 0.6.1 [16:48:09.524329][cli][debug] lxml: 4.9.1 [16:48:09.525330][cli][debug] pycountry: 22.3.5 [16:48:09.525330][cli][debug] pycryptodome: 3.16.0 [16:48:09.526331][cli][debug] PySocks: 1.7.1 [16:48:09.526331][cli][debug] requests: 2.28.1 [16:48:09.528332][cli][debug] urllib3: 1.26.13 [16:48:09.528332][cli][debug] websocket-client: 1.4.2 [16:48:09.534337][cli][debug] Arguments: [16:48:09.534337][cli][debug] url=twitch.tv/symfuhny [16:48:09.535338][cli][debug] stream=['best'] [16:48:09.535338][cli][debug] --loglevel=trace [16:48:09.535338][cli][debug] --player="C:\Program Files (x86)\mpv\mpv.exe" [16:48:09.536339][cli][debug] --ffmpeg-ffmpeg=C:\Users\name\AppData\Local\Streamlink\ffmpeg\ffmpeg.exe [16:48:09.536339][cli][debug] --twitch-proxy-playlist=['https://api.ttv.lol'] [16:48:09.536339][cli][debug] --twitch-reexec-on-ad=True [16:48:09.537340][cli][info] Found matching plugin twitch for URL twitch.tv/symfuhny [16:48:09.537340][plugins.twitch][debug] Getting live HLS streams for symfuhny [16:48:09.538341][plugins.twitch][info] Using playlist proxy 'https://api.ttv.lol' [16:48:09.538341][plugins.twitch][debug] Raw playlist proxy URL: 'https://api.ttv.lol/playlist/symfuhny.m3u8%3Fplayer%3Dtwitchweb%26type%3Dany%26allow_source%3Dtrue%26allow_audio_only%3Dtrue%26allow_spectre%3Dfalse%26fast_bread%3Dtrue' [16:48:09.570561][utils.l10n][debug] Language code: en_US [16:48:13.199386][cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p60, 936p60 (best) [16:48:13.199386][cli][info] Opening stream: 936p60 (hls) [16:48:13.200387][cli][info] Starting player: "C:\Program Files (x86)\mpv\mpv.exe" [16:48:13.201388][stream.hls][debug] Reloading playlist [16:48:13.201388][cli][debug] Pre-buffering 8192 bytes [16:48:13.433336][stream.hls][debug] First Sequence: 4580; Last Sequence: 4593 [16:48:13.433336][stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 4591; End Sequence: None [16:48:13.434338][stream.hls][debug] Adding segment 4591 to queue [16:48:13.434338][stream.hls][debug] Adding segment 4592 to queue [16:48:13.435339][stream.hls][debug] Adding segment 4593 to queue [16:48:13.912137][stream.hls][debug] Writing segment 4591 to output [16:48:13.914140][stream.hls][debug] Segment 4591 complete [16:48:13.915141][cli.output][debug] Opening subprocess: "C:\Program Files (x86)\mpv\mpv.exe" --force-media-title=twitch.tv/symfuhny - [16:48:13.995268][stream.hls][debug] Writing segment 4592 to output [16:48:13.998271][stream.hls][debug] Segment 4592 complete [16:48:14.129388][stream.hls][debug] Writing segment 4593 to output [16:48:14.132391][stream.hls][debug] Segment 4593 complete [16:48:14.432256][cli][debug] Writing stream to output [16:48:19.443645][stream.hls][debug] Reloading playlist [16:48:19.623725][stream.hls][debug] Adding segment 4594 to queue [16:48:19.623725][stream.hls][debug] Adding segment 4595 to queue [16:48:19.624726][stream.hls][debug] Adding segment 4596 to queue [16:48:19.624726][stream.hls][debug] Adding segment 4597 to queue [16:48:19.625727][stream.hls][debug] Adding segment 4598 to queue [16:48:19.625727][stream.hls][debug] Adding segment 4599 to queue [16:48:19.756317][stream.hls][debug] Writing segment 4594 to output [16:48:19.758319][stream.hls][debug] Segment 4594 complete [16:48:19.840551][stream.hls][debug] Writing segment 4595 to output [16:48:19.842552][stream.hls][debug] Segment 4595 complete [16:48:19.895645][plugins.twitch][info] Encountered an ad segment, re-execing to retrieve a new playlist C:\Users\name>[16:48:20.281398][cli][debug] OS: Windows 10 [16:48:20.281398][cli][debug] Python: 3.10.8 [16:48:20.282498][cli][debug] Streamlink: 5.1.2 [16:48:20.283491][cli][debug] Dependencies: [16:48:20.284492][cli][debug] certifi: 2022.9.24 [16:48:20.285494][cli][debug] isodate: 0.6.1 [16:48:20.286494][cli][debug] lxml: 4.9.1 [16:48:20.286494][cli][debug] pycountry: 22.3.5 [16:48:20.287495][cli][debug] pycryptodome: 3.16.0 [16:48:20.287495][cli][debug] PySocks: 1.7.1 [16:48:20.288496][cli][debug] requests: 2.28.1 [16:48:20.290498][cli][debug] urllib3: 1.26.13 [16:48:20.290498][cli][debug] websocket-client: 1.4.2 [16:48:20.296502][cli][debug] Arguments: [16:48:20.297504][cli][debug] url=twitch.tv/symfuhny [16:48:20.298505][cli][debug] stream=['best'] [16:48:20.298505][cli][debug] --loglevel=trace [16:48:20.298505][cli][debug] --player="C:\Program Files (x86)\mpv\mpv.exe" [16:48:20.299505][cli][debug] --ffmpeg-ffmpeg=C:\Users\name\AppData\Local\Streamlink\ffmpeg\ffmpeg.exe [16:48:20.299505][cli][debug] --twitch-proxy-playlist=['https://api.ttv.lol'] [16:48:20.299505][cli][debug] --twitch-reexec-on-ad=True [16:48:20.300506][cli][info] Found matching plugin twitch for URL twitch.tv/symfuhny [16:48:20.300506][plugins.twitch][debug] Getting live HLS streams for symfuhny [16:48:20.301507][plugins.twitch][info] Using playlist proxy 'https://api.ttv.lol' [16:48:20.301507][plugins.twitch][debug] Raw playlist proxy URL: 'https://api.ttv.lol/playlist/symfuhny.m3u8%3Fplayer%3Dtwitchweb%26type%3Dany%26allow_source%3Dtrue%26allow_audio_only%3Dtrue%26allow_spectre%3Dfalse%26fast_bread%3Dtrue' [16:48:20.334773][utils.l10n][debug] Language code: en_US [16:48:21.606445][cli][info] Available streams: audio_only, 160p (worst), 360p, 480p, 720p60, 936p60 (best) [16:48:21.606445][cli][info] Opening stream: 936p60 (hls) [16:48:21.607446][cli][info] Starting player: "C:\Program Files (x86)\mpv\mpv.exe" [16:48:21.608447][stream.hls][debug] Reloading playlist [16:48:21.608447][cli][debug] Pre-buffering 8192 bytes [16:48:22.036320][stream.hls][debug] First Sequence: 4585; Last Sequence: 4598 [16:48:22.036320][stream.hls][debug] Start offset: 0; Duration: None; Start Sequence: 4596; End Sequence: None [16:48:22.037322][stream.hls][debug] Adding segment 4596 to queue [16:48:22.038323][stream.hls][debug] Adding segment 4597 to queue [16:48:22.038323][stream.hls][debug] Adding segment 4598 to queue [16:48:23.342669][stream.hls][debug] Writing segment 4596 to output [16:48:23.345673][stream.hls][debug] Segment 4596 complete [16:48:23.345673][cli.output][debug] Opening subprocess: "C:\Program Files (x86)\mpv\mpv.exe" --force-media-title=twitch.tv/symfuhny - [16:48:23.576672][stream.hls][debug] Writing segment 4597 to output [16:48:23.579674][stream.hls][debug] Segment 4597 complete [16:48:23.733033][stream.hls][debug] Writing segment 4598 to output [16:48:23.735034][stream.hls][debug] Segment 4598 complete [16:48:23.850652][cli][debug] Writing stream to output [16:48:28.052079][stream.hls][debug] Reloading playlist [16:48:28.533535][stream.hls][debug] Adding segment 4599 to queue [16:48:28.533535][stream.hls][debug] Adding segment 4600 to queue [16:48:28.535537][stream.hls][debug] Adding segment 4601 to queue [16:48:28.687455][stream.hls][debug] Writing segment 4599 to output [16:48:28.690458][stream.hls][debug] Segment 4599 complete [16:48:28.843906][stream.hls][debug] Writing segment 4600 to output [16:48:28.846909][stream.hls][debug] Segment 4600 complete [16:48:29.001512][stream.hls][debug] Writing segment 4601 to output [16:48:29.003726][stream.hls][debug] Segment 4601 complete [16:48:31.656137][cli][info] Player closed [16:48:31.656137][stream.segmented][debug] Closing worker thread [16:48:31.657137][stream.segmented][debug] Closing writer thread [16:48:31.657137][stream.segmented][debug] Closing writer thread [16:48:31.658138][cli][info] Stream ended [16:48:31.658138][cli][info] Closing currently open stream...

My GUI Log launching mpv looks something like this:

[2023-03-23T17:15:41.710Z][debug][StreamingService] Spawning process { "exec": "C:\Users\name\AppData\Local\Streamlink\bin\streamlinkw.exe", "params": [ "--twitch-proxy-playlist=https://api.ttv.lol", "--twitch-reexec-on-ad", "--twitch-low-latency", "--player", "C:\Program Files (x86)\mpv\mpv.exe", "--player-args", "--profile=StreamProfile --script-opts=osc-visibility=never --keep-open=no \"--title=$>Tfue - Fortnite - 30 Kill Solo Attempts into Speedfue\" \"--force-media-title=Tfue - Fortnite - 30 Kill Solo Attempts into Speedfue\" --force-window=yes --force-seekable=yes --hr-seek=yes --hr-seek-framedrop=yes --cache=no", "--hls-live-edge", "1", "--stream-segment-threads", "1", "--retry-open", "1", "--retry-streams", "1", "twitch.tv/tfue", "best" ], "env": null }

If I'm doing something wrong or it's not intended to be used with Streamlink Twitch GUI then I apologise.

2bc4 commented 1 year ago

I reproduced this, it seems like it's the spaces in the path of C:\Program Files (x86)\mpv\mpv.exe. It works if the mpv folder is in for example the Documents folder because there aren't any spaces.

I'll think of a different method to pass the args to os.execv.