From 9c1d43e772efb8f5af4b7ef5562fb433c8985697 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 29 Oct 2022 21:33:18 +0200 Subject: Youtube: allow opening youtube channels directly from url. Same with ctrl+i info menu --- src/QuickMedia.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/QuickMedia.cpp') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 13931d2..69ac66e 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -318,7 +318,7 @@ namespace QuickMedia { } static void usage() { - fprintf(stderr, "usage: quickmedia [plugin] [--no-video] [--dir ] [-e ] [youtube-url]\n"); + fprintf(stderr, "usage: quickmedia [plugin] [--no-video] [--upscale-images] [--upscale-images-always] [--dir ] [--instance ] [-e ] [--video-max-height ] [youtube-url] [youtube-channel-url]\n"); fprintf(stderr, "OPTIONS:\n"); fprintf(stderr, " plugin The plugin to use. Should be either launcher, 4chan, manga, manganelo, manganelos, mangatown, mangakatana, mangadex, readm, onimanga, local-manga, local-anime, youtube, peertube, lbry, soundcloud, nyaa.si, matrix, saucenao, hotexamples, anilist, dramacool, file-manager, stdin, pornhub, spankbang, xvideos or xhamster\n"); fprintf(stderr, " --no-video Only play audio when playing a video. Disabled by default\n"); @@ -387,11 +387,17 @@ namespace QuickMedia { for(int i = 1; i < argc; ++i) { if(!plugin_name) { - std::string youtube_video_id_dummy; std::string youtube_url_converted = invidious_url_to_youtube_url(argv[i]); - if(youtube_url_extract_id(youtube_url_converted, youtube_video_id_dummy)) { + std::string youtube_channel_id; + std::string youtube_video_id_dummy; + + if(youtube_url_extract_channel_id(youtube_url_converted, youtube_channel_id, youtube_channel_url)) { + plugin_name = "youtube"; + continue; + } else if(youtube_url_extract_id(youtube_url_converted, youtube_video_id_dummy)) { youtube_url = std::move(youtube_url_converted); plugin_name = "youtube"; + continue; } for(const auto &valid_plugin : valid_plugins) { @@ -1308,7 +1314,14 @@ namespace QuickMedia { pipe_body->set_items(std::move(body_items)); tabs.push_back(Tab{std::move(pipe_body), std::make_unique(this), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); } else if(strcmp(plugin_name, "youtube") == 0) { - if(youtube_url.empty()) { + if(!youtube_channel_url.empty()) { + auto youtube_channel_page = std::make_unique(this, youtube_channel_url, "", "Channel videos"); + tabs.push_back(Tab{create_body(false, true), std::move(youtube_channel_page), create_search_bar("Search...", 350)}); + } else if(!youtube_url.empty()) { + current_page = PageType::VIDEO_CONTENT; + auto youtube_video_page = std::make_unique(this, youtube_url, false); + video_content_page(nullptr, youtube_video_page.get(), "", false, nullptr, 0); + } else { start_tab_index = 1; tabs.push_back(Tab{create_body(false, true), std::make_unique(this), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); tabs.push_back(Tab{create_body(false, true), std::make_unique(this), create_search_bar("Search...", 100)}); @@ -1316,10 +1329,6 @@ namespace QuickMedia { auto history_body = create_body(false, true); auto history_page = std::make_unique(this, tabs.front().page.get(), HistoryType::YOUTUBE); tabs.push_back(Tab{std::move(history_body), std::move(history_page), create_search_bar("Search...", SEARCH_DELAY_FILTER)}); - } else { - current_page = PageType::VIDEO_CONTENT; - auto youtube_video_page = std::make_unique(this, youtube_url, false); - video_content_page(nullptr, youtube_video_page.get(), "", false, nullptr, 0); } } else if(strcmp(plugin_name, "peertube") == 0) { if(instance.empty()) { -- cgit v1.2.3