Skip to content

Commit

Permalink
Always treat queries that start with ? as search queries (#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz authored Aug 22, 2024
1 parent 5f5686e commit 4f2801b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions YoutubeDownloader.Core/Resolving/QueryResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,17 @@ private async Task<QueryResult> ResolveSearchAsync(
public async Task<QueryResult> 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<QueryResult> ResolveAsync(
IReadOnlyList<string> queries,
Expand Down
1 change: 1 addition & 0 deletions YoutubeDownloader/Views/Components/DashboardView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<TextBox.InnerLeftContent>
<materialIcons:MaterialIcon
Expand Down

0 comments on commit 4f2801b

Please sign in to comment.