Merge branch 'master' into dev

This commit is contained in:
EkiciLP 2022-03-24 08:58:55 +01:00
commit b532f19080
9 changed files with 27 additions and 18 deletions

@ -81,7 +81,7 @@ namespace TomatenMusic.Commands
{
if (response.isPlaylist)
{
LavalinkPlaylist playlist = response.Playlist;
ILavalinkPlaylist playlist = response.Playlist;
await player.PlayPlaylistNowAsync(playlist);
_ = ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(
@ -234,7 +234,7 @@ namespace TomatenMusic.Commands
{
if (response.isPlaylist)
{
LavalinkPlaylist playlist = response.Playlist;
ILavalinkPlaylist playlist = response.Playlist;
await player.PlayPlaylistAsync(playlist);
await ctx.EditResponseAsync(new DiscordWebhookBuilder().WithContent("Now Playing:").AddEmbed(

@ -8,7 +8,7 @@ using Lavalink4NET.Player;
namespace TomatenMusic.Music.Entitites
{
public interface LavalinkPlaylist
public interface ILavalinkPlaylist
{
public string Name { get; }
public IEnumerable<LavalinkTrack> Tracks { get; }

@ -5,7 +5,7 @@ using System.Text;
namespace TomatenMusic.Music.Entitites
{
public class SpotifyPlaylist : LavalinkPlaylist
public class SpotifyPlaylist : ILavalinkPlaylist
{
public string Name { get; }
public IEnumerable<LavalinkTrack> Tracks { get; }

@ -9,7 +9,7 @@ using TomatenMusic.Services;
namespace TomatenMusic.Music.Entitites
{
public class YoutubePlaylist : LavalinkPlaylist
public class YoutubePlaylist : ILavalinkPlaylist
{
public string Name { get; }

@ -111,7 +111,7 @@ namespace TomatenMusic.Music
QueuePrompt.UpdateFor(GuildId);
}
public async Task PlayPlaylistAsync(LavalinkPlaylist playlist)
public async Task PlayPlaylistAsync(ILavalinkPlaylist playlist)
{
EnsureNotDestroyed();
EnsureConnected();
@ -129,7 +129,7 @@ namespace TomatenMusic.Music
QueuePrompt.UpdateFor(GuildId);
}
public async Task PlayPlaylistNowAsync(LavalinkPlaylist playlist)
public async Task PlayPlaylistNowAsync(ILavalinkPlaylist playlist)
{
EnsureConnected();
EnsureNotDestroyed();

@ -8,11 +8,11 @@ namespace TomatenMusic.Music
{
public class MusicActionResponse
{
public LavalinkPlaylist Playlist { get; }
public ILavalinkPlaylist Playlist { get; }
public LavalinkTrack Track { get; }
public IEnumerable<LavalinkTrack> Tracks { get; }
public bool isPlaylist { get; }
public MusicActionResponse(LavalinkTrack track = null, LavalinkPlaylist playlist = null, IEnumerable<LavalinkTrack> tracks = null)
public MusicActionResponse(LavalinkTrack track = null, ILavalinkPlaylist playlist = null, IEnumerable<LavalinkTrack> tracks = null)
{
Playlist = playlist;
Track = track;

@ -18,7 +18,7 @@ namespace TomatenMusic.Music
public Queue<LavalinkTrack> Queue { get; set; } = new Queue<LavalinkTrack>();
public Queue<LavalinkTrack> PlayedTracks { get; set; } = new Queue<LavalinkTrack>();
public ILogger<PlayerQueue> _logger { get; set; } = TomatenMusicBot.ServiceProvider.GetRequiredService<ILogger<PlayerQueue>>();
public LavalinkPlaylist CurrentPlaylist { get; set; }
public ILavalinkPlaylist CurrentPlaylist { get; set; }
public LoopType LoopType { get; private set; } = LoopType.NONE;
@ -36,7 +36,7 @@ namespace TomatenMusic.Music
QueueLoopList.Add(track);
}
public Task QueuePlaylistAsync(LavalinkPlaylist playlist)
public Task QueuePlaylistAsync(ILavalinkPlaylist playlist)
{
return Task.Run(() =>
{

@ -37,7 +37,7 @@ namespace TomatenMusic.Services
if (channel.Statistics.SubscriberCount != null)
context.YoutubeAuthorSubs = (ulong) channel.Statistics.SubscriberCount;
context.YoutubeAuthorThumbnail = new Uri(channel.Snippet.Thumbnails.High.Url);
context.YoutubeAuthorThumbnail = new Uri(channel.Snippet.Thumbnails.Default__.Url);
context.YoutubeAuthorUri = new Uri($"https://www.youtube.com/channel/{channel.Id}");
string desc = video.Snippet.Description;
@ -45,7 +45,12 @@ namespace TomatenMusic.Services
if (video.Statistics.LikeCount != null)
context.YoutubeLikes = (ulong) video.Statistics.LikeCount;
context.YoutubeTags = video.Snippet.Tags;
try
{
context.YoutubeThumbnail = new Uri(video.Snippet.Thumbnails.High.Url);
}catch (Exception ex) { }
context.YoutubeUploadDate = (DateTime)video.Snippet.PublishedAt;
context.YoutubeViews = (ulong)video.Statistics.ViewCount;
context.YoutubeCommentCount = video.Statistics.CommentCount;
@ -61,7 +66,7 @@ namespace TomatenMusic.Services
return newTracks;
}
public async Task<LavalinkPlaylist> PopulatePlaylistAsync(YoutubePlaylist playlist)
public async Task<ILavalinkPlaylist> PopulatePlaylistAsync(YoutubePlaylist playlist)
{
var list = await GetPlaylistAsync(playlist.Identifier);
var channel = await GetChannelAsync(list.Snippet.ChannelId);
@ -72,10 +77,14 @@ namespace TomatenMusic.Services
if (playlist.Description.Length < 2)
playlist.Description = "None";
playlist.Thumbnail = new Uri(list.Snippet.Thumbnails.High.Url);
try
{
playlist.Thumbnail = new Uri(list.Snippet.Thumbnails.Maxres.Url);
}catch (Exception ex) { }
playlist.AuthorName = channel.Snippet.Title;
playlist.CreationTime = (DateTime)list.Snippet.PublishedAt;
playlist.YoutubeItem = list;
playlist.AuthorThumbnail = new Uri(channel.Snippet.Thumbnails.High.Url);
playlist.AuthorThumbnail = new Uri(channel.Snippet.Thumbnails.Default__.Url);
playlist.AuthorUri = new Uri($"https://www.youtube.com/channels/{channel.Id}");
return playlist;

@ -92,7 +92,7 @@ namespace TomatenMusic.Util
return builder;
}
public static DiscordEmbed AsEmbed(LavalinkPlaylist playlist)
public static DiscordEmbed AsEmbed(ILavalinkPlaylist playlist)
{
DiscordEmbedBuilder builder = new DiscordEmbedBuilder();
@ -100,7 +100,7 @@ namespace TomatenMusic.Util
if (playlist is YoutubePlaylist)
{
YoutubePlaylist youtubePlaylist = (YoutubePlaylist)playlist;
Console.WriteLine($"{playlist.AuthorName}, {playlist.AuthorUri.ToString()}, {playlist.AuthorThumbnail.ToString()}");
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), youtubePlaylist.AuthorThumbnail.ToString());
builder.WithTitle(playlist.Name);
builder.WithUrl(playlist.Url);