From 0413a8b6d29f0718e7ac9c97b8658c5aedf66e4e Mon Sep 17 00:00:00 2001 From: dkanada Date: Fri, 21 Nov 2025 09:58:34 +0900 Subject: [PATCH] include external IDs and URLs for book providers --- .../Books/Isbn/ISBNExternalId.cs | 23 +++++++++++++++ .../Books/Isbn/ISBNExternalUrlProvider.cs | 25 +++++++++++++++++ .../Plugins/ComicVine/ComicVineExternalId.cs | 23 +++++++++++++++ .../ComicVine/ComicVineExternalUrlProvider.cs | 28 +++++++++++++++++++ .../ComicVine/ComicVinePersonExternalId.cs | 23 +++++++++++++++ .../GoogleBooks/GoogleBooksExternalId.cs | 23 +++++++++++++++ .../GoogleBooksExternalUrlProvider.cs | 25 +++++++++++++++++ 7 files changed, 170 insertions(+) create mode 100644 MediaBrowser.Providers/Books/Isbn/ISBNExternalId.cs create mode 100644 MediaBrowser.Providers/Books/Isbn/ISBNExternalUrlProvider.cs create mode 100644 MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalId.cs create mode 100644 MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalUrlProvider.cs create mode 100644 MediaBrowser.Providers/Plugins/ComicVine/ComicVinePersonExternalId.cs create mode 100644 MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalId.cs create mode 100644 MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalUrlProvider.cs diff --git a/MediaBrowser.Providers/Books/Isbn/ISBNExternalId.cs b/MediaBrowser.Providers/Books/Isbn/ISBNExternalId.cs new file mode 100644 index 0000000000..a86275d5ae --- /dev/null +++ b/MediaBrowser.Providers/Books/Isbn/ISBNExternalId.cs @@ -0,0 +1,23 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; + +namespace MediaBrowser.Providers.Books.Isbn +{ + /// + public class IsbnExternalId : IExternalId + { + /// + public string ProviderName => "ISBN"; + + /// + public string Key => "ISBN"; + + /// + public ExternalIdMediaType? Type => null; + + /// + public bool Supports(IHasProviderIds item) => item is Book; + } +} diff --git a/MediaBrowser.Providers/Books/Isbn/ISBNExternalUrlProvider.cs b/MediaBrowser.Providers/Books/Isbn/ISBNExternalUrlProvider.cs new file mode 100644 index 0000000000..9d7b1ff208 --- /dev/null +++ b/MediaBrowser.Providers/Books/Isbn/ISBNExternalUrlProvider.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Books.Isbn; + +/// +public class IsbnExternalUrlProvider : IExternalUrlProvider +{ + /// + public string Name => "ISBN"; + + /// + public IEnumerable GetExternalUrls(BaseItem item) + { + if (item.TryGetProviderId("ISBN", out var externalId)) + { + if (item is Book) + { + yield return $"https://search.worldcat.org/search?q=bn:{externalId}"; + } + } + } +} diff --git a/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalId.cs b/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalId.cs new file mode 100644 index 0000000000..8cbd1f89a7 --- /dev/null +++ b/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalId.cs @@ -0,0 +1,23 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; + +namespace MediaBrowser.Providers.Plugins.ComicVine +{ + /// + public class ComicVineExternalId : IExternalId + { + /// + public string ProviderName => "Comic Vine"; + + /// + public string Key => "ComicVine"; + + /// + public ExternalIdMediaType? Type => null; + + /// + public bool Supports(IHasProviderIds item) => item is Book; + } +} diff --git a/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalUrlProvider.cs b/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalUrlProvider.cs new file mode 100644 index 0000000000..9122399179 --- /dev/null +++ b/MediaBrowser.Providers/Plugins/ComicVine/ComicVineExternalUrlProvider.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Plugins.ComicVine; + +/// +public class ComicVineExternalUrlProvider : IExternalUrlProvider +{ + /// + public string Name => "Comic Vine"; + + /// + public IEnumerable GetExternalUrls(BaseItem item) + { + if (item.TryGetProviderId("ComicVine", out var externalId)) + { + switch (item) + { + case Person: + case Book: + yield return $"https://comicvine.gamespot.com/{externalId}"; + break; + } + } + } +} diff --git a/MediaBrowser.Providers/Plugins/ComicVine/ComicVinePersonExternalId.cs b/MediaBrowser.Providers/Plugins/ComicVine/ComicVinePersonExternalId.cs new file mode 100644 index 0000000000..26b8e11380 --- /dev/null +++ b/MediaBrowser.Providers/Plugins/ComicVine/ComicVinePersonExternalId.cs @@ -0,0 +1,23 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; + +namespace MediaBrowser.Providers.Plugins.ComicVine +{ + /// + public class ComicVinePersonExternalId : IExternalId + { + /// + public string ProviderName => "Comic Vine"; + + /// + public string Key => "ComicVine"; + + /// + public ExternalIdMediaType? Type => ExternalIdMediaType.Person; + + /// + public bool Supports(IHasProviderIds item) => item is Person; + } +} diff --git a/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalId.cs b/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalId.cs new file mode 100644 index 0000000000..02d3b36974 --- /dev/null +++ b/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalId.cs @@ -0,0 +1,23 @@ +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Providers; + +namespace MediaBrowser.Providers.Plugins.GoogleBooks +{ + /// + public class GoogleBooksExternalId : IExternalId + { + /// + public string ProviderName => "Google Books"; + + /// + public string Key => "GoogleBooks"; + + /// + public ExternalIdMediaType? Type => null; + + /// + public bool Supports(IHasProviderIds item) => item is Book; + } +} diff --git a/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalUrlProvider.cs b/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalUrlProvider.cs new file mode 100644 index 0000000000..95047ee83e --- /dev/null +++ b/MediaBrowser.Providers/Plugins/GoogleBooks/GoogleBooksExternalUrlProvider.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; + +namespace MediaBrowser.Providers.Plugins.GoogleBooks; + +/// +public class GoogleBooksExternalUrlProvider : IExternalUrlProvider +{ + /// + public string Name => "Google Books"; + + /// + public IEnumerable GetExternalUrls(BaseItem item) + { + if (item.TryGetProviderId("GoogleBooks", out var externalId)) + { + if (item is Book) + { + yield return $"https://books.google.com/books?id={externalId}"; + } + } + } +}