@ -1,67 +1,160 @@
@@ -1,67 +1,160 @@
namespace ErsatzTV.Core ;
using System.Reflection ;
namespace ErsatzTV.Core ;
public static class FileSystemLayout
{
public static readonly string AppDataFolder = Path . Combine (
Environment . GetFolderPath (
Environment . SpecialFolder . LocalApplicationData ,
Environment . SpecialFolderOption . Create ) ,
"ersatztv" ) ;
static FileSystemLayout ( )
{
string version = Assembly . GetEntryAssembly ( ) ? . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( )
? . InformationalVersion ? ? "unknown" ;
bool isDocker = version . Contains ( "docker" , StringComparison . OrdinalIgnoreCase ) ;
string defaultConfigFolder = Path . Combine (
Environment . GetFolderPath (
Environment . SpecialFolder . LocalApplicationData ,
Environment . SpecialFolderOption . DoNotVerify ) ,
"ersatztv" ) ;
string customConfigFolder = Environment . GetEnvironmentVariable ( "ETV_CONFIG_FOLDER" ) ;
bool useCustomConfigFolder = ! string . IsNullOrWhiteSpace ( customConfigFolder ) ;
if ( useCustomConfigFolder & & isDocker )
{
// check for config at old location
if ( Directory . Exists ( defaultConfigFolder ) )
{
Serilog . Log . Logger . Warning (
"Ignoring ETV_CONFIG_FOLDER {Folder} and using default {Default}" ,
customConfigFolder ,
defaultConfigFolder ) ;
// ignore custom config folder
useCustomConfigFolder = false ;
}
}
AppDataFolder = useCustomConfigFolder ? customConfigFolder : defaultConfigFolder ;
string defaultTranscodeFolder = Path . Combine (
Environment . GetFolderPath (
Environment . SpecialFolder . LocalApplicationData ,
Environment . SpecialFolderOption . DoNotVerify ) ,
"etv-transcode" ) ;
string customTranscodeFolder = Environment . GetEnvironmentVariable ( "ETV_TRANSCODE_FOLDER" ) ;
bool useCustomTranscodeFolder = ! string . IsNullOrWhiteSpace ( customTranscodeFolder ) ;
if ( useCustomTranscodeFolder & & isDocker )
{
// check for config at old location
if ( Directory . Exists ( defaultTranscodeFolder ) )
{
Serilog . Log . Logger . Warning (
"Ignoring ETV_TRANSCODE_FOLDER {Folder} and using default {Default}" ,
customTranscodeFolder ,
defaultTranscodeFolder ) ;
// ignore custom config folder
useCustomTranscodeFolder = false ;
}
}
TranscodeFolder = useCustomTranscodeFolder ? customTranscodeFolder : defaultTranscodeFolder ;
DataProtectionFolder = Path . Combine ( AppDataFolder , "data-protection" ) ;
LogsFolder = Path . Combine ( AppDataFolder , "logs" ) ;
DatabasePath = Path . Combine ( AppDataFolder , "ersatztv.sqlite3" ) ;
LogFilePath = Path . Combine ( LogsFolder , "ersatztv.log" ) ;
LegacyImageCacheFolder = Path . Combine ( AppDataFolder , "cache" , "images" ) ;
ResourcesCacheFolder = Path . Combine ( AppDataFolder , "cache" , "resources" ) ;
ChannelGuideCacheFolder = Path . Combine ( AppDataFolder , "cache" , "channel-guide" ) ;
PlexSecretsPath = Path . Combine ( AppDataFolder , "plex-secrets.json" ) ;
JellyfinSecretsPath = Path . Combine ( AppDataFolder , "jellyfin-secrets.json" ) ;
EmbySecretsPath = Path . Combine ( AppDataFolder , "emby-secrets.json" ) ;
FFmpegReportsFolder = Path . Combine ( AppDataFolder , "ffmpeg-reports" ) ;
SearchIndexFolder = Path . Combine ( AppDataFolder , "search-index" ) ;
TempFilePoolFolder = Path . Combine ( AppDataFolder , "temp-pool" ) ;
ArtworkCacheFolder = Path . Combine ( AppDataFolder , "cache" , "artwork" ) ;
ArtworkCacheFolder = Path . Combine ( AppDataFolder , "cache" , "artwork" ) ;
PosterCacheFolder = Path . Combine ( ArtworkCacheFolder , "posters" ) ;
ThumbnailCacheFolder = Path . Combine ( ArtworkCacheFolder , "thumbnails" ) ;
LogoCacheFolder = Path . Combine ( ArtworkCacheFolder , "logos" ) ;
FanArtCacheFolder = Path . Combine ( ArtworkCacheFolder , "fanart" ) ;
WatermarkCacheFolder = Path . Combine ( ArtworkCacheFolder , "watermarks" ) ;
StreamsCacheFolder = Path . Combine ( AppDataFolder , "cache" , "streams" ) ;
SubtitleCacheFolder = Path . Combine ( StreamsCacheFolder , "subtitles" ) ;
FontsCacheFolder = Path . Combine ( StreamsCacheFolder , "fonts" ) ;
TemplatesFolder = Path . Combine ( AppDataFolder , "templates" ) ;
MusicVideoCreditsTemplatesFolder = Path . Combine ( TemplatesFolder , "music-video-credits" ) ;
ChannelGuideTemplatesFolder = Path . Combine ( TemplatesFolder , "channel-guide" ) ;
ScriptsFolder = Path . Combine ( AppDataFolder , "scripts" ) ;
MultiEpisodeShuffleTemplatesFolder = Path . Combine ( ScriptsFolder , "multi-episode-shuffle" ) ;
// TODO: find a different spot for this; configurable?
public static readonly string TranscodeFolder = Path . Combine (
Environment . GetFolderPath (
Environment . SpecialFolder . LocalApplicationData ,
Environment . SpecialFolderOption . Create ) ,
"etv-transcode" ) ;
AudioStreamSelectorScriptsFolder = Path . Combine ( ScriptsFolder , "audio-stream-selector" ) ;
}
public static readonly string DataProtectionFolder = Path . Combine ( AppDataFolder , "data-protection" ) ;
public static readonly string AppDataFolder ;
public static readonly string LogsFolder = Path . Combine ( AppDataFolder , "logs" ) ;
public static readonly string TranscodeFolder ;
public static readonly string DatabasePath = Path . Combine ( AppDataFolder , "ersatztv.sqlite3" ) ;
public static readonly string DataProtectionFolder ;
public static readonly string LogsFolder ;
public static readonly string LogFilePath = Path . Combine ( LogsFolder , "ersatztv.log" ) ;
public static readonly string DatabasePath ;
public static readonly string LogFilePath ;
public static readonly string LegacyImageCacheFolder = Path . Combine ( AppDataFolder , "cache" , "images" ) ;
public static readonly string ResourcesCacheFolder = Path . Combine ( AppDataFolder , "cache" , "resources" ) ;
public static readonly string ChannelGuideCacheFolder = Path . Combine ( AppDataFolder , "cache" , "channel-guide" ) ;
public static readonly string LegacyImageCacheFolder ;
public static readonly string ResourcesCacheFolder ;
public static readonly string ChannelGuideCacheFolder ;
public static readonly string PlexSecretsPath = Path . Combine ( AppDataFolder , "plex-secrets.json" ) ;
public static readonly string JellyfinSecretsPath = Path . Combine ( AppDataFolder , "jellyfin-secrets.json" ) ;
public static readonly string EmbySecretsPath = Path . Combine ( AppDataFolder , "emby-secrets.json" ) ;
public static readonly string PlexSecretsPath ;
public static readonly string JellyfinSecretsPath ;
public static readonly string EmbySecretsPath ;
public static readonly string FFmpegReportsFolder = Path . Combine ( AppDataFolder , "ffmpeg-reports" ) ;
public static readonly string SearchIndexFolder = Path . Combine ( AppDataFolder , "search-index" ) ;
public static readonly string TempFilePoolFolder = Path . Combine ( AppDataFolder , "temp-pool" ) ;
public static readonly string FFmpegReportsFolder ;
public static readonly string SearchIndexFolder ;
public static readonly string TempFilePoolFolder ;
public static readonly string ArtworkCacheFolder = Path . Combine ( AppDataFolder , "cache" , "artwork" ) ;
public static readonly string ArtworkCacheFolder ;
public static readonly string PosterCacheFolder = Path . Combine ( ArtworkCacheFolder , "posters" ) ;
public static readonly string ThumbnailCacheFolder = Path . Combine ( ArtworkCacheFolder , "thumbnails" ) ;
public static readonly string LogoCacheFolder = Path . Combine ( ArtworkCacheFolder , "logos" ) ;
public static readonly string FanArtCacheFolder = Path . Combine ( ArtworkCacheFolder , "fanart" ) ;
public static readonly string WatermarkCacheFolder = Path . Combine ( ArtworkCacheFolder , "watermarks" ) ;
public static readonly string PosterCacheFolder ;
public static readonly string ThumbnailCacheFolder ;
public static readonly string LogoCacheFolder ;
public static readonly string FanArtCacheFolder ;
public static readonly string WatermarkCacheFolder ;
public static readonly string StreamsCacheFolder = Path . Combine ( AppDataFolder , "cache" , "streams" ) ;
public static readonly string StreamsCacheFolder ;
public static readonly string SubtitleCacheFolder = Path . Combine ( StreamsCacheFolder , "subtitles" ) ;
public static readonly string FontsCacheFolder = Path . Combine ( StreamsCacheFolder , "fonts" ) ;
public static readonly string SubtitleCacheFolder ;
public static readonly string FontsCacheFolder ;
public static readonly string TemplatesFolder = Path . Combine ( AppDataFolder , "templates" ) ;
public static readonly string TemplatesFolder ;
public static readonly string MusicVideoCreditsTemplatesFolder =
Path . Combine ( TemplatesFolder , "music-video-credits" ) ;
public static readonly string MusicVideoCreditsTemplatesFolder ;
public static readonly string ChannelGuideTemplatesFolder = Path . Combine ( TemplatesFolder , "channel-guide" ) ;
public static readonly string ChannelGuideTemplatesFolder ;
public static readonly string ScriptsFolder = Path . Combine ( AppDataFolder , "scripts" ) ;
public static readonly string ScriptsFolder ;
public static readonly string MultiEpisodeShuffleTemplatesFolder =
Path . Combine ( ScriptsFolder , "multi-episode-shuffle" ) ;
public static readonly string MultiEpisodeShuffleTemplatesFolder ;
public static readonly string AudioStreamSelectorScriptsFolder =
Path . Combine ( ScriptsFolder , "audio-stream-selector" ) ;
public static readonly string AudioStreamSelectorScriptsFolder ;
public static readonly string MacOsOldAppDataFolder = Path . Combine (
Environment . GetEnvironmentVariable ( "HOME" ) ? ? string . Empty ,