Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: fix pluginerror in handle_url if json is True #4590

Merged

Conversation

bastimeyer
Copy link
Member

Fixes #4589

console.exit(msg) requires a str parameter, otherwise it'll try to serialize the unknown input type as JSON if args.json is True, which can fail:

def exit(self, msg: str) -> None:
if self.json:
self.msg_json(error=msg)
else:
self.msg(f"error: {msg}")
sys.exit(1)

As already said in other threads, the ConsoleOutput usage and handling of console.exit() is pretty bad and needs to be rewritten.


@mkbloke
Copy link
Member

mkbloke commented Jun 13, 2022

This bombed before; it is working as expected now, thanks.

$ streamlink https://www.yupptv.com/channels/asianet-news/liveXXX
[cli][info] Found matching plugin yupptv for URL https://www.yupptv.com/channels/asianet-news/liveXXX
error: Unable to open URL: https://www.yupptv.com/channels/asianet-news/liveXXX (404 Client Error: Not Found for url: https://www.yupptv.com/channels/asianet-news/liveXXX)

$ streamlink -j https://www.yupptv.com/channels/asianet-news/liveXXX
{
  "error": "Unable to open URL: https://www.yupptv.com/channels/asianet-news/liveXXX (404 Client Error: Not Found for url: https://www.yupptv.com/channels/asianet-news/liveXXX)"
}

@bastimeyer bastimeyer force-pushed the cli/fix-handle-url-pluginerror branch from 9c69dc7 to f828f29 Compare June 13, 2022 04:43
@back-to back-to merged commit 1685c6c into streamlink:master Jun 13, 2022
@bastimeyer bastimeyer deleted the cli/fix-handle-url-pluginerror branch June 13, 2022 07:32
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using -j/--json option causes uncaught exception on 404 URLs
3 participants