add plugin configurations for tvdb and omdb

pull/3208/head
dkanada 4 years ago
parent 777c9c7bc9
commit 24f7f84828

@ -0,0 +1,9 @@
using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class PluginConfiguration : BasePluginConfiguration
{
public bool CastAndCrew { get; set; }
}
}

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<title>OMDb</title>
</head>
<body>
<div data-role="page" class="page type-interior pluginConfigurationPage configPage" data-require="emby-input,emby-button,emby-checkbox">
<div data-role="content">
<div class="content-primary">
<form class="configForm">
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="castAndCrew" />
<span>Collect information about the cast and other crew members from OMDb.</span>
</label>
<br />
<div>
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
</div>
</form>
</div>
</div>
<script type="text/javascript">
var PluginConfig = {
pluginId: "a628c0da-fac5-4c7e-9d1a-7134223f14c8"
};
$('.configPage').on('pageshow', function () {
Dashboard.showLoadingMsg();
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
$('#castAndCrew').checked = config.CastAndCrew;
Dashboard.hideLoadingMsg();
});
});
$('.configForm').on('submit', function (e) {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
config.CastAndCrew = $('#castAndCrew', form).checked;
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});
return false;
});
</script>
</div>
</body>
</html>

@ -92,6 +92,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
return item is Movie || item is Trailer || item is Episode; return item is Movie || item is Trailer || item is Episode;
} }
// After other internet providers, because they're better // After other internet providers, because they're better
// But before fallback providers like screengrab // But before fallback providers like screengrab
public int Order => 90; public int Order => 90;

@ -103,6 +103,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
urlQuery += "&t=" + WebUtility.UrlEncode(name); urlQuery += "&t=" + WebUtility.UrlEncode(name);
} }
urlQuery += "&type=" + type; urlQuery += "&type=" + type;
} }
else else
@ -117,6 +118,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
urlQuery += string.Format(CultureInfo.InvariantCulture, "&Episode={0}", searchInfo.IndexNumber); urlQuery += string.Format(CultureInfo.InvariantCulture, "&Episode={0}", searchInfo.IndexNumber);
} }
if (searchInfo.ParentIndexNumber.HasValue) if (searchInfo.ParentIndexNumber.HasValue)
{ {
urlQuery += string.Format(CultureInfo.InvariantCulture, "&Season={0}", searchInfo.ParentIndexNumber); urlQuery += string.Format(CultureInfo.InvariantCulture, "&Season={0}", searchInfo.ParentIndexNumber);

@ -87,10 +87,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
item.CommunityRating = imdbRating; item.CommunityRating = imdbRating;
} }
//if (!string.IsNullOrEmpty(result.Website)) if (!string.IsNullOrEmpty(result.Website))
//{ {
// item.HomePageUrl = result.Website; item.HomePageUrl = result.Website;
//} }
if (!string.IsNullOrWhiteSpace(result.imdbID)) if (!string.IsNullOrWhiteSpace(result.imdbID))
{ {
@ -121,7 +121,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
if (!string.IsNullOrWhiteSpace(episodeImdbId)) if (!string.IsNullOrWhiteSpace(episodeImdbId))
{ {
foreach (var episode in (seasonResult.Episodes ?? new RootObject[] { })) foreach (var episode in seasonResult.Episodes)
{ {
if (string.Equals(episodeImdbId, episode.imdbID, StringComparison.OrdinalIgnoreCase)) if (string.Equals(episodeImdbId, episode.imdbID, StringComparison.OrdinalIgnoreCase))
{ {
@ -134,7 +134,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
// finally, search by numbers // finally, search by numbers
if (result == null) if (result == null)
{ {
foreach (var episode in (seasonResult.Episodes ?? new RootObject[] { })) foreach (var episode in seasonResult.Episodes)
{ {
if (episode.Episode == episodeNumber) if (episode.Episode == episodeNumber)
{ {
@ -188,10 +188,10 @@ namespace MediaBrowser.Providers.Plugins.Omdb
item.CommunityRating = imdbRating; item.CommunityRating = imdbRating;
} }
//if (!string.IsNullOrEmpty(result.Website)) if (!string.IsNullOrEmpty(result.Website))
//{ {
// item.HomePageUrl = result.Website; item.HomePageUrl = result.Website;
//} }
if (!string.IsNullOrWhiteSpace(result.imdbID)) if (!string.IsNullOrWhiteSpace(result.imdbID))
{ {
@ -263,6 +263,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
{ {
return url; return url;
} }
return url + "&" + query; return url + "&" + query;
} }
@ -386,7 +387,7 @@ namespace MediaBrowser.Providers.Plugins.Omdb
var isConfiguredForEnglish = IsConfiguredForEnglish(item) || _configurationManager.Configuration.EnableNewOmdbSupport; var isConfiguredForEnglish = IsConfiguredForEnglish(item) || _configurationManager.Configuration.EnableNewOmdbSupport;
// Grab series genres because imdb data is better than tvdb. Leave movies alone // Grab series genres because IMDb data is better than TVDB. Leave movies alone
// But only do it if english is the preferred language because this data will not be localized // But only do it if english is the preferred language because this data will not be localized
if (isConfiguredForEnglish && !string.IsNullOrWhiteSpace(result.Genre)) if (isConfiguredForEnglish && !string.IsNullOrWhiteSpace(result.Genre))
{ {
@ -407,45 +408,50 @@ namespace MediaBrowser.Providers.Plugins.Omdb
item.Overview = result.Plot; item.Overview = result.Plot;
} }
//if (!string.IsNullOrWhiteSpace(result.Director)) if (!Plugin.Instance.Configuration.CastAndCrew)
//{ {
// var person = new PersonInfo return;
// { }
// Name = result.Director.Trim(),
// Type = PersonType.Director if (!string.IsNullOrWhiteSpace(result.Director))
// }; {
var person = new PersonInfo
// itemResult.AddPerson(person); {
//} Name = result.Director.Trim(),
Type = PersonType.Director
//if (!string.IsNullOrWhiteSpace(result.Writer)) };
//{
// var person = new PersonInfo itemResult.AddPerson(person);
// { }
// Name = result.Director.Trim(),
// Type = PersonType.Writer if (!string.IsNullOrWhiteSpace(result.Writer))
// }; {
var person = new PersonInfo
// itemResult.AddPerson(person); {
//} Name = result.Director.Trim(),
Type = PersonType.Writer
//if (!string.IsNullOrWhiteSpace(result.Actors)) };
//{
// var actorList = result.Actors.Split(','); itemResult.AddPerson(person);
// foreach (var actor in actorList) }
// {
// if (!string.IsNullOrWhiteSpace(actor)) if (!string.IsNullOrWhiteSpace(result.Actors))
// { {
// var person = new PersonInfo var actorList = result.Actors.Split(',');
// { foreach (var actor in actorList)
// Name = actor.Trim(), {
// Type = PersonType.Actor if (!string.IsNullOrWhiteSpace(actor))
// }; {
var person = new PersonInfo
// itemResult.AddPerson(person); {
// } Name = actor.Trim(),
// } Type = PersonType.Actor
//} };
itemResult.AddPerson(person);
}
}
}
} }
private bool IsConfiguredForEnglish(BaseItem item) private bool IsConfiguredForEnglish(BaseItem item)
@ -459,40 +465,70 @@ namespace MediaBrowser.Providers.Plugins.Omdb
internal class SeasonRootObject internal class SeasonRootObject
{ {
public string Title { get; set; } public string Title { get; set; }
public string seriesID { get; set; } public string seriesID { get; set; }
public int Season { get; set; } public int Season { get; set; }
public int? totalSeasons { get; set; } public int? totalSeasons { get; set; }
public RootObject[] Episodes { get; set; } public RootObject[] Episodes { get; set; }
public string Response { get; set; } public string Response { get; set; }
} }
internal class RootObject internal class RootObject
{ {
public string Title { get; set; } public string Title { get; set; }
public string Year { get; set; } public string Year { get; set; }
public string Rated { get; set; } public string Rated { get; set; }
public string Released { get; set; } public string Released { get; set; }
public string Runtime { get; set; } public string Runtime { get; set; }
public string Genre { get; set; } public string Genre { get; set; }
public string Director { get; set; } public string Director { get; set; }
public string Writer { get; set; } public string Writer { get; set; }
public string Actors { get; set; } public string Actors { get; set; }
public string Plot { get; set; } public string Plot { get; set; }
public string Language { get; set; } public string Language { get; set; }
public string Country { get; set; } public string Country { get; set; }
public string Awards { get; set; } public string Awards { get; set; }
public string Poster { get; set; } public string Poster { get; set; }
public List<OmdbRating> Ratings { get; set; } public List<OmdbRating> Ratings { get; set; }
public string Metascore { get; set; } public string Metascore { get; set; }
public string imdbRating { get; set; } public string imdbRating { get; set; }
public string imdbVotes { get; set; } public string imdbVotes { get; set; }
public string imdbID { get; set; } public string imdbID { get; set; }
public string Type { get; set; } public string Type { get; set; }
public string DVD { get; set; } public string DVD { get; set; }
public string BoxOffice { get; set; } public string BoxOffice { get; set; }
public string Production { get; set; } public string Production { get; set; }
public string Website { get; set; } public string Website { get; set; }
public string Response { get; set; } public string Response { get; set; }
public int Episode { get; set; } public int Episode { get; set; }
public float? GetRottenTomatoScore() public float? GetRottenTomatoScore()
@ -509,12 +545,15 @@ namespace MediaBrowser.Providers.Plugins.Omdb
} }
} }
} }
return null; return null;
} }
} }
public class OmdbRating public class OmdbRating
{ {
public string Source { get; set; } public string Source { get; set; }
public string Value { get; set; } public string Value { get; set; }
} }
} }

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Plugins.Omdb
{
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{
public static Plugin Instance { get; private set; }
public override Guid Id => new Guid("a628c0da-fac5-4c7e-9d1a-7134223f14c8");
public override string Name => "OMDb";
public override string Description => "Get metadata for movies and other video content from OMDb.";
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
public IEnumerable<PluginPageInfo> GetPages()
{
yield return new PluginPageInfo
{
Name = Name,
EmbeddedResourcePath = GetType().Namespace + ".Configuration.config.html"
};
}
}
}

@ -0,0 +1,8 @@
using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class PluginConfiguration : BasePluginConfiguration
{
}
}

@ -0,0 +1,24 @@
using System;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Providers.Plugins.TheTvdb
{
public class Plugin : BasePlugin<PluginConfiguration>
{
public static Plugin Instance { get; private set; }
public override Guid Id => new Guid("a677c0da-fac5-4cde-941a-7134223f14c8");
public override string Name => "TheTVDB";
public override string Description => "Get metadata for movies and other video content from TheTVDB.";
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer)
{
Instance = this;
}
}
}

@ -120,6 +120,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
var cacheKey = GenerateKey("series", zap2ItId, language); var cacheKey = GenerateKey("series", zap2ItId, language);
return TryGetValue(cacheKey, language, () => TvDbClient.Search.SearchSeriesByZap2ItIdAsync(zap2ItId, cancellationToken)); return TryGetValue(cacheKey, language, () => TvDbClient.Search.SearchSeriesByZap2ItIdAsync(zap2ItId, cancellationToken));
} }
public Task<TvDbResponse<Actor[]>> GetActorsAsync( public Task<TvDbResponse<Actor[]>> GetActorsAsync(
int tvdbId, int tvdbId,
string language, string language,
@ -190,7 +191,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
episodeQuery.AbsoluteNumber = searchInfo.IndexNumber.Value; episodeQuery.AbsoluteNumber = searchInfo.IndexNumber.Value;
break; break;
default: default:
//aired order // aired order
episodeQuery.AiredEpisode = searchInfo.IndexNumber.Value; episodeQuery.AiredEpisode = searchInfo.IndexNumber.Value;
episodeQuery.AiredSeason = searchInfo.ParentIndexNumber.Value; episodeQuery.AiredSeason = searchInfo.ParentIndexNumber.Value;
break; break;

@ -14,9 +14,8 @@ using TvDbSharper.Dto;
namespace MediaBrowser.Providers.Plugins.TheTvdb namespace MediaBrowser.Providers.Plugins.TheTvdb
{ {
/// <summary> /// <summary>
/// Class RemoteEpisodeProvider /// Class RemoteEpisodeProvider.
/// </summary> /// </summary>
public class TvdbEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>, IHasOrder public class TvdbEpisodeProvider : IRemoteMetadataProvider<Episode, EpisodeInfo>, IHasOrder
{ {
@ -139,7 +138,6 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
Name = episode.EpisodeName, Name = episode.EpisodeName,
Overview = episode.Overview, Overview = episode.Overview,
CommunityRating = (float?)episode.SiteRating, CommunityRating = (float?)episode.SiteRating,
} }
}; };
result.ResetPeople(); result.ResetPeople();

@ -57,7 +57,6 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
{ {
EnableImages = false EnableImages = false
} }
}).Cast<Series>() }).Cast<Series>()
.Where(i => TvdbSeriesProvider.IsValidSeries(i.ProviderIds)) .Where(i => TvdbSeriesProvider.IsValidSeries(i.ProviderIds))
.ToList(); .ToList();

@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
if (series == null || !season.IndexNumber.HasValue || !TvdbSeriesProvider.IsValidSeries(series.ProviderIds)) if (series == null || !season.IndexNumber.HasValue || !TvdbSeriesProvider.IsValidSeries(series.ProviderIds))
{ {
return new RemoteImageInfo[] { }; return Array.Empty<RemoteImageInfo>();
} }
var tvdbId = Convert.ToInt32(series.GetProviderId(MetadataProviders.Tvdb)); var tvdbId = Convert.ToInt32(series.GetProviderId(MetadataProviders.Tvdb));
@ -113,8 +113,8 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
imageInfo.Type = TvdbUtils.GetImageTypeFromKeyType(image.KeyType); imageInfo.Type = TvdbUtils.GetImageTypeFromKeyType(image.KeyType);
list.Add(imageInfo); list.Add(imageInfo);
} }
var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i => return list.OrderByDescending(i =>
{ {
if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase)) if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase))

@ -79,6 +79,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
tvdbId); tvdbId);
} }
} }
return remoteImages; return remoteImages;
} }
@ -110,8 +111,8 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
imageInfo.Type = TvdbUtils.GetImageTypeFromKeyType(image.KeyType); imageInfo.Type = TvdbUtils.GetImageTypeFromKeyType(image.KeyType);
list.Add(imageInfo); list.Add(imageInfo);
} }
var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
var isLanguageEn = string.Equals(preferredLanguage, "en", StringComparison.OrdinalIgnoreCase);
return list.OrderByDescending(i => return list.OrderByDescending(i =>
{ {
if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase)) if (string.Equals(preferredLanguage, i.Language, StringComparison.OrdinalIgnoreCase))

@ -22,6 +22,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
public class TvdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder public class TvdbSeriesProvider : IRemoteMetadataProvider<Series, SeriesInfo>, IHasOrder
{ {
internal static TvdbSeriesProvider Current { get; private set; } internal static TvdbSeriesProvider Current { get; private set; }
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ILibraryManager _libraryManager; private readonly ILibraryManager _libraryManager;
@ -145,7 +146,6 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
private async Task<string> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken) private async Task<string> GetSeriesByRemoteId(string id, string idType, string language, CancellationToken cancellationToken)
{ {
TvDbResponse<SeriesSearchResult[]> result = null; TvDbResponse<SeriesSearchResult[]> result = null;
try try
@ -249,6 +249,7 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
ImageUrl = TvdbUtils.BannerUrl + seriesSearchResult.Banner ImageUrl = TvdbUtils.BannerUrl + seriesSearchResult.Banner
}; };
try try
{ {
var seriesSesult = var seriesSesult =
@ -274,11 +275,12 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
} }
/// <summary> /// <summary>
/// The remove /// The remove.
/// </summary> /// </summary>
const string remove = "\"'!`?"; const string remove = "\"'!`?";
/// <summary> /// <summary>
/// The spacers /// The spacers.
/// </summary> /// </summary>
const string spacers = "/,.:;\\(){}[]+-_=*"; // (there are two types of dashes, short and long) const string spacers = "/,.:;\\(){}[]+-_=*"; // (there are two types of dashes, short and long)
@ -315,8 +317,8 @@ namespace MediaBrowser.Providers.Plugins.TheTvdb
sb.Append(c); sb.Append(c);
} }
} }
sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " ");
sb.Replace(", the", string.Empty).Replace("the ", " ").Replace(" the ", " ");
return Regex.Replace(sb.ToString().Trim(), @"\s+", " "); return Regex.Replace(sb.ToString().Trim(), @"\s+", " ");
} }

Loading…
Cancel
Save