2019-07-31 11:44:25 -05:00
|
|
|
|
using Roadie.Library.Configuration;
|
|
|
|
|
using Roadie.Library.Extensions;
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2018-11-11 14:10:10 -06:00
|
|
|
|
|
|
|
|
|
namespace Roadie.Library.Data
|
|
|
|
|
{
|
|
|
|
|
public partial class Playlist
|
|
|
|
|
{
|
2019-07-03 11:21:29 -05:00
|
|
|
|
public string CacheKey => CacheUrn(RoadieId);
|
|
|
|
|
|
|
|
|
|
public string CacheRegion => CacheRegionUrn(RoadieId);
|
|
|
|
|
|
2018-11-11 14:10:10 -06:00
|
|
|
|
public static string CacheRegionUrn(Guid Id)
|
|
|
|
|
{
|
|
|
|
|
return string.Format("urn:playlist:{0}", Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string CacheUrn(Guid Id)
|
|
|
|
|
{
|
2019-07-03 11:21:29 -05:00
|
|
|
|
return $"urn:playlist_by_id:{Id}";
|
2018-12-12 08:31:39 -06:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 11:44:25 -05:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns a full file path to the Playlist Image
|
|
|
|
|
/// </summary>
|
2019-11-10 08:48:07 -06:00
|
|
|
|
public string PathToImage(IRoadieSettings configuration, bool makeFolderIfNotExist = false)
|
2019-07-31 11:44:25 -05:00
|
|
|
|
{
|
2019-11-10 08:48:07 -06:00
|
|
|
|
var folder = configuration.PlaylistImageFolder;
|
|
|
|
|
if (!Directory.Exists(folder) && makeFolderIfNotExist)
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(folder);
|
|
|
|
|
}
|
|
|
|
|
return Path.Combine(folder, $"{ (SortName ?? Name).ToFileNameFriendly() } [{ Id }].jpg");
|
2019-07-31 11:44:25 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-11-25 10:57:17 -06:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
2019-07-03 11:21:29 -05:00
|
|
|
|
return $"Id [{Id}], Name [{Name}], RoadieId [{RoadieId}]";
|
2018-11-25 10:57:17 -06:00
|
|
|
|
}
|
2018-11-11 14:10:10 -06:00
|
|
|
|
}
|
2019-07-03 11:21:29 -05:00
|
|
|
|
}
|