feat: add tmdb proxy config. close #45
This commit is contained in:
parent
45e4a40c28
commit
ca06af4b53
|
@ -29,7 +29,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
AllowAutoRedirect = false
|
AllowAutoRedirect = false
|
||||||
};
|
};
|
||||||
httpClient = new HttpClient(handler);
|
httpClient = new HttpClient(handler);
|
||||||
httpClient.Timeout = TimeSpan.FromSeconds(5);
|
httpClient.Timeout = TimeSpan.FromSeconds(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Jellyfin.Plugin.MetaShark.Api
|
||||||
var config = Plugin.Instance?.Configuration;
|
var config = Plugin.Instance?.Configuration;
|
||||||
var apiKey = string.IsNullOrEmpty(config?.TmdbApiKey) ? DEFAULT_API_KEY : config.TmdbApiKey;
|
var apiKey = string.IsNullOrEmpty(config?.TmdbApiKey) ? DEFAULT_API_KEY : config.TmdbApiKey;
|
||||||
var host = string.IsNullOrEmpty(config?.TmdbHost) ? DEFAULT_API_HOST : config.TmdbHost;
|
var host = string.IsNullOrEmpty(config?.TmdbHost) ? DEFAULT_API_HOST : config.TmdbHost;
|
||||||
_tmDbClient = new TMDbClient(apiKey, true, host);
|
_tmDbClient = new TMDbClient(apiKey, true, host, null, config.GetTmdbWebProxy());
|
||||||
_tmDbClient.Timeout = TimeSpan.FromSeconds(10);
|
_tmDbClient.Timeout = TimeSpan.FromSeconds(10);
|
||||||
// Not really interested in NotFoundException
|
// Not really interested in NotFoundException
|
||||||
_tmDbClient.ThrowApiExceptions = false;
|
_tmDbClient.ThrowApiExceptions = false;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using MediaBrowser.Model.Plugins;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using MediaBrowser.Model.Plugins;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.MetaShark.Configuration;
|
namespace Jellyfin.Plugin.MetaShark.Configuration;
|
||||||
|
|
||||||
|
@ -12,6 +13,9 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||||
public const int MAX_CAST_MEMBERS = 15;
|
public const int MAX_CAST_MEMBERS = 15;
|
||||||
public const int MAX_SEARCH_RESULT = 5;
|
public const int MAX_SEARCH_RESULT = 5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 插件版本
|
||||||
|
/// </summary>
|
||||||
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
|
public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
|
||||||
|
|
||||||
public string DoubanCookies { get; set; } = string.Empty;
|
public string DoubanCookies { get; set; } = string.Empty;
|
||||||
|
@ -28,10 +32,19 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DoubanImageProxyBaseUrl { get; set; } = string.Empty;
|
public string DoubanImageProxyBaseUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用获取tmdb元数据
|
||||||
|
/// </summary>
|
||||||
public bool EnableTmdb { get; set; } = true;
|
public bool EnableTmdb { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用显示tmdb搜索结果
|
||||||
|
/// </summary>
|
||||||
public bool EnableTmdbSearch { get; set; } = false;
|
public bool EnableTmdbSearch { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用tmdb获取背景图
|
||||||
|
/// </summary>
|
||||||
public bool EnableTmdbBackdrop { get; set; } = true;
|
public bool EnableTmdbBackdrop { get; set; } = true;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否获取电影系列信息
|
/// 是否获取电影系列信息
|
||||||
|
@ -41,9 +54,36 @@ public class PluginConfiguration : BasePluginConfiguration
|
||||||
/// 是否获取tmdb分级信息
|
/// 是否获取tmdb分级信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableTmdbOfficialRating { get; set; } = true;
|
public bool EnableTmdbOfficialRating { get; set; } = true;
|
||||||
|
/// <summary>
|
||||||
|
/// tmdb api key
|
||||||
|
/// </summary>
|
||||||
public string TmdbApiKey { get; set; } = string.Empty;
|
public string TmdbApiKey { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// tmdb api host
|
||||||
|
/// </summary>
|
||||||
public string TmdbHost { get; set; } = string.Empty;
|
public string TmdbHost { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 代理服务器类型,0-禁用,1-http,2-https,3-socket5
|
||||||
|
/// </summary>
|
||||||
|
public string TmdbProxyType { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 代理服务器host
|
||||||
|
/// </summary>
|
||||||
|
public string TmdbProxyPort { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// 代理服务器端口
|
||||||
|
/// </summary>
|
||||||
|
public string TmdbProxyHost { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
public IWebProxy GetTmdbWebProxy()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(TmdbProxyType))
|
||||||
|
{
|
||||||
|
return new WebProxy($"{TmdbProxyType}://{TmdbProxyHost}:{TmdbProxyPort}", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,29 @@
|
||||||
<div class="fieldDescription">
|
<div class="fieldDescription">
|
||||||
填写Api域名,可选api.tmdb.org/api.themoviedb.org,默认api.tmdb.org.(需重启才能生效)</div>
|
填写Api域名,可选api.tmdb.org/api.themoviedb.org,默认api.tmdb.org.(需重启才能生效)</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="selectContainer">
|
||||||
|
<label class="selectLabel" for="TmdbProxyType">Api代理服务器:</label>
|
||||||
|
<select is="emby-select" id="TmdbProxyType" name="TmdbProxyType"
|
||||||
|
class="TmdbProxyType emby-select-withcolor emby-select">
|
||||||
|
<option value="">禁用</option>
|
||||||
|
<option value="http">HTTP</option>
|
||||||
|
<option value="https">HTTPS</option>
|
||||||
|
<option value="socks5">Socks5</option>
|
||||||
|
</select>
|
||||||
|
<div class="fieldDescription">
|
||||||
|
选择Api代理服务器方式.(需重启才能生效)</div>
|
||||||
|
</div>
|
||||||
|
<div class="inputContainer tmdb-proxy-wapper">
|
||||||
|
<label class="inputLabel inputLabel-float inputLabelUnfocused"
|
||||||
|
for="TmdbProxyHost">Api代理服务器Host:</label>
|
||||||
|
<input is="emby-input" id="TmdbProxyHost" name="TmdbProxyHost" class="emby-input">
|
||||||
|
</div>
|
||||||
|
<div class="inputContainer tmdb-proxy-wapper">
|
||||||
|
<label class="inputLabel inputLabel-float inputLabelUnfocused"
|
||||||
|
for="TmdbProxyPort">Api代理服务器端口:</label>
|
||||||
|
<input is="emby-input" type="number" id="TmdbProxyPort" name="TmdbProxyPort"
|
||||||
|
pattern="[0-9]*" min="1" max="65535" class="emby-input">
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
|
||||||
<span>Save</span>
|
<span>Save</span>
|
||||||
|
@ -134,6 +157,7 @@
|
||||||
|
|
||||||
document.querySelector('#TemplateConfigPage')
|
document.querySelector('#TemplateConfigPage')
|
||||||
.addEventListener('pageshow', function () {
|
.addEventListener('pageshow', function () {
|
||||||
|
console.log('metashark pageshow');
|
||||||
Dashboard.showLoadingMsg();
|
Dashboard.showLoadingMsg();
|
||||||
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
|
ApiClient.getPluginConfiguration(TemplateConfig.pluginUniqueId).then(function (config) {
|
||||||
$('#current_version').text("v" + config.Version);
|
$('#current_version').text("v" + config.Version);
|
||||||
|
@ -151,6 +175,11 @@
|
||||||
document.querySelector('#TmdbApiKey').value = config.TmdbApiKey;
|
document.querySelector('#TmdbApiKey').value = config.TmdbApiKey;
|
||||||
document.querySelector('#TmdbHost').value = config.TmdbHost;
|
document.querySelector('#TmdbHost').value = config.TmdbHost;
|
||||||
|
|
||||||
|
document.querySelector('#TmdbProxyType').value = config.TmdbProxyType;
|
||||||
|
document.querySelector('#TmdbProxyHost').value = config.TmdbProxyHost;
|
||||||
|
document.querySelector('#TmdbProxyPort').value = config.TmdbProxyPort;
|
||||||
|
|
||||||
|
changeProxyDisplay();
|
||||||
checkDoubanLogin();
|
checkDoubanLogin();
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.hideLoadingMsg();
|
||||||
|
@ -173,6 +202,9 @@
|
||||||
config.EnableTmdbOfficialRating = document.querySelector('#EnableTmdbOfficialRating').checked;
|
config.EnableTmdbOfficialRating = document.querySelector('#EnableTmdbOfficialRating').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;
|
||||||
|
config.TmdbProxyType = document.querySelector('#TmdbProxyType').value;
|
||||||
|
config.TmdbProxyHost = document.querySelector('#TmdbProxyHost').value;
|
||||||
|
config.TmdbProxyPort = document.querySelector('#TmdbProxyPort').value;
|
||||||
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
|
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
|
||||||
Dashboard.processPluginConfigurationUpdateResult(result);
|
Dashboard.processPluginConfigurationUpdateResult(result);
|
||||||
|
|
||||||
|
@ -184,6 +216,20 @@
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.querySelector('#TmdbProxyType')
|
||||||
|
.addEventListener('change', function (e) {
|
||||||
|
changeProxyDisplay();
|
||||||
|
});
|
||||||
|
|
||||||
|
function changeProxyDisplay() {
|
||||||
|
let proxyType = document.querySelector('#TmdbProxyType').value;
|
||||||
|
if (proxyType) {
|
||||||
|
$('.tmdb-proxy-wapper').show()
|
||||||
|
} else {
|
||||||
|
$('.tmdb-proxy-wapper').hide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkDoubanLogin() {
|
function checkDoubanLogin() {
|
||||||
let cookie = document.querySelector('#DoubanCookies').value
|
let cookie = document.querySelector('#DoubanCookies').value
|
||||||
if (!cookie || !$.trim(cookie)) {
|
if (!cookie || !$.trim(cookie)) {
|
||||||
|
|
Loading…
Reference in New Issue