NadekoBot/NadekoBot.Modules.Music/Common/SongResolver/Strategies/SoundCloudResolveStrategy.cs

28 lines
815 B
C#
Raw Normal View History

2017-07-17 02:37:51 +00:00
using NadekoBot.Modules.Music.Extensions;
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();
}
}
}