28 lines
810 B
C#
Raw Normal View History

2017-07-17 04:37:51 +02:00
using NadekoBot.Modules.Music.Extensions;
using NadekoBot.Services.Impl;
2017-07-11 03:16:56 +02:00
using System.Threading.Tasks;
2017-07-17 04:37:51 +02:00
namespace NadekoBot.Modules.Music.Common.SongResolver.Strategies
2017-07-11 03:16:56 +02: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();
}
}
}