fixed m3u support
This commit is contained in:
parent
5f86c83422
commit
643f8590a7
@ -54,11 +54,10 @@ namespace NadekoBot.Classes.Music {
|
|||||||
this.Server = e.Server;
|
this.Server = e.Server;
|
||||||
this.Query = query;
|
this.Query = query;
|
||||||
this.RadioLink = radio;
|
this.RadioLink = radio;
|
||||||
Task.Run(() => ResolveStreamLink());
|
|
||||||
mc.SongQueue.Add(this);
|
mc.SongQueue.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ResolveStreamLink() {
|
public async Task Resolve() {
|
||||||
string uri = null;
|
string uri = null;
|
||||||
try {
|
try {
|
||||||
if (RadioLink) {
|
if (RadioLink) {
|
||||||
|
@ -262,6 +262,8 @@ namespace NadekoBot.Modules {
|
|||||||
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
if (string.IsNullOrWhiteSpace(query) || query.Length < 3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
query = query.Trim();
|
||||||
|
|
||||||
if (IsRadioLink(query)) {
|
if (IsRadioLink(query)) {
|
||||||
radio = true;
|
radio = true;
|
||||||
query = await HandleStreamContainers(query);
|
query = await HandleStreamContainers(query);
|
||||||
@ -284,7 +286,7 @@ namespace NadekoBot.Modules {
|
|||||||
if (player.SongQueue.Count >= 25) return;
|
if (player.SongQueue.Count >= 25) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var sr = await Task.Run(() => new StreamRequest(e, query, player, radio));
|
var sr = new StreamRequest(e, query, player, radio);
|
||||||
|
|
||||||
if (sr == null)
|
if (sr == null)
|
||||||
throw new NullReferenceException("StreamRequest is null.");
|
throw new NullReferenceException("StreamRequest is null.");
|
||||||
@ -292,15 +294,12 @@ namespace NadekoBot.Modules {
|
|||||||
Message qmsg = null;
|
Message qmsg = null;
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
qmsg = await e.Channel.SendMessage("🎵 `Searching...`");
|
qmsg = await e.Channel.SendMessage("🎵 `Searching / Resolving...`");
|
||||||
sr.OnResolving += async () => {
|
|
||||||
await qmsg.Edit($"🎵 `Resolving`... \"{query}\"");
|
|
||||||
};
|
|
||||||
sr.OnResolvingFailed += async (err) => {
|
sr.OnResolvingFailed += async (err) => {
|
||||||
await qmsg.Edit($"💢 🎵 `Resolving failed` for **{query}**");
|
await qmsg?.Edit($"💢 🎵 `Resolving failed` for **{query}**");
|
||||||
};
|
};
|
||||||
sr.OnQueued += async () => {
|
sr.OnQueued += async () => {
|
||||||
await qmsg.Edit($"🎵`Queued`{sr.FullPrettyName}");
|
await qmsg?.Edit($"🎵`Queued`{sr.FullPrettyName}");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
sr.OnCompleted += async () => {
|
sr.OnCompleted += async () => {
|
||||||
@ -322,6 +321,7 @@ namespace NadekoBot.Modules {
|
|||||||
sr.OnBuffering += async () => {
|
sr.OnBuffering += async () => {
|
||||||
msg = await e.Send($"🎵`Buffering...`{sr.FullPrettyName}");
|
msg = await e.Send($"🎵`Buffering...`{sr.FullPrettyName}");
|
||||||
};
|
};
|
||||||
|
sr.Resolve();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
await e.Send($"💢 {ex.Message}");
|
await e.Send($"💢 {ex.Message}");
|
||||||
@ -351,7 +351,7 @@ namespace NadekoBot.Modules {
|
|||||||
try {
|
try {
|
||||||
var m = Regex.Match(file, "File1=(?<url>.*?)\\n");
|
var m = Regex.Match(file, "File1=(?<url>.*?)\\n");
|
||||||
var res = m.Groups["url"]?.ToString();
|
var res = m.Groups["url"]?.ToString();
|
||||||
return res;
|
return res?.Trim();
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Console.WriteLine($"Failed reading .pls:\n{file}");
|
Console.WriteLine($"Failed reading .pls:\n{file}");
|
||||||
@ -365,9 +365,9 @@ namespace NadekoBot.Modules {
|
|||||||
C:\xxx5xx\x6xxxxxx\x7xxxxx\xx.mp3
|
C:\xxx5xx\x6xxxxxx\x7xxxxx\xx.mp3
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
var m = Regex.Match(file, "^[^#](?<url>.*)");
|
var m = Regex.Match(file, "(?<url>^[^#].*)");
|
||||||
var res = m.Groups["url"]?.ToString();
|
var res = m.Groups["url"]?.ToString();
|
||||||
return res;
|
return res?.Trim();
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Console.WriteLine($"Failed reading .m3u:\n{file}");
|
Console.WriteLine($"Failed reading .m3u:\n{file}");
|
||||||
@ -380,7 +380,7 @@ namespace NadekoBot.Modules {
|
|||||||
try {
|
try {
|
||||||
var m = Regex.Match(file, "<ref href=\"(?<url>.*?)\"");
|
var m = Regex.Match(file, "<ref href=\"(?<url>.*?)\"");
|
||||||
var res = m.Groups["url"]?.ToString();
|
var res = m.Groups["url"]?.ToString();
|
||||||
return res;
|
return res?.Trim();
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Console.WriteLine($"Failed reading .asx:\n{file}");
|
Console.WriteLine($"Failed reading .asx:\n{file}");
|
||||||
|
Loading…
Reference in New Issue
Block a user