From 0dc3940a3392c3c5c294da865b707d831c9277b1 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Fri, 23 Aug 2024 02:36:32 +0300 Subject: [PATCH] Always treat queries that start with `?` as search queries --- .../Resolving/QueryResolver.cs | 16 +++++++++++----- .../Views/Components/DashboardView.axaml | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/YoutubeDownloader.Core/Resolving/QueryResolver.cs b/YoutubeDownloader.Core/Resolving/QueryResolver.cs index 11a0326dd..05791c87b 100644 --- a/YoutubeDownloader.Core/Resolving/QueryResolver.cs +++ b/YoutubeDownloader.Core/Resolving/QueryResolver.cs @@ -111,11 +111,17 @@ private async Task ResolveSearchAsync( public async Task ResolveAsync( string query, CancellationToken cancellationToken = default - ) => - await TryResolvePlaylistAsync(query, cancellationToken) - ?? await TryResolveVideoAsync(query, cancellationToken) - ?? await TryResolveChannelAsync(query, cancellationToken) - ?? await ResolveSearchAsync(query, cancellationToken); + ) + { + // If the query starts with a question mark, it's always treated as a search query + if (query.StartsWith('?')) + return await ResolveSearchAsync(query[1..], cancellationToken); + + return await TryResolvePlaylistAsync(query, cancellationToken) + ?? await TryResolveVideoAsync(query, cancellationToken) + ?? await TryResolveChannelAsync(query, cancellationToken) + ?? await ResolveSearchAsync(query, cancellationToken); + } public async Task ResolveAsync( IReadOnlyList queries, diff --git a/YoutubeDownloader/Views/Components/DashboardView.axaml b/YoutubeDownloader/Views/Components/DashboardView.axaml index 98ef0e25c..40cccbba8 100644 --- a/YoutubeDownloader/Views/Components/DashboardView.axaml +++ b/YoutubeDownloader/Views/Components/DashboardView.axaml @@ -27,6 +27,7 @@ ScrollViewer.HorizontalScrollBarVisibility="Hidden" Text="{Binding Query}" Theme="{DynamicResource SoloTextBox}" + ToolTip.Tip="Any valid YouTube URL or ID is accepted. Prepend a question mark (?) to perform search by text." Watermark="URL or search query">