mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Load definitions from multiple directories
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Jackett.Services
|
|||||||
T GetConfig<T>();
|
T GetConfig<T>();
|
||||||
void SaveConfig<T>(T config);
|
void SaveConfig<T>(T config);
|
||||||
string ApplicationFolder();
|
string ApplicationFolder();
|
||||||
string GetCardigannDefinitionsFolder();
|
List<string> GetCardigannDefinitionsFolders();
|
||||||
void CreateOrMigrateSettings();
|
void CreateOrMigrateSettings();
|
||||||
void PerformMigration();
|
void PerformMigration();
|
||||||
}
|
}
|
||||||
@@ -198,8 +198,21 @@ namespace Jackett.Services
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCardigannDefinitionsFolder()
|
public List<string> GetCardigannDefinitionsFolders()
|
||||||
{
|
{
|
||||||
|
List<string> dirs = new List<string>();
|
||||||
|
|
||||||
|
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
|
{
|
||||||
|
dirs.Add(Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".config/cardigann/definitions/"));
|
||||||
|
dirs.Add("/etc/xdg/cardigan/definitions/");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirs.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "cardigann\\definitions\\"));
|
||||||
|
dirs.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cardigann\\definitions\\"));
|
||||||
|
}
|
||||||
|
|
||||||
// If we are debugging we can use the non copied definitions.
|
// If we are debugging we can use the non copied definitions.
|
||||||
string dir = Path.Combine(ApplicationFolder(), "Definitions"); ;
|
string dir = Path.Combine(ApplicationFolder(), "Definitions"); ;
|
||||||
|
|
||||||
@@ -211,7 +224,8 @@ namespace Jackett.Services
|
|||||||
dir = sourcePath;
|
dir = sourcePath;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return dir;
|
dirs.Add(dir);
|
||||||
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetVersion()
|
public string GetVersion()
|
||||||
|
@@ -76,10 +76,14 @@ namespace Jackett.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
return;
|
||||||
|
|
||||||
DirectoryInfo d = new DirectoryInfo(path);
|
DirectoryInfo d = new DirectoryInfo(path);
|
||||||
|
|
||||||
foreach (var file in d.GetFiles("*.yml"))
|
foreach (var file in d.GetFiles("*.yml"))
|
||||||
{
|
{
|
||||||
|
logger.Info("Loading Cardigann definition " + file.FullName);
|
||||||
string DefinitionString = File.ReadAllText(file.FullName);
|
string DefinitionString = File.ReadAllText(file.FullName);
|
||||||
CardigannIndexer idx = new CardigannIndexer(this, container.Resolve<IWebClient>(), logger, container.Resolve<IProtectionService>(), DefinitionString);
|
CardigannIndexer idx = new CardigannIndexer(this, container.Resolve<IWebClient>(), logger, container.Resolve<IProtectionService>(), DefinitionString);
|
||||||
if (indexers.ContainsKey(idx.ID))
|
if (indexers.ContainsKey(idx.ID))
|
||||||
|
@@ -150,7 +150,10 @@ namespace Jackett.Services
|
|||||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
||||||
// Load indexers
|
// Load indexers
|
||||||
indexerService.InitIndexers();
|
indexerService.InitIndexers();
|
||||||
indexerService.InitCardigannIndexers(configService.GetCardigannDefinitionsFolder());
|
foreach(string dir in configService.GetCardigannDefinitionsFolders())
|
||||||
|
{
|
||||||
|
indexerService.InitCardigannIndexers(dir);
|
||||||
|
}
|
||||||
client.Init();
|
client.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user