music updates
This commit is contained in:
parent
8b48d1e9be
commit
1808d4961f
@ -49,8 +49,6 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
|
public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
|
||||||
|
|
||||||
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
||||||
|
|
||||||
public string PTT => $"{PrettyTotalTime}";
|
|
||||||
|
|
||||||
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
public string PrettyFullName => $"{PrettyName}\n\t\t*{PrettyInfo}*";
|
||||||
|
|
||||||
@ -67,6 +65,24 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Thumbnail {
|
||||||
|
get {
|
||||||
|
switch (SongInfo.ProviderType)
|
||||||
|
{
|
||||||
|
case MusicType.Normal:
|
||||||
|
//todo have videoid in songinfo from the start
|
||||||
|
var videoId = Regex.Match(SongInfo.Query, "<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+");
|
||||||
|
return $"https://img.youtube.com/vi/{ videoId }/0.jpg";
|
||||||
|
case MusicType.Soundcloud:
|
||||||
|
return SongInfo.AlbumArt;
|
||||||
|
case MusicType.Local:
|
||||||
|
case MusicType.Radio:
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int skipTo = 0;
|
private int skipTo = 0;
|
||||||
public int SkipTo {
|
public int SkipTo {
|
||||||
get { return skipTo; }
|
get { return skipTo; }
|
||||||
|
@ -217,26 +217,16 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (currentSong == null)
|
if (currentSong == null)
|
||||||
return;
|
return;
|
||||||
try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
try { await musicPlayer.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
var videoid = Regex.Match(currentSong.SongInfo.Query, "<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+");
|
|
||||||
|
|
||||||
var embed = new EmbedBuilder()
|
var embed = new EmbedBuilder()
|
||||||
.WithAuthor(eab => eab.WithName("Now Playing")
|
.WithAuthor(eab => eab.WithName("Now Playing")
|
||||||
.WithMusicIcon())
|
.WithMusicIcon())
|
||||||
.WithTitle($"{currentSong.SongInfo.Title}")
|
.WithTitle($"{currentSong.SongInfo.Title}")
|
||||||
.WithDescription(currentSong.PrettyCurrentTime + "/" + currentSong.PTT)
|
.WithDescription(currentSong.PrettyFullTime)
|
||||||
.WithFooter(ef => ef.WithText($"{currentSong.PrettyProvider} | {currentSong.QueuerName}"))
|
.WithFooter(ef => ef.WithText($"{currentSong.PrettyProvider} | {currentSong.QueuerName}"))
|
||||||
.WithOkColor();
|
.WithOkColor()
|
||||||
if (currentSong.SongInfo.Provider.Equals("YouTube", StringComparison.OrdinalIgnoreCase))
|
.WithThumbnail(tn => tn.Url = currentSong.Thumbnail)
|
||||||
{
|
.WithUrl(currentSong.SongInfo.Query);
|
||||||
embed.WithThumbnail(tn => tn.Url = $"https://img.youtube.com/vi/{videoid}/0.jpg");
|
|
||||||
embed.WithUrl($"{currentSong.SongInfo.Query}");
|
|
||||||
}
|
|
||||||
else if (currentSong.SongInfo.Provider.Equals("SoundCloud", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
embed.WithThumbnail(tn => tn.Url = $"{currentSong.SongInfo.AlbumArt}");
|
|
||||||
embed.WithUrl($"{currentSong.SongInfo.Query}");
|
|
||||||
}
|
|
||||||
|
|
||||||
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +315,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
|
|
||||||
var msg =
|
var msg =
|
||||||
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
await channel.SendMessageAsync($"🎵 Attempting to queue **{count}** songs".SnPl(count) + "...").ConfigureAwait(false);
|
||||||
|
|
||||||
var cancelSource = new CancellationTokenSource();
|
var cancelSource = new CancellationTokenSource();
|
||||||
|
|
||||||
var tasks = Task.WhenAll(idArray.Select(async id =>
|
var tasks = Task.WhenAll(idArray.Select(async id =>
|
||||||
@ -341,16 +331,6 @@ namespace NadekoBot.Modules.Music
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
await Task.WhenAny(tasks, Task.Delay(Timeout.Infinite, cancelSource.Token));
|
await Task.WhenAny(tasks, Task.Delay(Timeout.Infinite, cancelSource.Token));
|
||||||
|
|
||||||
/*foreach (var id in idArray)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await QueueSong(((IGuildUser)umsg.Author), channel, ((IGuildUser)umsg.Author).VoiceChannel, id, true).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (SongNotFoundException) { }
|
|
||||||
catch { break; }
|
|
||||||
}*/
|
|
||||||
|
|
||||||
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
await msg.ModifyAsync(m => m.Content = "✅ Playlist queue complete.").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
@ -847,7 +827,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
if (finishedMessage != null)
|
if (finishedMessage != null)
|
||||||
finishedMessage.DeleteAfter(0);
|
finishedMessage.DeleteAfter(0);
|
||||||
|
|
||||||
finishedMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
finishedMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||||
.WithAuthor(eab => eab.WithName("Finished Song").WithMusicIcon())
|
.WithAuthor(eab => eab.WithName("Finished Song").WithMusicIcon())
|
||||||
.WithDescription(song.PrettyName)
|
.WithDescription(song.PrettyName)
|
||||||
@ -863,11 +843,11 @@ namespace NadekoBot.Modules.Music
|
|||||||
catch { }
|
catch { }
|
||||||
};
|
};
|
||||||
IUserMessage playingMessage = null;
|
IUserMessage playingMessage = null;
|
||||||
|
|
||||||
mp.OnStarted += async (player, song) =>
|
mp.OnStarted += async (player, song) =>
|
||||||
{
|
{
|
||||||
try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
try { await mp.UpdateSongDurationsAsync().ConfigureAwait(false); } catch { }
|
||||||
var sender = player as MusicPlayer;
|
var sender = player as MusicPlayer;
|
||||||
if (sender == null)
|
if (sender == null)
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user