2021-09-25 21:00:58 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using SpotifyAPI.Web;
|
|
|
|
|
|
|
|
|
|
namespace Selector.Tests
|
|
|
|
|
{
|
|
|
|
|
static class Helper
|
|
|
|
|
{
|
2021-10-01 22:01:28 +01:00
|
|
|
|
public static FullTrack FullTrack(string name, string album = "album name", List<string> artists = null)
|
2021-09-25 21:00:58 +01:00
|
|
|
|
{
|
2021-10-01 22:01:28 +01:00
|
|
|
|
if (artists is null) artists = new List<string>() {"artist"};
|
|
|
|
|
|
2021-09-25 21:00:58 +01:00
|
|
|
|
return new FullTrack()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Uri = name,
|
|
|
|
|
Album = SimpleAlbum(album, artists),
|
|
|
|
|
Artists = artists.Select(a => SimpleArtist(a)).ToList()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FullTrack FullTrack(string name, string album, string artist)
|
|
|
|
|
{
|
|
|
|
|
return FullTrack(name, album, new List<string>() { artist });
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 15:25:54 +01:00
|
|
|
|
public static FullEpisode FullEpisode(string name, string show = null, string publisher = null)
|
|
|
|
|
{
|
|
|
|
|
return new FullEpisode()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Uri = name,
|
|
|
|
|
Show = SimpleShow(show ?? name, publisher: publisher)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 22:01:28 +01:00
|
|
|
|
public static SimpleAlbum SimpleAlbum(string name, List<string> artists = null)
|
2021-09-25 21:00:58 +01:00
|
|
|
|
{
|
2021-10-01 22:01:28 +01:00
|
|
|
|
if (artists is null) artists = new List<string>() {"artist"};
|
2021-09-25 21:00:58 +01:00
|
|
|
|
return new SimpleAlbum()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Uri = name,
|
|
|
|
|
Artists = artists.Select(a => SimpleArtist(a)).ToList()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SimpleAlbum SimpleAlbum(string name, string artist)
|
|
|
|
|
{
|
|
|
|
|
return SimpleAlbum(name, new List<string>() { artist });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SimpleArtist SimpleArtist(string name)
|
|
|
|
|
{
|
|
|
|
|
return new SimpleArtist()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Uri = name
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-09-26 12:11:44 +01:00
|
|
|
|
|
2021-09-26 15:25:54 +01:00
|
|
|
|
public static SimpleShow SimpleShow(string name, string publisher = null)
|
|
|
|
|
{
|
|
|
|
|
return new SimpleShow()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Publisher = publisher ?? name,
|
|
|
|
|
Uri = name
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 12:11:44 +01:00
|
|
|
|
public static CurrentlyPlaying CurrentlyPlaying(FullTrack track, bool isPlaying = true, string context = null)
|
|
|
|
|
{
|
|
|
|
|
return new CurrentlyPlaying()
|
|
|
|
|
{
|
|
|
|
|
Context = Context(context ?? track.Uri),
|
|
|
|
|
IsPlaying = isPlaying,
|
|
|
|
|
Item = track
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-01 22:01:28 +01:00
|
|
|
|
public static CurrentlyPlayingContext CurrentPlayback(FullTrack track, Device device = null, bool isPlaying = true, string context = "context")
|
2021-09-28 21:14:52 +01:00
|
|
|
|
{
|
|
|
|
|
return new CurrentlyPlayingContext()
|
|
|
|
|
{
|
2021-10-01 22:01:28 +01:00
|
|
|
|
Context = Context(context),
|
2021-09-28 21:14:52 +01:00
|
|
|
|
Device = device ?? Device("device"),
|
|
|
|
|
IsPlaying = isPlaying,
|
|
|
|
|
Item = track
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 15:25:54 +01:00
|
|
|
|
public static CurrentlyPlaying CurrentlyPlaying(FullEpisode episode, bool isPlaying = true, string context = null)
|
|
|
|
|
{
|
|
|
|
|
return new CurrentlyPlaying()
|
|
|
|
|
{
|
|
|
|
|
Context = Context(context ?? episode.Uri),
|
|
|
|
|
IsPlaying = isPlaying,
|
|
|
|
|
Item = episode
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-28 21:14:52 +01:00
|
|
|
|
public static CurrentlyPlayingContext CurrentPlayback(FullEpisode episode, Device device = null, bool isPlaying = true, string context = null)
|
|
|
|
|
{
|
|
|
|
|
return new CurrentlyPlayingContext()
|
|
|
|
|
{
|
|
|
|
|
Context = Context(context ?? episode.Uri),
|
|
|
|
|
Device = device ?? Device("device"),
|
|
|
|
|
IsPlaying = isPlaying,
|
|
|
|
|
Item = episode
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 12:11:44 +01:00
|
|
|
|
public static Context Context(string uri)
|
|
|
|
|
{
|
|
|
|
|
return new Context()
|
|
|
|
|
{
|
|
|
|
|
Uri = uri
|
|
|
|
|
};
|
|
|
|
|
}
|
2021-09-28 21:14:52 +01:00
|
|
|
|
|
|
|
|
|
public static Device Device(string name, string id = null, int volume = 50)
|
|
|
|
|
{
|
|
|
|
|
return new Device()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Id = id ?? name,
|
|
|
|
|
Type = "computer",
|
|
|
|
|
VolumePercent = volume
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-06-28 07:30:27 +01:00
|
|
|
|
|
|
|
|
|
public static FullPlaylist FullPlaylist(string name, string id = null, string snapshotId = null)
|
|
|
|
|
{
|
|
|
|
|
return new FullPlaylist()
|
|
|
|
|
{
|
|
|
|
|
Name = name,
|
|
|
|
|
Id = id ?? name,
|
2022-06-28 07:46:00 +01:00
|
|
|
|
SnapshotId = snapshotId ?? id ?? name,
|
|
|
|
|
Tracks = new()
|
|
|
|
|
{
|
|
|
|
|
Items = new List<PlaylistTrack<IPlayableItem>>(),
|
|
|
|
|
Total = 0
|
|
|
|
|
}
|
2022-06-28 07:30:27 +01:00
|
|
|
|
};
|
|
|
|
|
}
|
2021-09-25 21:00:58 +01:00
|
|
|
|
}
|
|
|
|
|
}
|