2017-07-17 02:37:51 +00:00
|
|
|
|
using NadekoBot.Modules.Music.Extensions;
|
2017-10-13 04:14:54 +00:00
|
|
|
|
using NadekoBot.Core.Services.Impl;
|
2017-07-11 01:16:56 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2017-07-17 02:37:51 +00:00
|
|
|
|
namespace NadekoBot.Modules.Music.Common.SongResolver.Strategies
|
2017-07-11 01:16:56 +00:00
|
|
|
|
{
|
|
|
|
|
public class SoundcloudResolveStrategy : IResolveStrategy
|
|
|
|
|
{
|
|
|
|
|
private readonly SoundCloudApiService _sc;
|
|
|
|
|
|
|
|
|
|
public SoundcloudResolveStrategy(SoundCloudApiService sc)
|
|
|
|
|
{
|
|
|
|
|
_sc = sc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<SongInfo> ResolveSong(string query)
|
|
|
|
|
{
|
|
|
|
|
var svideo = !_sc.IsSoundCloudLink(query) ?
|
|
|
|
|
await _sc.GetVideoByQueryAsync(query).ConfigureAwait(false) :
|
|
|
|
|
await _sc.ResolveVideoAsync(query).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
if (svideo == null)
|
|
|
|
|
return null;
|
|
|
|
|
return await svideo.GetSongInfo();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|