Skip to content

Commit

Permalink
Revert "made filter optional"
Browse files Browse the repository at this point in the history
  • Loading branch information
UnidentifiedX authored Aug 14, 2024
1 parent 334e0b7 commit 9c3ca40
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/YTSearch.NET/YouTubeSearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ public YouTubeSearchClient()
/// </summary>
/// <param name="query">Query string</param>
/// <returns><seealso cref="YouTubeSearchResult"/></returns>
public async Task<YouTubeVideoSearchResult> SearchYoutubeVideoAsync(string query, bool filter = true)
public async Task<YouTubeVideoSearchResult> SearchYoutubeVideoAsync(string query)
{
var searchResults = new List<SearchedYouTubeVideo>();
query = HttpUtility.UrlEncode(query);

var url = $"https://www.youtube.com/results?search_query={query}";

if(filter)
url += "&sp=EgIQAQ%253D%253D";
var url = $"https://www.youtube.com/results?search_query={query}&sp=EgIQAQ%253D%253D";

var result = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url));
var content = await result.Content.ReadAsStringAsync();
Expand All @@ -62,15 +59,12 @@ public async Task<YouTubeVideoSearchResult> SearchYoutubeVideoAsync(string query
return new YouTubeVideoSearchResult(query, url, searchResults);
}

public async Task<YouTubeChannelSearchResult> SearchYouTubeChannelAsync(string query, bool filter = true)
public async Task<YouTubeChannelSearchResult> SearchYouTubeChannelAsync(string query)
{
var searchResults = new List<SearchedYouTubeChannel>();
query = HttpUtility.UrlEncode(query);

var url = $"https://www.youtube.com/results?search_query={query}";

if(filter)
url += "&sp=EgIQAg%253D%253D";
var url = $"https://www.youtube.com/results?search_query={query}&sp=EgIQAg%253D%253D";

var result = await _httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get, url));
var content = await result.Content.ReadAsStringAsync();
Expand Down Expand Up @@ -258,4 +252,4 @@ private static TimeSpan ParseVideoLength(string? timespan)
}
}
}
}
}

0 comments on commit 9c3ca40

Please sign in to comment.