Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Commit

Permalink
Added Result Saving #25
Browse files Browse the repository at this point in the history
Saving Results to measure improvements on result filter
  • Loading branch information
BackInBash committed Nov 16, 2019
1 parent ae75c28 commit b21b957
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
14 changes: 13 additions & 1 deletion DeezerSync/DeezerSync.Core/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
using System.Linq;
using System.Threading.Tasks;
using DeezerSync.Log;
using System.IO;
using System.Reflection;
using Newtonsoft.Json;

namespace DeezerSync.Core
{
partial class DebugResult
{
public StandardTitle Searching;
public List<StandardTitle> Results;
}
public class Search
{
private List<StandardPlaylist> MusicProvider;
Expand Down Expand Up @@ -170,6 +178,10 @@ protected async Task<bool> AddSongToPlaylist(string id, List<long> ids)
/// <returns></returns>
protected async Task<long> search(List<StandardTitle> results, StandardTitle Searching)
{
#if DEBUG
Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\results\\");
await File.WriteAllTextAsync(Directory.GetCurrentDirectory() + "\\results\\" + Searching.title+".json", JsonConvert.SerializeObject(new DebugResult { Searching = Searching, Results = results }, Formatting.Indented));
#endif
foreach (var result in results)
{
//Artist
Expand Down Expand Up @@ -291,7 +303,7 @@ protected async Task<List<StandardTitle>> ExecuteQuery(StandardTitle query)
Prepare p = new Prepare();
foreach (var i in res.Data)
{
tracks.Add(await p.PrepareDeezerQuery(new StandardTitle { description = string.Empty, duration = (int)i.Duration, genre = string.Empty, id = i.Id.Value, labelname = string.Empty, search_stage = 0, title = i.Title, username = i.Artist.Name, artist = i.Artist.Name }));
tracks.Add(await p.PrepareDeezerQuery(new StandardTitle { description = string.Empty, duration = (int)i.Duration, genre = string.Empty, id = i.Id.Value, labelname = string.Empty, search_stage = 0, title = i.Title, username = i.Artist.Name, artist = i.Artist.Name, url = i.Link.AbsoluteUri }));
}
return tracks;
}
Expand Down
4 changes: 4 additions & 0 deletions DeezerSync/DeezerSync.Models/StandardTitel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public partial class StandardTitle
/// Marks filter stage in queue
/// </summary>
public int search_stage { get; set; }
/// <summary>
/// Song Url
/// </summary>
public string url { get; set; }

}
}
2 changes: 1 addition & 1 deletion DeezerSync/DeezerSync.MusicProvider/SoundCloud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task<List<StandardPlaylist>> GetStandardPlaylists()
try
{
var userinfo = a.User;
track.Add(new StandardTitle { username = userinfo.Username, description = a.Description, duration = a.Duration / 1000, genre = a.Genre, labelname = a.LabelName ?? string.Empty, title = a.Title, id = (long)i.Id });
track.Add(new StandardTitle { username = userinfo.Username, description = a.Description, duration = a.Duration / 1000, genre = a.Genre, labelname = a.LabelName ?? string.Empty, title = a.Title, id = (long)i.Id, url = a.PermalinkUrl.AbsoluteUri });

}
catch (Exception e)
Expand Down
2 changes: 1 addition & 1 deletion DeezerSync/DeezerSync.MusicProvider/Spotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task<List<StandardPlaylist>> GetStandardPlaylists()
List<StandardTitle> track = new List<StandardTitle>();
foreach(var trck in playlist.Tracks.Items)
{
track.Add(new StandardTitle { username = trck.Track.Artists[0].Name, description = trck.Track.Album.Name, duration = trck.Track.DurationMs, genre = trck.Track.Type, title = trck.Track.Name});
track.Add(new StandardTitle { username = trck.Track.Artists[0].Name, description = trck.Track.Album.Name, duration = trck.Track.DurationMs, genre = trck.Track.Type, title = trck.Track.Name, url = trck.Track.Uri});
}
stp.tracks = track;
Playlists.Add(stp);
Expand Down
1 change: 0 additions & 1 deletion DeezerSync/DeezerSync/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ static async System.Threading.Tasks.Task Main(string[] args)
{
musicprovider_playlist = new MusicProvider.main(config.soundcloud_profile, config.spotify_profile, config.spotify_secret, config.soundcloud_clientid);
}
File.WriteAllText("spotify.json", JsonConvert.SerializeObject(musicprovider_playlist.Data, Formatting.Indented));
// Start Search
DeezerSync.Core.Search core = new DeezerSync.Core.Search(musicprovider_playlist.Data, await api.GetAllPlaylistsasync());
await core.Start();
Expand Down

0 comments on commit b21b957

Please sign in to comment.