Support movie collections
This commit is contained in:
parent
fefcc7ab11
commit
aa4e8dae59
|
@ -32,7 +32,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestGetMetadata()
|
public void TestGetMetadata()
|
||||||
{
|
{
|
||||||
var info = new MovieInfo() { Name = "南极料理人" };
|
|
||||||
var doubanApi = new DoubanApi(loggerFactory);
|
var doubanApi = new DoubanApi(loggerFactory);
|
||||||
var tmdbApi = new TmdbApi(loggerFactory);
|
var tmdbApi = new TmdbApi(loggerFactory);
|
||||||
var omdbApi = new OmdbApi(loggerFactory);
|
var omdbApi = new OmdbApi(loggerFactory);
|
||||||
|
@ -42,6 +42,7 @@ namespace Jellyfin.Plugin.MetaShark.Test
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
var info = new MovieInfo() { Name = "南极料理人", MetadataLanguage = "zh" };
|
||||||
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
var provider = new MovieProvider(httpClientFactory, loggerFactory, libraryManagerStub.Object, httpContextAccessorStub.Object, doubanApi, tmdbApi, omdbApi);
|
||||||
var result = await provider.GetMetadata(info, CancellationToken.None);
|
var result = await provider.GetMetadata(info, CancellationToken.None);
|
||||||
Assert.IsNotNull(result);
|
Assert.IsNotNull(result);
|
||||||
|
|
|
@ -42,6 +42,10 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||||
public bool EnableTmdbSearch { get; set; } = false;
|
public bool EnableTmdbSearch { get; set; } = false;
|
||||||
|
|
||||||
public bool EnableTmdbBackdrop { get; set; } = false;
|
public bool EnableTmdbBackdrop { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否获取电影系列信息
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableTmdbCollection { get; set; } = true;
|
||||||
|
|
||||||
public string TmdbApiKey { get; set; } = string.Empty;
|
public string TmdbApiKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,14 @@
|
||||||
</label>
|
</label>
|
||||||
<div class="fieldDescription">勾选后,当影片在豆瓣找不到背景图时,改使用TheMovieDb的补全</div>
|
<div class="fieldDescription">勾选后,当影片在豆瓣找不到背景图时,改使用TheMovieDb的补全</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||||
|
<label class="emby-checkbox-label" for="EnableTmdbCollection">
|
||||||
|
<input id="EnableTmdbCollection" name="EnableTmdbCollection" type="checkbox"
|
||||||
|
is="emby-checkbox" />
|
||||||
|
<span>从TheMovieDb获取电影系列信息</span>
|
||||||
|
</label>
|
||||||
|
<div class="fieldDescription">勾选后,刮削会变慢,会自动创建电影系列合集(需先在媒体库配置中打开<b>自动添加到合集</b>功能)</div>
|
||||||
|
</div>
|
||||||
<div class="inputContainer">
|
<div class="inputContainer">
|
||||||
<label class="inputLabel inputLabelUnfocused" for="TmdbApiKey">Api Key</label>
|
<label class="inputLabel inputLabelUnfocused" for="TmdbApiKey">Api Key</label>
|
||||||
<input id="TmdbApiKey" name="TmdbApiKey" type="text" is="emby-input" />
|
<input id="TmdbApiKey" name="TmdbApiKey" type="text" is="emby-input" />
|
||||||
|
@ -122,6 +130,7 @@
|
||||||
document.querySelector('#EnableTmdb').checked = config.EnableTmdb;
|
document.querySelector('#EnableTmdb').checked = config.EnableTmdb;
|
||||||
document.querySelector('#EnableTmdbSearch').checked = config.EnableTmdbSearch;
|
document.querySelector('#EnableTmdbSearch').checked = config.EnableTmdbSearch;
|
||||||
document.querySelector('#EnableTmdbBackdrop').checked = config.EnableTmdbBackdrop;
|
document.querySelector('#EnableTmdbBackdrop').checked = config.EnableTmdbBackdrop;
|
||||||
|
document.querySelector('#EnableTmdbCollection').checked = config.EnableTmdbCollection;
|
||||||
document.querySelector('#TmdbApiKey').value = config.TmdbApiKey;
|
document.querySelector('#TmdbApiKey').value = config.TmdbApiKey;
|
||||||
document.querySelector('#TmdbHost').value = config.TmdbHost;
|
document.querySelector('#TmdbHost').value = config.TmdbHost;
|
||||||
|
|
||||||
|
@ -141,6 +150,7 @@
|
||||||
config.EnableTmdb = document.querySelector('#EnableTmdb').checked;
|
config.EnableTmdb = document.querySelector('#EnableTmdb').checked;
|
||||||
config.EnableTmdbSearch = document.querySelector('#EnableTmdbSearch').checked;
|
config.EnableTmdbSearch = document.querySelector('#EnableTmdbSearch').checked;
|
||||||
config.EnableTmdbBackdrop = document.querySelector('#EnableTmdbBackdrop').checked;
|
config.EnableTmdbBackdrop = document.querySelector('#EnableTmdbBackdrop').checked;
|
||||||
|
config.EnableTmdbCollection = document.querySelector('#EnableTmdbCollection').checked;
|
||||||
config.TmdbApiKey = document.querySelector('#TmdbApiKey').value;
|
config.TmdbApiKey = document.querySelector('#TmdbApiKey').value;
|
||||||
config.TmdbHost = document.querySelector('#TmdbHost').value;
|
config.TmdbHost = document.querySelector('#TmdbHost').value;
|
||||||
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
|
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MetaShark;
|
namespace Jellyfin.Plugin.MetaShark;
|
||||||
|
|
||||||
|
@ -24,14 +25,19 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ProviderId = "MetaSharkID";
|
public const string ProviderId = "MetaSharkID";
|
||||||
|
|
||||||
|
protected readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
/// Initializes a new instance of the <see cref="Plugin"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
|
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
|
||||||
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
|
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
|
||||||
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
|
/// /// <param name="httpContextAccessor">Instance of the <see cref="IHttpContextAccessor"/> interface.</param>
|
||||||
|
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer, IHttpContextAccessor httpContextAccessor)
|
||||||
: base(applicationPaths, xmlSerializer)
|
: base(applicationPaths, xmlSerializer)
|
||||||
{
|
{
|
||||||
|
this._httpContextAccessor = httpContextAccessor;
|
||||||
|
|
||||||
Plugin.Instance = this;
|
Plugin.Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,4 +64,29 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// jellyfin web服务域名
|
||||||
|
/// 注意:经过nginx代理后,会拿不到真正的域名,需要用户配置http服务传入真正host
|
||||||
|
/// </summary>
|
||||||
|
public string BaseUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_httpContextAccessor.HttpContext != null)
|
||||||
|
{
|
||||||
|
// // 使用web浏览器访问直接使用相对链接???可解决用户配置了http反代
|
||||||
|
// var userAgent = _httpContextAccessor.HttpContext.Request.Headers.UserAgent.ToString();
|
||||||
|
// var fromWeb = userAgent.Contains("Chrome") || userAgent.Contains("Safari");
|
||||||
|
// if (fromWeb) return string.Empty;
|
||||||
|
|
||||||
|
return _httpContextAccessor.HttpContext.Request.Scheme + System.Uri.SchemeDelimiter + _httpContextAccessor.HttpContext.Request.Host;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,18 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
if (!string.IsNullOrEmpty(tmdbId))
|
if (!string.IsNullOrEmpty(tmdbId))
|
||||||
{
|
{
|
||||||
movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);
|
movie.SetProviderId(MetadataProvider.Tmdb, tmdbId);
|
||||||
|
|
||||||
|
// 获取电影系列信息
|
||||||
|
if (this.config.EnableTmdbCollection)
|
||||||
|
{
|
||||||
|
var movieResult = await _tmdbApi
|
||||||
|
.GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
if (movieResult != null && movieResult.BelongsToCollection != null)
|
||||||
|
{
|
||||||
|
movie.CollectionName = movieResult.BelongsToCollection.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +202,12 @@ namespace Jellyfin.Plugin.MetaShark.Providers
|
||||||
movie.SetProviderId(MetadataProvider.Imdb, movieResult.ImdbId);
|
movie.SetProviderId(MetadataProvider.Imdb, movieResult.ImdbId);
|
||||||
movie.SetProviderId(Plugin.ProviderId, MetaSource.Tmdb);
|
movie.SetProviderId(Plugin.ProviderId, MetaSource.Tmdb);
|
||||||
|
|
||||||
|
// 获取电影系列信息
|
||||||
|
if (this.config.EnableTmdbCollection && movieResult.BelongsToCollection != null)
|
||||||
|
{
|
||||||
|
movie.CollectionName = movieResult.BelongsToCollection.Name;
|
||||||
|
}
|
||||||
|
|
||||||
movie.CommunityRating = (float)System.Math.Round(movieResult.VoteAverage, 2);
|
movie.CommunityRating = (float)System.Math.Round(movieResult.VoteAverage, 2);
|
||||||
movie.PremiereDate = movieResult.ReleaseDate;
|
movie.PremiereDate = movieResult.ReleaseDate;
|
||||||
movie.ProductionYear = movieResult.ReleaseDate?.Year;
|
movie.ProductionYear = movieResult.ReleaseDate?.Year;
|
||||||
|
|
Loading…
Reference in New Issue