.scq fixed, local soundcloud api keys are no longer used, .scpl fix is coming soon™️

This commit is contained in:
Master Kwoth 2017-06-15 18:56:35 +02:00
parent b0966a7cd3
commit dd1d21e29c
3 changed files with 13 additions and 7 deletions

View File

@ -431,7 +431,7 @@ namespace NadekoBot.Modules.Music
using (var http = new HttpClient())
{
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
var scvids = JObject.Parse(await http.GetStringAsync($"http://scapi.nadekobot.me/resolve?url={pl}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
await _music.QueueSong(((IGuildUser)Context.User), (ITextChannel)Context.Channel, ((IGuildUser)Context.User).VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
MusicPlayer musicPlayer;
@ -446,7 +446,7 @@ namespace NadekoBot.Modules.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = MusicType.Normal,
Query = svideo.TrackLink,
}), ((IGuildUser)Context.User).Username);

View File

@ -281,7 +281,7 @@ namespace NadekoBot.Services.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = musicType,
Query = svideo.TrackLink,
AlbumArt = svideo.artwork_url,
@ -296,7 +296,7 @@ namespace NadekoBot.Services.Music
{
Title = svideo.FullName,
Provider = "SoundCloud",
Uri = svideo.GetStreamLink(_creds),
Uri = await svideo.StreamLink(),
ProviderType = MusicType.Soundcloud,
Query = svideo.TrackLink,
AlbumArt = svideo.artwork_url,

View File

@ -26,7 +26,7 @@ namespace NadekoBot.Services.Music
using (var http = new HttpClient())
{
response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false);
response = await http.GetStringAsync($"https://scapi.nadekobot.me/resolve?url={url}").ConfigureAwait(false);
}
@ -50,7 +50,7 @@ namespace NadekoBot.Services.Music
var response = "";
using (var http = new HttpClient())
{
response = await http.GetStringAsync($"http://api.soundcloud.com/tracks?q={Uri.EscapeDataString(query)}&client_id={_creds.SoundCloudClientId}").ConfigureAwait(false);
response = await http.GetStringAsync($"https://scapi.nadekobot.me/tracks?q={Uri.EscapeDataString(query)}").ConfigureAwait(false);
}
var responseObj = JsonConvert.DeserializeObject<SoundCloudVideo[]>(response).Where(s => s.Streamable).FirstOrDefault();
@ -74,7 +74,13 @@ namespace NadekoBot.Services.Music
[JsonProperty("permalink_url")]
public string TrackLink { get; set; } = "";
public string artwork_url { get; set; } = "";
public string GetStreamLink(IBotCredentials creds) => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={creds.SoundCloudClientId}";
public async Task<string> StreamLink()
{
using (var http = new HttpClient())
{
return await http.GetStringAsync($"http://scapi.nadekobot.me/stream/{Id}");
}
}
}
public class SoundCloudUser
{