few fixex

This commit is contained in:
samvaio 2016-12-25 01:19:29 +05:30
parent 94067cf179
commit ee316a6c1d
2 changed files with 80 additions and 37 deletions

View File

@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using VideoLibrary;
using System.Net;
namespace NadekoBot.Modules.Music.Classes
{
@ -46,7 +47,25 @@ namespace NadekoBot.Modules.Music.Classes
public string PrettyFullTime => PrettyCurrentTime + " / " + PrettyTotalTime;
public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
//public string PrettyName => $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
public string PrettyName {
get {
switch (SongInfo.ProviderType)
{
case MusicType.Normal:
return $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
case MusicType.Soundcloud:
return $"**[{SongInfo.Title.TrimTo(70)}]({SongInfo.Query})**";
case MusicType.Local:
return $"**{SongInfo.Title.TrimTo(70)}**";
case MusicType.Radio:
return $"**{SongInfo.Title.TrimTo(70)}**";
default:
return "";
}
}
}
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
@ -67,16 +86,36 @@ namespace NadekoBot.Modules.Music.Classes
public string Thumbnail {
get {
switch (SongInfo.ProviderType)
switch (SongInfo.Provider)
{
case MusicType.Normal:
case "YouTube":
//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:
case "SoundCloud":
return SongInfo.AlbumArt;
case "Local File":
return $"https://cdn.discordapp.com/attachments/155726317222887425/261850914783100928/1482522077_music.png"; //test links
case "Radio Stream":
return $"https://cdn.discordapp.com/attachments/155726317222887425/261850925063340032/1482522097_radio.png"; //test links
default:
return "";
}
}
}
public string songURL {
get {
switch (SongInfo.ProviderType)
{
case MusicType.Normal:
return SongInfo.Query;
case MusicType.Soundcloud:
return SongInfo.Query;
case MusicType.Local:
return $"https://google.com/search?q={ WebUtility.UrlEncode(SongInfo.Title).Replace(' ', '+') }";
case MusicType.Radio:
return $"https://google.com/search?q={SongInfo.Title}";
default:
return "";
}
@ -104,6 +143,7 @@ namespace NadekoBot.Modules.Music.Classes
{
var s = new Song(SongInfo);
s.MusicPlayer = MusicPlayer;
s.QueuerName = QueuerName;
return s;
}

View File

@ -221,12 +221,12 @@ namespace NadekoBot.Modules.Music
var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName("Now Playing")
.WithMusicIcon())
.WithTitle($"{currentSong.SongInfo.Title}")
.WithTitle(currentSong.SongInfo.Title)
.WithDescription(currentSong.PrettyFullTime)
.WithFooter(ef => ef.WithText($"{currentSong.PrettyProvider} | {currentSong.QueuerName}"))
.WithOkColor()
.WithThumbnail(tn => tn.Url = currentSong.Thumbnail)
.WithUrl(currentSong.SongInfo.Query);
.WithUrl(currentSong.songURL);
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
}
@ -472,7 +472,8 @@ namespace NadekoBot.Modules.Music
var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName("Song Removed!").WithMusicIcon())
.AddField(fb => fb.WithName("**Song Position**").WithValue($"#{num}").WithIsInline(true))
.AddField(fb => fb.WithName("**Song Name**").WithValue($"**[{song.SongInfo.Title.TrimTo(70)}]({song.SongInfo.Query})** `{song.PrettyProvider} | {song.QueuerName.TrimTo(15)}`").WithIsInline(true))
.AddField(fb => fb.WithName("**Song Name**").WithValue(song.PrettyName).WithIsInline(true))
.WithFooter(ef => ef.WithText($"{song.PrettyProvider} | {song.QueuerName}"))
.WithErrorColor();
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
@ -526,11 +527,12 @@ namespace NadekoBot.Modules.Music
playlist.RemoveAt(nn1);
var embed = new EmbedBuilder()
.WithTitle($"{s.SongInfo.Title.TrimTo(70)}")
.WithUrl($"{s.SongInfo.Query}")
.WithTitle(s.SongInfo.Title.TrimTo(70))
.WithUrl(s.SongInfo.Query)
.WithAuthor(eab => eab.WithName("Song Moved").WithMusicIcon())
.AddField(fb => fb.WithName("**From Position**").WithValue($"#{n1}").WithIsInline(true))
.AddField(fb => fb.WithName("**To Position**").WithValue($"#{n2}").WithIsInline(true))
.WithFooter(ef => ef.WithText($"{s.PrettyProvider} | {s.QueuerName}"))
.WithOkColor();
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
}
@ -566,7 +568,8 @@ namespace NadekoBot.Modules.Music
await channel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithAuthor(eab => eab.WithMusicIcon().WithName("🔂 Repeating track"))
.WithDescription(currentSong.PrettyFullName)
.WithDescription(currentSong.PrettyName)
.WithFooter(ef => ef.WithText(currentSong.PrettyInfo))
.Build()).ConfigureAwait(false);
else
await channel.SendConfirmAsync($"🔂 Current track repeat stopped.")
@ -674,7 +677,7 @@ namespace NadekoBot.Modules.Music
var embed = new EmbedBuilder()
.WithAuthor(eab => eab.WithName($"Page {num} of Saved Playlists").WithMusicIcon())
.WithDescription(string.Join("\n", playlists.Select(r => $"`#{r.Id}` - **{r.Name}**\t by **`{r.Author}`**\t ({r.Songs.Count} songs)")))
.WithDescription(string.Join("\n", playlists.Select(r => $"`#{r.Id}` - **{r.Name}** by *{r.Author}* ({r.Songs.Count} songs)")))
.WithOkColor();
await channel.EmbedAsync(embed.Build()).ConfigureAwait(false);
@ -863,7 +866,7 @@ namespace NadekoBot.Modules.Music
playingMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithAuthor(eab => eab.WithName("Playing Song").WithMusicIcon())
.WithDescription($"{song.PrettyName}")
.WithDescription(song.PrettyName)
.WithFooter(ef => ef.WithText($"🔉 {(int)(sender.Volume * 100)}% | {song.PrettyInfo}"))
.Build())
.ConfigureAwait(false);
@ -885,7 +888,7 @@ namespace NadekoBot.Modules.Music
pauseMessage = await textCh.SendConfirmAsync("🎵 Music playback **resumed**.").ConfigureAwait(false);
}
if (pauseMessage != null)
pauseMessage.DeleteAfter(5);
pauseMessage.DeleteAfter(15);
}
catch { }
};
@ -914,9 +917,9 @@ namespace NadekoBot.Modules.Music
//var queuedMessage = await textCh.SendConfirmAsync($"🎵 Queued **{resolvedSong.SongInfo.Title}** at `#{musicPlayer.Playlist.Count + 1}`").ConfigureAwait(false);
var queuedMessage = await textCh.EmbedAsync(new EmbedBuilder().WithOkColor()
.WithAuthor(eab => eab.WithName("Queued Song").WithMusicIcon())
.WithTitle($"{resolvedSong.SongInfo.Title}")
.WithDescription($"Queue #{musicPlayer.Playlist.Count + 1}")
.WithFooter(ef => ef.WithText($"{resolvedSong.PrettyProvider}"))
.WithDescription($"{resolvedSong.PrettyName}\nQueue #{musicPlayer.Playlist.Count + 1}")
.WithThumbnail(tn => tn.Url = resolvedSong.Thumbnail)
.WithFooter(ef => ef.WithText(resolvedSong.PrettyProvider))
.Build())
.ConfigureAwait(false);
if (queuedMessage != null)