diff --git a/.env.example b/.env.example
index d20e7e37..b4d74dd0 100644
--- a/.env.example
+++ b/.env.example
@@ -1,7 +1,7 @@
# Useful config options
LIBRARY_ROOT=/video
TVDB__APIKEY=
-THEMOVIEDB__APIKEY=
+THEMOVIEDB_APIKEY=
PUBLIC_BACK_URL=http://localhost:5000
AUTHENTICATION_SECRET=
diff --git a/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs
index f74c32e9..76a7a8bb 100644
--- a/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs
+++ b/back/src/Kyoo.Core/Controllers/Repositories/LibraryRepository.cs
@@ -98,6 +98,7 @@ namespace Kyoo.Core.Controllers
?? await _providers.CreateIfNotExists(x)
)
.ToListAsync();
+ _database.AttachRange(resource.Providers);
}
}
diff --git a/back/src/Kyoo.TheMovieDb/PluginTmdb.cs b/back/src/Kyoo.TheMovieDb/PluginTmdb.cs
index e20149b5..cc009f44 100644
--- a/back/src/Kyoo.TheMovieDb/PluginTmdb.cs
+++ b/back/src/Kyoo.TheMovieDb/PluginTmdb.cs
@@ -21,7 +21,6 @@ using System.Collections.Generic;
using Autofac;
using Kyoo.Abstractions;
using Kyoo.Abstractions.Controllers;
-using Kyoo.TheMovieDb.Models;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
@@ -62,13 +61,10 @@ namespace Kyoo.TheMovieDb
public string Description => "A metadata provider for TheMovieDB.";
///
- public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue("themoviedb:apikey"));
+ public bool Enabled => !string.IsNullOrEmpty(_configuration.GetValue("THEMOVIEDB_APIKEY"));
///
- public Dictionary Configuration => new()
- {
- { TheMovieDbOptions.Path, typeof(TheMovieDbOptions) }
- };
+ public Dictionary Configuration => new();
///
public void Configure(ContainerBuilder builder)
diff --git a/back/src/Kyoo.TheMovieDb/TheMovieDbOptions.cs b/back/src/Kyoo.TheMovieDb/TheMovieDbOptions.cs
deleted file mode 100644
index a4ddcc2c..00000000
--- a/back/src/Kyoo.TheMovieDb/TheMovieDbOptions.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Kyoo - A portable and vast media library solution.
-// Copyright (c) Kyoo.
-//
-// See AUTHORS.md and LICENSE file in the project root for full license information.
-//
-// Kyoo is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// any later version.
-//
-// Kyoo is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Kyoo. If not, see .
-
-namespace Kyoo.TheMovieDb.Models
-{
- ///
- /// The option containing the api key for TheMovieDb.
- ///
- public class TheMovieDbOptions
- {
- ///
- /// The path to get this option from the root configuration.
- ///
- public const string Path = "themoviedb";
-
- ///
- /// The api key of TheMovieDb.
- ///
- public string ApiKey { get; set; }
- }
-}
diff --git a/back/src/Kyoo.TheMovieDb/TheMovieDbProvider.cs b/back/src/Kyoo.TheMovieDb/TheMovieDbProvider.cs
index a68ca206..9ca635ce 100644
--- a/back/src/Kyoo.TheMovieDb/TheMovieDbProvider.cs
+++ b/back/src/Kyoo.TheMovieDb/TheMovieDbProvider.cs
@@ -22,9 +22,8 @@ using System.Linq;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
-using Kyoo.TheMovieDb.Models;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
using TMDbLib.Client;
using TMDbLib.Objects.Movies;
using TMDbLib.Objects.Search;
@@ -40,7 +39,7 @@ namespace Kyoo.TheMovieDb
///
/// The API key used to authenticate with TheMovieDb API.
///
- private readonly IOptions _apiKey;
+ private readonly string _apiKey;
///
/// The logger to use in ase of issue.
@@ -62,11 +61,11 @@ namespace Kyoo.TheMovieDb
///
/// Create a new using the given api key.
///
- /// The api key.
+ /// The api key.
/// The logger to use in case of issue.
- public TheMovieDbProvider(IOptions apiKey, ILogger logger)
+ public TheMovieDbProvider(IConfiguration config, ILogger logger)
{
- _apiKey = apiKey;
+ _apiKey = config.GetValue("THEMOVIEDB_APIKEY");
_logger = logger;
}
@@ -100,7 +99,7 @@ namespace Kyoo.TheMovieDb
return found;
}
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.GetCollectionAsync(id)).ToCollection(Provider);
}
@@ -119,7 +118,7 @@ namespace Kyoo.TheMovieDb
return found;
}
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
if (show.IsMovie)
{
@@ -150,7 +149,7 @@ namespace Kyoo.TheMovieDb
if (!season.Show.TryGetID(Provider.Slug, out int id))
return null;
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.GetTvSeasonAsync(id, season.SeasonNumber))
.ToSeason(id, Provider);
}
@@ -173,7 +172,7 @@ namespace Kyoo.TheMovieDb
|| episode.SeasonNumber == null || episode.EpisodeNumber == null)
return null;
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.GetTvEpisodeAsync(id, episode.SeasonNumber.Value, episode.EpisodeNumber.Value))
?.ToEpisode(id, Provider);
}
@@ -192,7 +191,7 @@ namespace Kyoo.TheMovieDb
return found;
}
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.GetPersonAsync(id)).ToPeople(Provider);
}
@@ -210,7 +209,7 @@ namespace Kyoo.TheMovieDb
return found;
}
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.GetCompanyAsync(id)).ToStudio(Provider);
}
@@ -236,7 +235,7 @@ namespace Kyoo.TheMovieDb
/// A list of collections containing metadata from TheMovieDb
private async Task> _SearchCollections(string query)
{
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.SearchCollectionAsync(query))
.Results
.Select(x => x.ToCollection(Provider))
@@ -251,7 +250,7 @@ namespace Kyoo.TheMovieDb
/// A list of shows containing metadata from TheMovieDb
private async Task> _SearchShows(string query, int? year = null)
{
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.SearchMultiAsync(query, year: year ?? 0))
.Results
.Select(x =>
@@ -274,7 +273,7 @@ namespace Kyoo.TheMovieDb
/// A list of people containing metadata from TheMovieDb
private async Task> _SearchPeople(string query)
{
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.SearchPersonAsync(query))
.Results
.Select(x => x.ToPeople(Provider))
@@ -288,7 +287,7 @@ namespace Kyoo.TheMovieDb
/// A list of studios containing metadata from TheMovieDb
private async Task> _SearchStudios(string query)
{
- TMDbClient client = new(_apiKey.Value.ApiKey);
+ TMDbClient client = new(_apiKey);
return (await client.SearchCompanyAsync(query))
.Results
.Select(x => x.ToStudio(Provider))
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index c5b784db..2966adfe 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -15,7 +15,7 @@ services:
volumes:
- ./back:/app
- /app/out/
- - kyoo:/var/lib/kyoo
+ - kyoo:/kyoo
- ./video:/video
front:
build: