Getting "get_video_info?video_id" when trying to get title of YouTube video

This forum is about all development around libVLC.
trofchik
New Cone
New Cone
Posts: 4
Joined: 20 Mar 2021 15:00

Getting "get_video_info?video_id" when trying to get title of YouTube video

Postby trofchik » 04 Oct 2021 12:38

Hello, thanks for stopping by.
The "get_title()" function in my program is responsible for getting video title. It is used in a loop to return titles of 5 previous tracks, currently played track and 5 tracks after it. Loop is run each time a new track starts to play. The code bellow is written for testing purposes so you could easily check the problem on your PC if you desire so.

Code: Select all

// main.cpp std::string get_title( std::string song_mrl ) { const char *const arg[] = {"--preferred-resolution=720", "--no-video"}; std::shared_ptr<VLC::Instance> dummy = std::make_shared<VLC::Instance>(VLC::Instance(2, arg)); VLC::Media media = VLC::Media(*dummy, song_mrl, VLC::Media::FromLocation); media.parseWithOptions(VLC::Media::ParseFlags::Network, -1); while (media.parsedStatus() != VLC::Media::ParsedStatus::Done) { } return media.subitems()->itemAtIndex(0)->meta(libvlc_meta_Title); } int main() { const std::array<const std::string, 3> mrls = { "https://youtu.be/QzqZ1RY1seQ", "https://youtu.be/sO8d1CIFV8w", "https://youtu.be/rtL5oMyBHPs" }; for (int i = 0; i < 30; i++) { std::cout << get_title(mrls[0]) << std::endl; std::cout << get_title(mrls[1]) << std::endl; std::cout << get_title(mrls[2]) << std::endl; std::cout << std::endl; } return 0; }

Code: Select all

# CMakeLIsts.txt cmake_minimum_required(VERSION 3.18) # probably can be set to lower version, didn't check project( vlc_title_test LANGUAGES CXX C ) set(LIBVLC_HEADERS /usr/include/vlc ) set(LIBVLC_STATIC /usr/lib64 ) add_library(libvlc SHARED IMPORTED GLOBAL) set_target_properties(libvlc PROPERTIES IMPORTED_LOCATION ${LIBVLC_STATIC}/libvlc.so INTERFACE_INCLUDE_DIRECTORIES ${LIBVLC_HEADERS} LINKER_LANGUAGE C ) add_executable(vlc_title_test main.cpp) set_target_properties(vlc_title_test PROPERTIES LINKER_LANGUAGE CXX ) target_link_libraries(vlc_title_test PRIVATE libvlc)
The problem occurs slightly less frequently when build type is set to "Release" (add -DCMAKE_BUILD_TYPE=Release when preconfiguring with CMake). On my PC in "Debug" mode code above always show get_video_info?video_id in place of second song's title.

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Getting "get_video_info?video_id" when trying to get title of YouTube video

Postby Rémi Denis-Courmont » 05 Oct 2021 12:56

Obviously, it's not a very smart choice but that's the best guess at a title that the engine came up with. I don't think that there is anything to do in your C++ code.

You're welcome to propose improvement patches to LibVLC.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

trofchik
New Cone
New Cone
Posts: 4
Joined: 20 Mar 2021 15:00

Re: Getting "get_video_info?video_id" when trying to get title of YouTube video

Postby trofchik » 05 Oct 2021 15:20

Obviously, it's not a very smart choice but that's the best guess at a title that the engine came up with. I don't think that there is anything to do in your C++ code.

You're welcome to propose improvement patches to LibVLC.
Thank you.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 9 guests