Tyrrrz / YoutubeExplode

Abstraction layer over YouTube's internal API
MIT License
2.98k stars 497 forks source link

Return a more specific error message when playlist is unavailable #445

Closed derech1e closed 4 years ago

derech1e commented 4 years ago

Hey. The idea is to get a more detailed error message, of the fail reason from the download. For example, in the case of a private playlists, simply return a response that indicate that.

Youtube already has this feature: image

It would be very nice. Thank you!

bcwood commented 4 years ago

I've been doing some testing on this, and you can't differentiate between a playlist that is private, and a playlist that doesn't exist. In both cases, the response returned is 400 : Bad Request.

I could still improve the error message to say something along the lines of "This playlist cannot be found. It either does not exist, or is private." Would that be acceptable?

I'm thinking that I could mimic the implementation and usage of VideoUnavailableException.

Tyrrrz commented 4 years ago

Yeah, that message would be fine. The problem currently is that 400 is automatically handled by YoutubeHttpClient here:

https://github.com/Tyrrrz/YoutubeExplode/blob/530e9d678b586f892d198d667e4400cd3d495b85/YoutubeExplode/ReverseEngineering/YoutubeHttpClient.cs#L17-L34

You would either need to change PlaylistResponse.GetAsync() so that it passes ensureSuccess = false and checks everything itself or maybe rework this automatic error handling so it can work well in both scenarios.

bcwood commented 4 years ago

I was thinking the same thing. I think I'll probably go the route of passing ensureSuccess = false. I imagine that reworking that automatic error handling will have wide-reaching effects.