Code Monkey home page Code Monkey logo

Comments (4)

Tyrrrz avatar Tyrrrz commented on June 2, 2024

What is the problem? Are you getting an error or something else? It's not clear from the title nor the description

from youtubeexplode.

pvogt avatar pvogt commented on June 2, 2024

What is the problem? Are you getting an error or something else? It's not clear from the title nor the description

When doing a search for "Mystery at Blind Frog Ranch", the error I get is:
'Failed to extract the video channel ID.'

The reason is because the search encounters a video, where in order to watch the video, you have to 'Buy' it.

If you go to these Youtube URLs:
https://www.youtube.com/show/SCTlUsX7ucO3lLjmpYmbZKPg
https://www.youtube.com/show/SC5q_AUmH7GP_hCdqCc1QQXw
you can see that you have to pay to watch the episodes.

Any search results that tries to get the channel ID from episodes similar to the two links above, the search fails to extract the channel ID.

It seems the json structure changes when a search finds a normal video and a 'Buy' TV show video:
https://codebeautify.org/json-decode-online/y249b1c25
shows the JSON info for two Youtube videos.
The first (search) node is the "Buy" video that causes the 'Failed to extract the video channel ID.' error, and the second node is a normal video that would parse correctly if the search did not error on the first result.
If you look at the online JSON viewer, there is a channel ID for the first node, but it's listed under a different structure to that of a normal video.
"Buy" video structure:
videoRenderer > channelThumbnailSupportedRenderers > channelThumbnailWithLinkRenderer > navigationEndpoint > browseEndpoint > browseId
Normal Youtube video structure:
videoRenderer > longBylineText > runs > 0 > navigationEndpoint > browseEndpoint > browseId

from youtubeexplode.

pvogt avatar pvogt commented on June 2, 2024

I may have found a solution, whether it's a proper way or not, I don't know.
In the SearchResponse.cs file, on line 86, modify:

public string? ChannelId =>
    AuthorDetails
        ?.GetPropertyOrNull("navigationEndpoint")
        ?.GetPropertyOrNull("browseEndpoint")
        ?.GetPropertyOrNull("browseId")
        ?.GetStringOrNull();

to:

public string? ChannelId =>
    AuthorDetails
        ?.GetPropertyOrNull("navigationEndpoint")
        ?.GetPropertyOrNull("browseEndpoint")
        ?.GetPropertyOrNull("browseId")
        ?.GetStringOrNull()
    ?? content
        .GetPropertyOrNull("channelThumbnailSupportedRenderers")
        ?.GetPropertyOrNull("channelThumbnailWithLinkRenderer")
        ?.GetPropertyOrNull("navigationEndpoint")
        ?.GetPropertyOrNull("browseEndpoint")
        ?.GetPropertyOrNull("browseId")
        ?.GetStringOrNull();

I've tested it multiple times and I was able to print the channel ID using the search query: "Mystery at Blind Frog Ranch"
Without the "?? content" section, searching gave me the "Failed to extract the video channel ID." error.

from youtubeexplode.

Tyrrrz avatar Tyrrrz commented on June 2, 2024

Ok, thank you for the clarification.

If you have a solution, feel free to make a PR so we can test it out.

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.