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

Implement a parser simular youtubei.js #15

Open
walking-octopus opened this issue Aug 8, 2022 · 7 comments
Open

Implement a parser simular youtubei.js #15

walking-octopus opened this issue Aug 8, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@walking-octopus
Copy link
Contributor

walking-octopus commented Aug 8, 2022

Currently, this project uses error-prone and difficult to maintain manual parsing for each response type. Implementing a YouTube.js-inspired parser would help to get rid of unnecessary unwraps, add a layer of abstraction for creating new API endpoints, and make the project more maintainable. Maybe a macro could be made for parsing the InnerTube responses.

@89Q12
Copy link
Owner

89Q12 commented Aug 8, 2022 via email

@walking-octopus
Copy link
Contributor Author

Thanks for the response. I'll look into it. I just wanted to create an issue for tracking the progress.

@89Q12 89Q12 added the enhancement New feature or request label Aug 10, 2022
@89Q12
Copy link
Owner

89Q12 commented Aug 10, 2022

So I thought about it and the main problem we would face is that we have to use type Option<T> anyways or we could generate new() for every type since we need to type out the api anyway since I wanna stay idiomatic and not work with the BTree serde_json provides^^ Providing defaults for every type would create the same 'problem' we currently have with all the unwrap calls

@walking-octopus
Copy link
Contributor Author

I think fetching any data should return a Result so we could propagate any parsing errors.
As for parsing the InnerTube responses, maybe iterators could parse everything, returning an Option or a Result for any missing data.

YouTube.js's parser is mostly typesafe, so maybe some inspiration could be taken.

@walking-octopus
Copy link
Contributor Author

Is there any kind of InnerTube schema that can be used to validate the JSON?

@89Q12
Copy link
Owner

89Q12 commented Aug 12, 2022

Nope, hence I chose the option to parse via serde_json

@89Q12
Copy link
Owner

89Q12 commented Aug 12, 2022

But using serde_json has the disadvantage of not given good error messages but is also easy to use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants