Removed module projects because it can't work like that atm. Commented out package commands.
This commit is contained in:
NadekoBot.Core
Migrations
20171013055008_clear-and-loadedpackage.Designer.cs20171013055008_clear-and-loadedpackage.csNadekoSqliteContextModelSnapshot.cs
Modules
Administration
Gambling
AnimalRacingCommands.cs
Common
CurrencyEventsCommands.csDiceRollCommands.csDrawCommands.csFlipCoinCommands.csFlowerShopCommands.csGambling.csServices
SlotCommands.csWaifuClaimCommands.csWheelOfFortuneCommands.csGames
AcropobiaCommands.csCleverBotCommands.csConnect4Commands.csGames.csHangmanCommands.csLeetCommands.csNunchiCommands.csPlantAndPickCommands.csPollCommands.cs
Common
Acrophobia
ChatterBot
ChatterBotResponse.csChatterBotSession.csCleverbotResponse.csIChatterBotSession.csOfficialCleverbotSession.cs
Connect4
GirlRating.csHangman
Nunchi
Poll.csTicTacToe.csTrivia
TypingArticle.csTypingGame.csServices
SpeedTypingCommands.csTicTacToeCommands.csTriviaCommands.csMusic
Common
Extensions
Music.csServices
Nsfw
Pokemon
Searches
AnimeSearchCommands.cs
Common
AnimeResult.csDefineModel.cs
Exceptions
GoogleSearchResult.csMagicItem.csMangaResult.csOmdbProvider.csOverwatchApiModel.csSearchImageCacher.csSearchPokemon.csStreamResponses.csTimeModels.csWeatherModels.csWikipediaApiModel.csWoWJoke.csExceptions
FeedCommands.csJokeCommands.csLoLCommands.csMemegenCommands.csOsuCommands.csOverwatchCommands.csPlaceCommands.csPokemonSearchCommands.csSearches.csServices
StreamNotificationCommands.csTranslatorCommands.csXkcdCommands.csUtility
BotConfigCommands.csCalcCommands.csCommandMapCommands.cs
Common
Extensions
InfoCommands.csNadekoBot.Modules.Searches.csprojPatreonCommands.csQuoteCommands.csRemindCommands.csRepeatCommands.csServices
CommandMapService.csConverterService.csMessageRepeaterService.csPatreonRewardsService.csRemindService.csStreamRoleService.csVerboseErrorsService.cs
StreamRoleCommands.csUnitConversionCommands.csUtility.csVerboseErrorCommands.csXp
Services
NadekoBot.Modules.Games
NadekoBot.slndocs
mkdocs.ymlsrc/NadekoBot
79
NadekoBot.Core/Modules/Music/Common/SongInfo.cs
Normal file
79
NadekoBot.Core/Modules/Music/Common/SongInfo.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Discord;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Core.Services.Database.Models;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NadekoBot.Modules.Music.Common
|
||||
{
|
||||
public class SongInfo
|
||||
{
|
||||
public string Provider { get; set; }
|
||||
public MusicType ProviderType { get; set; }
|
||||
public string Query { get; set; }
|
||||
public string Title { get; set; }
|
||||
public Func<Task<string>> Uri { get; set; }
|
||||
public string Thumbnail { get; set; }
|
||||
public string QueuerName { get; set; }
|
||||
public TimeSpan TotalTime { get; set; } = TimeSpan.Zero;
|
||||
|
||||
public string PrettyProvider => (Provider ?? "???");
|
||||
//public string PrettyFullTime => PrettyCurrentTime + " / " + PrettyTotalTime;
|
||||
public string PrettyName => $"**[{Title.TrimTo(65)}]({SongUrl})**";
|
||||
public string PrettyInfo => $"{PrettyTotalTime} | {PrettyProvider} | {QueuerName}";
|
||||
public string PrettyFullName => $"{PrettyName}\n\t\t`{PrettyTotalTime} | {PrettyProvider} | {Format.Sanitize(QueuerName.TrimTo(15))}`";
|
||||
public string PrettyTotalTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (TotalTime == TimeSpan.Zero)
|
||||
return "(?)";
|
||||
if (TotalTime == TimeSpan.MaxValue)
|
||||
return "∞";
|
||||
var time = TotalTime.ToString(@"mm\:ss");
|
||||
var hrs = (int)TotalTime.TotalHours;
|
||||
|
||||
if (hrs > 0)
|
||||
return hrs + ":" + time;
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
||||
public string SongUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (ProviderType)
|
||||
{
|
||||
case MusicType.YouTube:
|
||||
return Query;
|
||||
case MusicType.Soundcloud:
|
||||
return Query;
|
||||
case MusicType.Local:
|
||||
return $"https://google.com/search?q={ WebUtility.UrlEncode(Title).Replace(' ', '+') }";
|
||||
case MusicType.Radio:
|
||||
return $"https://google.com/search?q={Title}";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _videoId = null;
|
||||
public string VideoId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ProviderType == MusicType.YouTube)
|
||||
return _videoId = _videoId ?? videoIdRegex.Match(Query)?.ToString();
|
||||
|
||||
return _videoId ?? "";
|
||||
}
|
||||
|
||||
set => _videoId = value;
|
||||
}
|
||||
|
||||
private readonly Regex videoIdRegex = new Regex("<=v=[a-zA-Z0-9-]+(?=&)|(?<=[0-9])[^&\n]+|(?<=v=)[^&\n]+", RegexOptions.Compiled);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user