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

Always treat queries that start with ? as search queries #489

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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