mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
add: Added .q support for invidious. If you have ytProvider set to invidious in data/searches.yml, invidious will be used to queue up songs and play them."work
This commit is contained in:
@@ -5,5 +5,59 @@ namespace NadekoBot.Modules.Searches;
|
||||
public sealed class InvidiousSearchResponse
|
||||
{
|
||||
[JsonPropertyName("videoId")]
|
||||
public string VideoId { get; set; } = null!;
|
||||
public required string VideoId { get; init; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public required string Title { get; init; }
|
||||
|
||||
[JsonPropertyName("videoThumbnails")]
|
||||
public required List<InvidiousThumbnail> Thumbnails { get; init; }
|
||||
|
||||
[JsonPropertyName("lengthSeconds")]
|
||||
public required int LengthSeconds { get; init; }
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public required string Description { get; init; }
|
||||
}
|
||||
|
||||
public sealed class InvidiousVideoResponse
|
||||
{
|
||||
[JsonPropertyName("title")]
|
||||
public required string Title { get; init; }
|
||||
|
||||
[JsonPropertyName("videoId")]
|
||||
public required string VideoId { get; init; }
|
||||
|
||||
[JsonPropertyName("lengthSeconds")]
|
||||
public required int LengthSeconds { get; init; }
|
||||
|
||||
[JsonPropertyName("videoThumbnails")]
|
||||
public required List<InvidiousThumbnail> Thumbnails { get; init; }
|
||||
|
||||
[JsonPropertyName("adaptiveFormats")]
|
||||
public required List<InvidiousAdaptiveFormat> AdaptiveFormats { get; init; }
|
||||
}
|
||||
|
||||
public sealed class InvidiousAdaptiveFormat
|
||||
{
|
||||
[JsonPropertyName("url")]
|
||||
public required string Url { get; init; }
|
||||
|
||||
[JsonPropertyName("audioQuality")]
|
||||
public string? AudioQuality { get; init; }
|
||||
}
|
||||
|
||||
public sealed class InvidiousPlaylistResponse
|
||||
{
|
||||
[JsonPropertyName("title")]
|
||||
public required string Title { get; init; }
|
||||
|
||||
[JsonPropertyName("videos")]
|
||||
public required List<InvidiousVideoResponse> Videos { get; init; }
|
||||
}
|
||||
|
||||
public sealed class InvidiousThumbnail
|
||||
{
|
||||
[JsonPropertyName("url")]
|
||||
public required string Url { get; init; }
|
||||
}
|
@@ -32,13 +32,14 @@ public sealed class InvidiousYtSearchService : IYoutubeSearchService, INService
|
||||
|
||||
var instance = instances[_rng.Next(0, instances.Count)];
|
||||
|
||||
var url = $"{instance}/api/v1/search"
|
||||
+ $"?q={query}"
|
||||
+ $"&type=video";
|
||||
using var http = _http.CreateClient();
|
||||
var res = await http.GetFromJsonAsync<List<InvidiousSearchResponse>>(
|
||||
$"{instance}/api/v1/search"
|
||||
+ $"?q={query}"
|
||||
+ $"&type=video");
|
||||
url);
|
||||
|
||||
if (res is null or {Count: 0})
|
||||
if (res is null or { Count: 0 })
|
||||
return null;
|
||||
|
||||
return new VideoInfo(res[0].VideoId);
|
||||
|
Reference in New Issue
Block a user