NadekoBot/NadekoBot.Modules.Music/Common/SongResolver/SongResolverFactory.cs

42 lines
1.5 KiB
C#
Raw Normal View History

2017-07-11 01:16:56 +00:00
using System.Threading.Tasks;
using NadekoBot.Services.Database.Models;
using NadekoBot.Services.Impl;
2017-07-17 02:37:51 +00:00
using NadekoBot.Modules.Music.Common.SongResolver.Strategies;
2017-07-11 01:16:56 +00:00
2017-07-17 02:37:51 +00:00
namespace NadekoBot.Modules.Music.Common.SongResolver
2017-07-11 01:16:56 +00:00
{
public class SongResolverFactory : ISongResolverFactory
{
private readonly SoundCloudApiService _sc;
public SongResolverFactory(SoundCloudApiService sc)
{
_sc = sc;
}
public async Task<IResolveStrategy> GetResolveStrategy(string query, MusicType? musicType)
{
await Task.Yield(); //for async warning
switch (musicType)
{
case MusicType.YouTube:
return new YoutubeResolveStrategy();
case MusicType.Radio:
return new RadioResolveStrategy();
case MusicType.Local:
return new LocalSongResolveStrategy();
case MusicType.Soundcloud:
return new SoundcloudResolveStrategy(_sc);
default:
if (_sc.IsSoundCloudLink(query))
return new SoundcloudResolveStrategy(_sc);
else if (RadioResolveStrategy.IsRadioLink(query))
return new RadioResolveStrategy();
// maybe add a check for local files in the future
else
return new YoutubeResolveStrategy();
}
}
}
}