Giter Club home page Giter Club logo

Comments (16)

Tyrrrz avatar Tyrrrz commented on May 12, 2024

I get
Error 404 -> Video 1,2,4
Error 410 -> Video 3,5,6,7
Looks like some of the streams were deleted for whatever reason but the references still remain in the get_video_info API.
The only thing the videos seem to have in common is that they all have very few available qualities - either 144p and 240p or only 360p.

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

I really don't want to add try/catch blocks to the HTTP requests... Maybe we can just add a IHttpService.PingAsync(string url) and use it to see if the stream is alive?

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

Actually, instead of using response.EnsureSuccessStatusCode(); we can maually check if response.IsSuccessStatusCode and then act accordingly. I'd say just drop the stream (since it's not available anymore), but I haven't decided on what's the best implementation of this.

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

You mean like returning null from those methods if the code doesn't signify success? The problem is then IHttpService cannot guarantee all its implementation will follow that guideline. We can also just return HttpResponse to callers but I feel like it's an overkill, considering this is (so far) the only place where this would be needed. I think it's fine that they throw exceptions and then we can use bool CheckSuccessAsync(string url) only when we actually expect some url not to work (but still able to continue execution).

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

I do belive we can't get arround a (specific) try-catch, since

  1. As you said, we don't need to implement magic return values or out parameters
  2. Thats the purpose of those exceptions, to handle exceptions

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

Where exactly and what exception are you suggesting to catch?

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

Oh, I was wrong. I thought the http status code is in the exception data included.
When do you mean we should execute bool CheckSuccessAsync(string url)? Befor every time we execute IHttpService.GetHeadersAsync?

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

No, just for the streams I think

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

That's what I mean, currently it's every time ^^ But now I see what you are going for. I think you are talking about the mixed stream for loop in it's whole.
Hm, could be possible to do so

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

Oh yeah, I meant inside that loop instead of inside GetHeadersAsync or GetContentLengthAsync

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

But I'm still not sure about that exception design. I think there are many more error sources on some videos out there, we never can cover all posibilities. But when an error occured and from the GetVideoInfoAsync(id)-method just comes a HttpRequestException for example, I as library user would have no idea what to do to fix it. I think there should be at least a hint or something that's saying in which part of processing an error occured.

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

The thing is, if they are not using the default HttpService they might have a different exception and then YoutubeClient won't be able to handle it. :/

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

For example, if someone implements WebClientHttpService : IHttpService that uses WebClient instead of HttpClient, which would then throw WebException instead of HttpRequestException

from youtubeexplode.

BrunoZell avatar BrunoZell commented on May 12, 2024

Wouldn't it become an inner exception anyways?

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

Hmm. I meant that doing this:

try
{
    long contentLength = await GetContentLengthAsync(url).ConfigureAwait(false);
}
catch (HttpRequestException)
{
}

...isn't really safe because there's no guarantee the supplied _httpService will actually throw that exact exception on failure.

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on May 12, 2024

Ok on the second thought, sending CheckSuccessAsync on every stream is probably a bad idea. It's going to significantly increase the time it takes to do GetVideoInfoAsync...

from youtubeexplode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.