Merge branch 'hotfix' into dev
This commit is contained in:
commit
9c162ee934
@ -4,11 +4,9 @@ using TomatenMusic_Api.Auth.Services;
|
|||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Add services to the container.
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
builder.Services.AddCors();
|
builder.Services.AddCors();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen();
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@ namespace TomatenMusic.Music.Entitites
|
|||||||
context.SpotifyIdentifier = spotifyIdentifier;
|
context.SpotifyIdentifier = spotifyIdentifier;
|
||||||
context.YoutubeUri = new Uri($"https://youtu.be/{track.TrackIdentifier}");
|
context.YoutubeUri = new Uri($"https://youtu.be/{track.TrackIdentifier}");
|
||||||
track.Context = context;
|
track.Context = context;
|
||||||
Console.WriteLine(context);
|
|
||||||
await youtubeService.PopulateTrackInfoAsync(track);
|
await youtubeService.PopulateTrackInfoAsync(track);
|
||||||
await spotifyService.PopulateTrackAsync(track);
|
await spotifyService.PopulateTrackAsync(track);
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ using System.Text;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Google.Apis.YouTube.v3.Data;
|
using Google.Apis.YouTube.v3.Data;
|
||||||
using Lavalink4NET.Player;
|
using Lavalink4NET.Player;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using TomatenMusic.Services;
|
||||||
|
|
||||||
namespace TomatenMusic.Music.Entitites
|
namespace TomatenMusic.Music.Entitites
|
||||||
{
|
{
|
||||||
@ -28,11 +30,12 @@ namespace TomatenMusic.Music.Entitites
|
|||||||
|
|
||||||
public YoutubePlaylist(string name, IEnumerable<LavalinkTrack> tracks, Uri uri)
|
public YoutubePlaylist(string name, IEnumerable<LavalinkTrack> tracks, Uri uri)
|
||||||
{
|
{
|
||||||
Identifier = uri.ToString().Replace("https://www.youtube.com/playlist?list=", "");
|
Identifier = uri.ToString().Replace("https://www.youtube.com/playlist?list=", "").Replace("https://youtube.com/playlist?list=", "");
|
||||||
Name = name;
|
Name = name;
|
||||||
Tracks = tracks;
|
Tracks = tracks;
|
||||||
Url = uri;
|
Url = uri;
|
||||||
TrackCount = tracks.Count();
|
TrackCount = tracks.Count();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,13 @@ namespace TomatenMusic.Music
|
|||||||
{
|
{
|
||||||
public ISpotifyService _spotifyService { get; set; }
|
public ISpotifyService _spotifyService { get; set; }
|
||||||
public IAudioService _audioService { get; set; }
|
public IAudioService _audioService { get; set; }
|
||||||
|
public YoutubeService _youtubeService { get; set; }
|
||||||
|
|
||||||
public TrackProvider(ISpotifyService spotify, IAudioService audioService)
|
public TrackProvider(ISpotifyService spotify, IAudioService audioService, YoutubeService youtubeService)
|
||||||
{
|
{
|
||||||
_audioService = audioService;
|
_audioService = audioService;
|
||||||
_spotifyService = spotify;
|
_spotifyService = spotify;
|
||||||
|
_youtubeService = youtubeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MusicActionResponse> SearchAsync(string query, bool withSearchResults = false)
|
public async Task<MusicActionResponse> SearchAsync(string query, bool withSearchResults = false)
|
||||||
@ -55,7 +57,7 @@ namespace TomatenMusic.Music
|
|||||||
|
|
||||||
if (loadResult.LoadType == TrackLoadType.PlaylistLoaded && !isSearch)
|
if (loadResult.LoadType == TrackLoadType.PlaylistLoaded && !isSearch)
|
||||||
return new MusicActionResponse(
|
return new MusicActionResponse(
|
||||||
playlist: new YoutubePlaylist(loadResult.PlaylistInfo.Name, await FullTrackContext.PopulateTracksAsync(loadResult.Tracks), uri));
|
playlist: await _youtubeService.PopulatePlaylistAsync(new YoutubePlaylist(loadResult.PlaylistInfo.Name, await FullTrackContext.PopulateTracksAsync(loadResult.Tracks), uri)));
|
||||||
else
|
else
|
||||||
return new MusicActionResponse(await FullTrackContext.PopulateAsync(loadResult.Tracks.First()));
|
return new MusicActionResponse(await FullTrackContext.PopulateAsync(loadResult.Tracks.First()));
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace TomatenMusic.Services
|
|||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<LavalinkTrack>> PopulateMultiTrackListAsync(IEnumerable<LavalinkTrack> tracks)
|
public async Task<List<LavalinkTrack>> PopulateTrackListAsync(IEnumerable<LavalinkTrack> tracks)
|
||||||
{
|
{
|
||||||
List<LavalinkTrack> newTracks = new List<LavalinkTrack>();
|
List<LavalinkTrack> newTracks = new List<LavalinkTrack>();
|
||||||
foreach (var track in tracks)
|
foreach (var track in tracks)
|
||||||
@ -69,14 +69,14 @@ namespace TomatenMusic.Services
|
|||||||
string desc = list.Snippet.Description;
|
string desc = list.Snippet.Description;
|
||||||
|
|
||||||
playlist.Description = desc.Substring(0, Math.Min(desc.Length, 1024)) + (desc.Length > 1020 ? "..." : " ");
|
playlist.Description = desc.Substring(0, Math.Min(desc.Length, 1024)) + (desc.Length > 1020 ? "..." : " ");
|
||||||
if (playlist.Description == "")
|
if (playlist.Description.Length < 2)
|
||||||
playlist.Description = "None";
|
playlist.Description = "None";
|
||||||
|
|
||||||
playlist.Thumbnail = new Uri(list.Snippet.Thumbnails.High.Url);
|
playlist.Thumbnail = new Uri(list.Snippet.Thumbnails.High.Url);
|
||||||
playlist.CreationTime = (DateTime)list.Snippet.PublishedAt;
|
playlist.CreationTime = (DateTime)list.Snippet.PublishedAt;
|
||||||
playlist.YoutubeItem = list;
|
playlist.YoutubeItem = list;
|
||||||
playlist.AuthorThumbnail = new Uri(channel.Snippet.Thumbnails.High.Url);
|
playlist.AuthorThumbnail = new Uri(channel.Snippet.Thumbnails.High.Url);
|
||||||
playlist.AuthorUri = new Uri($"https://www.youtube.com/playlist?list={playlist.Identifier}");
|
playlist.AuthorUri = new Uri($"https://www.youtube.com/channels/{channel.Id}");
|
||||||
|
|
||||||
return playlist;
|
return playlist;
|
||||||
}
|
}
|
||||||
|
@ -100,28 +100,28 @@ namespace TomatenMusic.Util
|
|||||||
if (playlist is YoutubePlaylist)
|
if (playlist is YoutubePlaylist)
|
||||||
{
|
{
|
||||||
YoutubePlaylist youtubePlaylist = (YoutubePlaylist)playlist;
|
YoutubePlaylist youtubePlaylist = (YoutubePlaylist)playlist;
|
||||||
builder
|
|
||||||
.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), youtubePlaylist.AuthorThumbnail.ToString())
|
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), youtubePlaylist.AuthorThumbnail.ToString());
|
||||||
.WithTitle(playlist.Name)
|
builder.WithTitle(playlist.Name);
|
||||||
.WithUrl(playlist.Url)
|
builder.WithUrl(playlist.Url);
|
||||||
.WithDescription(TrackListString(playlist.Tracks))
|
builder.WithDescription(TrackListString(playlist.Tracks));
|
||||||
.WithImageUrl(youtubePlaylist.Thumbnail)
|
builder.WithImageUrl(youtubePlaylist.Thumbnail);
|
||||||
.AddField("Description", playlist.Description, false)
|
builder.AddField("Description", playlist.Description, false);
|
||||||
.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true)
|
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
||||||
.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true)
|
builder.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true);
|
||||||
.AddField("Create Date", $"{youtubePlaylist.CreationTime:dd. MMMM, yyyy}", true);
|
builder.AddField("Create Date", $"{youtubePlaylist.CreationTime:dd. MMMM, yyyy}", true);
|
||||||
|
|
||||||
}else if (playlist is SpotifyPlaylist)
|
}else if (playlist is SpotifyPlaylist)
|
||||||
{
|
{
|
||||||
SpotifyPlaylist spotifyPlaylist = (SpotifyPlaylist)playlist;
|
SpotifyPlaylist spotifyPlaylist = (SpotifyPlaylist)playlist;
|
||||||
builder
|
|
||||||
.WithTitle(playlist.Name)
|
builder.WithTitle(playlist.Name);
|
||||||
.WithUrl(playlist.Url)
|
builder.WithUrl(playlist.Url);
|
||||||
.WithDescription(TrackListString(playlist.Tracks))
|
builder.WithDescription(TrackListString(playlist.Tracks));
|
||||||
.AddField("Description", playlist.Description, false)
|
builder.AddField("Description", playlist.Description, false);
|
||||||
.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true)
|
builder.AddField("Track Count", $"{playlist.Tracks.Count()} Tracks", true);
|
||||||
.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true)
|
builder.AddField("Length", $"{Common.GetTimestamp(playlist.GetLength())}", true);
|
||||||
.AddField("Spotify Followers", $"{spotifyPlaylist.Followers:N0}", true);
|
builder.AddField("Spotify Followers", $"{spotifyPlaylist.Followers:N0}", true);
|
||||||
if (spotifyPlaylist.AuthorThumbnail != null)
|
if (spotifyPlaylist.AuthorThumbnail != null)
|
||||||
{
|
{
|
||||||
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), spotifyPlaylist.AuthorThumbnail.ToString());
|
builder.WithAuthor(playlist.AuthorName, playlist.AuthorUri.ToString(), spotifyPlaylist.AuthorThumbnail.ToString());
|
||||||
@ -150,11 +150,12 @@ namespace TomatenMusic.Util
|
|||||||
builder.AddField("Length", GetTimestamp(timeSpan), true);
|
builder.AddField("Length", GetTimestamp(timeSpan), true);
|
||||||
builder.AddField("Loop Type", player.PlayerQueue.LoopType.ToString(), true);
|
builder.AddField("Loop Type", player.PlayerQueue.LoopType.ToString(), true);
|
||||||
builder.AddField("Autoplay", player.Autoplay ? "✅" : "❌", true);
|
builder.AddField("Autoplay", player.Autoplay ? "✅" : "❌", true);
|
||||||
if (player.PlayerQueue.PlayedTracks.Any())
|
|
||||||
builder.AddField("History", TrackListString(player.PlayerQueue.PlayedTracks), true);
|
|
||||||
if (player.PlayerQueue.CurrentPlaylist != null)
|
if (player.PlayerQueue.CurrentPlaylist != null)
|
||||||
builder.AddField("Current Playlist", $"[{player.PlayerQueue.CurrentPlaylist.Name}]({player.PlayerQueue.CurrentPlaylist.Url})", true);
|
builder.AddField("Current Playlist", $"[{player.PlayerQueue.CurrentPlaylist.Name}]({player.PlayerQueue.CurrentPlaylist.Url})", true);
|
||||||
|
|
||||||
|
if (player.PlayerQueue.PlayedTracks.Any())
|
||||||
|
builder.AddField("History", TrackListString(player.PlayerQueue.PlayedTracks), true);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user