This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using PluginManager.Others.Exceptions;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
@@ -22,8 +24,8 @@ namespace MusicCommands
|
||||
|
||||
private async Task<string> GetYoutubeVideoID()
|
||||
{
|
||||
//https://www.youtube.com/watch?v=i-p--m7qaCM&ab_channel=Leviathan
|
||||
return URL.Split("=")[1].Split('&')[0];
|
||||
//https://www.youtube.com/watch?v=i-p--m7qaCM&ab_channel={channel}/
|
||||
return URL.Split('=')[1].Split('&')[0];
|
||||
}
|
||||
|
||||
public async Task<Stream> GetStream()
|
||||
@@ -32,13 +34,18 @@ namespace MusicCommands
|
||||
if (type == LinkType.SPOTIFY) s = await GetSpotifyMusicStreamAsync();
|
||||
else if (type == LinkType.YOUTUBE) s = await GetYoutubeMusicStreamAsync();
|
||||
else s = await GetRAWMusicStreamAsync();
|
||||
if (s == null)
|
||||
{
|
||||
Console.WriteLine("Failed to get the stream for url: " + this.URL);
|
||||
throw new APIException("URL [" + this.URL + "] is invalid", "async Task <Stream> GetStream()", "Work in progress", PluginManager.Others.Error.STREAM_NOT_FOUND);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private async Task<Stream> GetSpotifyMusicStreamAsync()
|
||||
{
|
||||
Stream response = null;
|
||||
return response;
|
||||
throw new APIException("Not implemented", "async Task<Stream> GetSpotifyMusicStream()",
|
||||
"Work in progress", PluginManager.Others.Error.STREAM_NOT_FOUND);
|
||||
}
|
||||
|
||||
private async Task<Stream> GetYoutubeMusicStreamAsync()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{ WINDOWS, LINUX, MAC_OS, UNKNOWN }
|
||||
|
||||
public enum Error
|
||||
{ UNKNOWN_ERROR, GUILD_NOT_FOUND, }
|
||||
{ UNKNOWN_ERROR, GUILD_NOT_FOUND, STREAM_NOT_FOUND }
|
||||
|
||||
public enum OutputLogLevel { NONE, INFO, WARNING, ERROR, CRITICAL }
|
||||
}
|
||||
@@ -2,11 +2,19 @@ using System;
|
||||
|
||||
namespace PluginManager.Others.Exceptions
|
||||
{
|
||||
[System.Serializable]
|
||||
[Serializable]
|
||||
public class APIException : Exception
|
||||
{
|
||||
public string? Function { get; }
|
||||
public Error? ErrorCode { get; }
|
||||
public string? Function { get; } = "not specified";
|
||||
public Error? ErrorCode { get; } = Error.UNKNOWN_ERROR;
|
||||
public string? PossibleCause { get; } = "not specified";
|
||||
|
||||
public APIException(string message, string? function, string possible_cause, Error error) : base(message)
|
||||
{
|
||||
ErrorCode = error;
|
||||
Function = function;
|
||||
PossibleCause = possible_cause;
|
||||
}
|
||||
|
||||
public APIException(string message, string? function, Error? errorCode) : base(message)
|
||||
{
|
||||
@@ -16,14 +24,12 @@ namespace PluginManager.Others.Exceptions
|
||||
|
||||
public APIException(string message, string? function) : base(message)
|
||||
{
|
||||
ErrorCode = Error.UNKNOWN_ERROR;
|
||||
Function = function;
|
||||
}
|
||||
|
||||
public APIException(string message) : base(message)
|
||||
{
|
||||
ErrorCode = Error.UNKNOWN_ERROR;
|
||||
Function = "Unspecified_Function";
|
||||
|
||||
}
|
||||
|
||||
public void Print()
|
||||
@@ -31,6 +37,9 @@ namespace PluginManager.Others.Exceptions
|
||||
Console.WriteLine("Message Content: " + Message);
|
||||
Console.WriteLine("Function: " + Function);
|
||||
Console.WriteLine("Error Code: " + ErrorCode.ToString());
|
||||
Console.WriteLine("Possible cause: " + PossibleCause);
|
||||
if (this.StackTrace != null)
|
||||
Functions.WriteErrFile(this.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user