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

Some weird console outputs while requesting video info #128

Open
bigelle opened this issue Mar 21, 2024 · 6 comments
Open

Some weird console outputs while requesting video info #128

bigelle opened this issue Mar 21, 2024 · 6 comments

Comments

@bigelle
Copy link

bigelle commented Mar 21, 2024

I was trying to run this block of code:

public File getFile() {
        Config config = new Config.Builder().maxRetries(1).build();
        YoutubeDownloader downloader = new YoutubeDownloader(config);

        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter your query: ");
        String query = scanner.nextLine();

        RequestSearchResult searchRequest = new RequestSearchResult(query)
                .forceExactQuery(true)
                .sortBy(SortField.RELEVANCE);
        SearchResultItem result = downloader.search(searchRequest).data().items().getFirst();

        String videoId = result.asVideo().videoId();
        RequestVideoInfo videoRequest = new RequestVideoInfo(videoId)
                .callback(new YoutubeCallback<VideoInfo>() {
                    @Override
                    public void onFinished(VideoInfo videoInfo) {
                        System.out.println("Finished parsing");
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        System.out.println("Error: " + throwable.getMessage());
                    }
                })
                .async();
        Response<VideoInfo> response = downloader.getVideoInfo(videoRequest);
        VideoInfo video = response.data();
        }

and while getting response ive got this html(?) document in the console:

"navigationEndpoint":{"commandMetadata":{"webCommandMetadata":{"rootVe":3832,"webPageType":"WEB_PAGE_TYPE_WATCH","url":"/watch?v=4NRXx6U8ABQ&list=RD4NRXx6U8ABQ&start_radio=1"}},"clickTrackingParams":"CMkCELs3GAMiEwj24vzttoWFAxVT008IHa_lAdQyBnNlYXJjaA==","watchEndpoint":{"playlistId":"RD4NRXx6U8ABQ","watchEndpointSupportedOnesieConfig":{"html5PlaybackOnesieConfig":{"commonConfig":{"url":"https://rr2---sn-cxxapox31-unxs.googlevideo.com/initplayback?source=youtube&oeis=1&c=WEB&oad=3200&ovd=3200&oaad=11000&oavd=11000&ocs=700&oewis=1&oputc=1&ofpcc=1&msp=1&odepv=1&id=e0d457c7a53c0014&ip=46.34.192.151&initcwndbps=1330000&mt=1711026304&oweuc=&pxtags=Cg4KAnR4Egg1MTExODU2NQ&rxtags=Cg4KAnR4Egg1MTExODU2MQ%2CCg4KAnR4Egg1MTExODU2Mg%2CCg4KAnR4Egg1MTExODU2Mw%2CCg4KAnR4Egg1MTExODU2NA%2CCg4KAnR4Egg1MTExODU2NQ%2CCg4KAnR4Egg1MTExODU2Ng%2CCg4KAnR4Egg1MTExODU2Nw"}}},"videoId":"4NRXx6U8ABQ","params":"wAEB","loggingContext":{"vssLoggingContext":{"serializedContextData":"Gg1SRDROUlh4NlU4QUJR"}}}}}},{"childVideoRenderer":{"lengthText":{"simpleText":"4:34","accessibility":{"accessibilityData":{"label":"4 минут 34 секунд"}}},"videoId":"34Na4j8AVgA","title":{"simpleText":"The Weeknd - Starboy ft. Daft Punk (Official Video)"},"navigationEndpoint":{"commandMetadata":{"webCommandMetadata":{"rootVe":3832,"webPageType":"WEB_PAGE_TYPE_WATCH","url":"/watch?v=34Na4j8AVgA&list=RD4NRXx6U8ABQ&start_radio=1"}},"clickTrackingParams":"CMkCELs3GAMiEwj24vzttoWFAxVT008IHa_lAdQyBnNlYXJjaA==","watchEndpoint":{"playlistId":"RD4NRXx6U8ABQ","watchEndpointSupportedOnesieConfig":{"html5PlaybackOnesieConfig":{"commonConfig":{"url":"https://rr2---sn-cxxapox31-unxs.googlevideo.com/initplayback?source=youtube&oeis=1&c=WEB&oad=3200&ovd=3200&oaad=11000&oavd=11000&ocs=700&oewis=1&oputc=1&ofpcc=1&msp=1&odepv=1&id=df835ae23f005600&ip=46.34.192.151&initcwndbps=1330000&mt=1711026304&oweuc=&pxtags=Cg4KAnR4Egg1MTExODU2NQ&rxtags=Cg4KAnR4Egg1MTExODU2MQ%2CCg4KAnR4Egg1MTExODU2Mg%2CCg4KAnR4Egg1MTExODU2Mw%2CCg4KAnR4Egg1MTExODU2NA%2CCg4KAnR4Egg1MTExODU2NQ%2CCg4KAnR4Egg1MTExODU2Ng%2CCg4KAnR4Egg1MTExODU2Nw"}}},"videoId":"34Na4j8AVgA","params":"wAEB","loggingContext":{"vssLoggingContext":{"serializedContextData":"Gg1SRDROUlh4NlU4QUJR"}}}}}}],"title":{"simpleText":"Микс – The Weeknd - Blinding Lights (Official Video)"},"thumbnailOverlays":[{"thumbnailOverlayBottomPanelRenderer":{"icon":{"iconType":"MIX"},"text":{"simpleText":"Mикс"}}},{"thumbnailOverlayHoverTextRenderer":{"icon":{"iconType":"PLAY_ALL"},"text":{"runs":[{"text":"Барлығын ойнату"}]}}},{"thumbnailOverlayNowPlayingRenderer":{"text":{"runs":[{"text":"Қазір ойнатылуда"}]}}}],"longBylineText":{"simpleText":"The Weeknd және т.б."},"navigationEndpoint":{"commandMetadata":{"webCommandMetadata":{"rootVe":3832,"webPageType":"WEB_PAGE_TYPE_WATCH","url":"/watch?v=4NRXx6U8ABQ&list=RD4NRXx6U8ABQ&start_radio=1"}},"clickTrackingParams":"CMkCELs3GAMiEwj24vzttoWFAxVT008IHa_lAdQyBnNlYXJjaA==","watchEndpoint":{"playlistId":"RD4NRXx6U8ABQ","watchEndpointSupportedOnesieConfig":{"html5PlaybackOnesieConfig":{"commonConfig":{"url":"https://rr2---sn-cxxapox31-unxs.googlevideo.com/initplayback?source=youtube&oeis=1&c=WEB&oad=3200&ovd=3200&oaad=11000&oavd=11000&ocs=700&oewis=1&oputc=1&ofpcc=1&msp=1&odepv=1&id=e0d457c7a53c0014&ip=46.34.192.151&initcwndbps=1330000&mt=1711026304&oweuc=&pxtags=Cg4KAnR4Egg1MTExODU2NQ&rxtags=Cg4KAnR4Egg1MTExODU2MQ%2CCg4KAnR4Egg1MTExODU2Mg%2CCg4KAnR4Egg1MTExODU2Mw%2CCg4KAnR4Egg1MTExODU2NA%2CCg4KAnR4Egg1MTExODU2NQ%2CCg4KAnR4Egg1MTExODU2Ng%2CCg4KAnR4Egg1MTExODU2Nw"}}},"continuePlayback":true,"videoId":"4NRXx6U8ABQ","params":"OALAAQE%3D","loggingContext":{"vssLoggingContext":{"serializedContextData":"Gg1SRDROUlh4NlU4QUJR"}}}},"thumbnailRenderer":{"playlistVideoThumbnailRenderer":{"thumbnail":{"thumbnails":[{"width":168,"url":"https://i.ytimg.com/vi/4NRXx6U8ABQ/hqdefault.jpg?sqp=-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ==&rs=AOn4CLC5mMM9wTGWWELNWkLpoX7axxB7lQ","height":94},{"width":196,"url":"https://i.ytimg.com/vi/4NRXx6U8ABQ/hqdefault.jpg?sqp=-oaymwEWCMQBEG5IWvKriqkDCQgBFQAAiEIYAQ==&rs=AOn4CLACbDtK2wbPadpyu1-QIzE1zgOTEw","height":110},{"width":246,"url":"https://i.ytimg.com/vi/4NRXx6U8ABQ/hqdefault.jpg?sqp=-oaymwEXCPYBEIoBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLB_Veqo7XFv4sDGJHEQFh06fYaXWg","height":138},{"width":336,"url":"https://i.ytimg.com/vi/4NRXx6U8ABQ/hqdefault.jpg?sqp=-oaymwEXCNACELwBSFryq4qpAwkIARUAAIhCGAE=&rs=AOn4CLDfAV_i3cp4LQLuMxiom0Gfpq4MHQ","height":188}]},"trackingParams":"CMoCEMvsCSITCPbi_O22hYUDFVPTTwgdr-UB1A=="}}}}
Unknown search result element type reelShelfRenderer
{"reelShelfRenderer":{"button":{"menuRenderer":{"trackingParams":"CJwBEN-DAxgNIhMI9uL87baFhQMVU9NPCB2v5QHU","accessibility":{"accessibilityData":{"label":"Қосымша әрекеттер"}},"items":[{"menuNavigationItemRenderer":{"trackingParams":"CJwBEN-DAxgNIhMI9uL87baFhQMVU9NPCB2v5QHU","accessibility":{"accessibilityData":{"label":"Пікір жіберу"}},"icon":{"iconType":"FEEDBACK"},"text":{"runs":[{"text":"Пікір жіберу"}]},"navigationEndpoint":{"commandMetadata":{"webCommandMetadata":{"ignoreNavigation":true}},"clickTrackingParams":"CJwBEN-DAxgNIhMI9uL87baFhQMVU9NPCB2v5QHU","userFeedbackEndpoint":{"additionalDatas":[{"userFeedbackEndpointProductSpecificValueData":{"value":"shelf","key":"lockup"}}]}}}}]}},"trackingParams":"CJwBEN-DAxgNIhMI9uL87baFhQMVU9NPCB2v5QHU","icon":{"iconType":"YOUTUBE_SHORTS_BRAND_24"},"title":{"simpleText":"Shorts"},"items":[{"reelItemRenderer":{"inlinePlaybackEndpoint":{"commandMetadata":{"webCommandMetadata":{"rootVe":3832,"webPageType":"WEB_PAGE_TYPE_WATCH","url":"/watch?v=Ex-_hdJjYO0&pp=YAHIAQHwAQG6AwIYAugFAaIGFQHV2fo7EiiGhF5rtq4RHv6G0ZTLLQ%3D%3D"}},

...and so on.

This code is working well but idk if i can get rid off this console output

@Brad1944
Copy link

Brad1944 commented May 5, 2024

From a quick google search I found that this happens when a query returned a youtube shorts video, which the library doesn't really know what to do yet

@sealedtx
Copy link
Owner

sealedtx commented May 5, 2024

@Brad1944 are you sure about that? As far as I know youtube shorts video under the hood is same as regular youtube video and could be opened as regular video by videoId as https://www.youtube.com/watch?v={videoId}

@Brad1944
Copy link

Brad1944 commented May 6, 2024

@sealedtx Can't really confirm since I haven't really dug into the code. Though a quick search led me to this github issue and this commit

@dadoonet
Copy link

I'm seeing similar behavior on my side. Any idea on how to hide those messages?

@bigelle
Copy link
Author

bigelle commented Sep 21, 2024

I'm seeing similar behavior on my side. Any idea on how to hide those messages?

I did it by temporarily redirecting outputstream, something like:

// you're other code...

// redirecting outputstream to empty ByteArrayOutputStream:
PrintStream original = System.out
System.setOut(new PrintStream(new ByteArrayOutputStream))

// get your video...

//restoring original outputstream:
System.setOut(original)

I forgot where exactly you should put this code, but it's somewhere before and after getting your video

@dadoonet
Copy link

Nice hack! Thanks a lot!

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

No branches or pull requests

4 participants