This commit is contained in:
Steven Hildreth 2018-11-05 21:43:17 -06:00
parent 0b24085d90
commit 7d078a0920
3 changed files with 120 additions and 2 deletions

View file

@ -0,0 +1,48 @@
using Roadie.Library.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Roadie.Library.Models.Player
{
[Serializable]
public class PlayResult
{
public List<PlayResultTrack> Tracks { get; set; }
public string TotalTrackTime
{
get
{
return TimeSpan.FromMilliseconds((double)this.Tracks.Sum(x => x.Duration)).ToString(@"hh\:mm\:ss");
}
}
public string TrackCount
{
get
{
return this.Tracks.Count().ToString("D3");
}
}
private string _rawTracks = null;
public string RawTracks
{
get
{
return this._rawTracks ?? (this._rawTracks = Newtonsoft.Json.JsonConvert.SerializeObject(this.Tracks));
}
}
public string SiteName { get; set; }
public PlayResult(IRoadieSettings configuration)
{
this.SiteName = configuration.SiteName;
this.Tracks = new List<PlayResultTrack>();
}
}
}

View file

@ -0,0 +1,64 @@
using Roadie.Library.Data;
using Roadie.Library.Models.Releases;
using System;
using System.Collections.Generic;
using System.Text;
namespace Roadie.Library.Models.Player
{
[Serializable]
public class PlayResultTrack
{
private readonly string _baseUrl = null;
public ArtistList Artist { get; set; }
public ReleaseList Release { get; set; }
public TrackList Track { get; set; }
public UserTrack UserTrack { get; set; }
public int? Duration
{
get
{
return this.Track.Duration;
}
}
public string StreamUrl
{
get
{
// The cb paramneter is because Firefox caches this and prevents playcount from being updated
return $"{ this._baseUrl}/play/stream/{ this.Track.Id }/?cb=" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
}
}
public string ShowArtistId
{
get
{
return this.Track.TrackArtist?.Text ?? this.Artist.Artist.Text;
}
}
public string ShowArtistName
{
get
{
if (this.Track.TrackArtist != null)
{
return this.Track.TrackArtist.Text;
}
return this.Artist.Artist.Text;
}
}
public PlayResultTrack(string baseUrl)
{
this._baseUrl = baseUrl;
}
}
}

View file

@ -15,8 +15,7 @@ namespace Roadie.Library.Models
public Guid ReleaseArtistId { get; set; }
public string ReleaseArtistName { get; set; }
public string ReleaseArtistThumbnail { get; set; }
public Guid? TrackArtistId { get; set; }
public string TrackArtistName { get; set; }
public DataToken TrackArtist { get; set; }
public string TrackArtistThumbnail { get; set; }
public string Title { get; set; }
public int? Duration { get; set; }
@ -27,6 +26,13 @@ namespace Roadie.Library.Models
return this.Duration.HasValue ? TimeSpan.FromSeconds(this.Duration.Value / 1000).ToString(@"hh\:mm\:ss") : "--:--";
}
}
public string DurationTimeShort
{
get
{
return this.Duration.HasValue ? TimeSpan.FromSeconds(this.Duration.Value / 1000).ToString(@"mm\:ss") : "--:--";
}
}
public short? Rating { get; set; }
public short? UserRating { get; set; }
public bool? IsUserFavorite { get; set; }