forked from musicbeeremote/mbrc-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MockLibrary.cs
42 lines (38 loc) · 1.17 KB
/
MockLibrary.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using MusicBeeRemote.Core.Model.Entities;
using Newtonsoft.Json;
namespace MbrcTester
{
public class MockLibrary
{
private List<MockTrackMetadata> library;
public MockLibrary()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mock_library.json");
// deserialize JSON directly from a file
using (var file = File.OpenText($"{path}"))
{
library = JsonConvert.DeserializeObject<List<MockTrackMetadata>>(file.ReadToEnd());
}
}
public IEnumerable<Track> GetTracks()
{
return library.Select(metadata => new Track()
{
Album = metadata.Album,
AlbumArtist = metadata.AlbumArtist,
Disc = metadata.Disc,
Artist = metadata.Artist,
Genre = metadata.Genre,
Src = metadata._id,
Title = metadata.Title,
Trackno = metadata.TrackNo,
Year = metadata.Year
});
}
}
}