mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-08-11 09:13:54 -04:00
fixes #231 - Fanart Thumbs are not downloaded
This commit is contained in:
parent
eb45e67c81
commit
f996336137
@ -35,6 +35,8 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
/// <value>The HTTP client.</value>
|
/// <value>The HTTP client.</value>
|
||||||
protected IHttpClient HttpClient { get; private set; }
|
protected IHttpClient HttpClient { get; private set; }
|
||||||
|
|
||||||
|
internal static FanArtAlbumProvider Current { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="FanArtAlbumProvider"/> class.
|
/// Initializes a new instance of the <see cref="FanArtAlbumProvider"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -47,6 +49,8 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
{
|
{
|
||||||
_providerManager = providerManager;
|
_providerManager = providerManager;
|
||||||
HttpClient = httpClient;
|
HttpClient = httpClient;
|
||||||
|
|
||||||
|
Current = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -208,12 +212,12 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
private DateTime _lastMusicBrainzRequest = DateTime.MinValue;
|
private DateTime _lastMusicBrainzRequest = DateTime.MinValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the release group id.
|
/// Gets the music brainz response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="releaseEntryId">The release entry id.</param>
|
/// <param name="url">The URL.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.String}.</returns>
|
/// <returns>Task{XmlDocument}.</returns>
|
||||||
private async Task<string> GetReleaseGroupId(string releaseEntryId, CancellationToken cancellationToken)
|
internal async Task<XmlDocument> GetMusicBrainzResponse(string url, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _musicBrainzResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await _musicBrainzResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
@ -230,7 +234,17 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
|
|
||||||
_lastMusicBrainzRequest = DateTime.Now;
|
_lastMusicBrainzRequest = DateTime.Now;
|
||||||
|
|
||||||
return await GetReleaseGroupIdInternal(releaseEntryId, cancellationToken).ConfigureAwait(false);
|
var doc = new XmlDocument();
|
||||||
|
|
||||||
|
using (var xml = await HttpClient.Get(url, cancellationToken).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
using (var oReader = new StreamReader(xml, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
doc.Load(oReader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -244,19 +258,11 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
/// <param name="releaseEntryId">The release entry id.</param>
|
/// <param name="releaseEntryId">The release entry id.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{System.String}.</returns>
|
/// <returns>Task{System.String}.</returns>
|
||||||
private async Task<string> GetReleaseGroupIdInternal(string releaseEntryId, CancellationToken cancellationToken)
|
private async Task<string> GetReleaseGroupId(string releaseEntryId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var url = string.Format("http://www.musicbrainz.org/ws/2/release-group/?query=reid:{0}", releaseEntryId);
|
var url = string.Format("http://www.musicbrainz.org/ws/2/release-group/?query=reid:{0}", releaseEntryId);
|
||||||
|
|
||||||
var doc = new XmlDocument();
|
var doc = await GetMusicBrainzResponse(url, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
using (var xml = await HttpClient.Get(url, cancellationToken).ConfigureAwait(false))
|
|
||||||
{
|
|
||||||
using (var oReader = new StreamReader(xml, Encoding.UTF8))
|
|
||||||
{
|
|
||||||
doc.Load(oReader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var ns = new XmlNamespaceManager(doc.NameTable);
|
var ns = new XmlNamespaceManager(doc.NameTable);
|
||||||
ns.AddNamespace("mb", "http://musicbrainz.org/ns/mmd-2.0#");
|
ns.AddNamespace("mb", "http://musicbrainz.org/ns/mmd-2.0#");
|
||||||
|
@ -3,13 +3,11 @@ using MediaBrowser.Controller.Configuration;
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities.Audio;
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Net;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers.Music
|
namespace MediaBrowser.Controller.Providers.Music
|
||||||
{
|
{
|
||||||
@ -24,37 +22,22 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
LocalMetaFileName = LastfmHelper.LocalArtistMetaFileName;
|
LocalMetaFileName = LastfmHelper.LocalArtistMetaFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
|
protected override async Task<string> FindId(BaseItem item, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
//Execute the Artist search against our name and assume first one is the one we want
|
var url = string.Format("http://www.musicbrainz.org/ws/2/artist/?query=artistaccent:{0}", UrlEncode(item.Name));
|
||||||
var url = RootUrl + string.Format("method=artist.search&artist={0}&api_key={1}&format=json", UrlEncode(item.Name), ApiKey);
|
|
||||||
|
|
||||||
LastfmArtistSearchResults searchResult;
|
var doc = await FanArtAlbumProvider.Current.GetMusicBrainzResponse(url, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
var ns = new XmlNamespaceManager(doc.NameTable);
|
||||||
{
|
ns.AddNamespace("mb", "http://musicbrainz.org/ns/mmd-2.0#");
|
||||||
using (var json = await HttpClient.Get(url, LastfmResourcePool, cancellationToken).ConfigureAwait(false))
|
var node = doc.SelectSingleNode("//mb:artist-list/mb:artist/@id", ns);
|
||||||
{
|
|
||||||
searchResult = JsonSerializer.DeserializeFromStream<LastfmArtistSearchResults>(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (HttpException e)
|
|
||||||
{
|
|
||||||
if (e.StatusCode == HttpStatusCode.NotFound)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchResult != null && searchResult.results != null && searchResult.results.artistmatches != null && searchResult.results.artistmatches.artist.Count > 0)
|
return node != null ? node.Value : null;
|
||||||
{
|
|
||||||
var artist = searchResult.results.artistmatches.artist.FirstOrDefault(i => string.Equals(i.name, item.Name, System.StringComparison.OrdinalIgnoreCase));
|
|
||||||
|
|
||||||
return artist != null ? artist.mbid : searchResult.results.artistmatches.artist[0].mbid;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task FetchLastfmData(BaseItem item, string id, CancellationToken cancellationToken)
|
protected override async Task FetchLastfmData(BaseItem item, string id, CancellationToken cancellationToken)
|
||||||
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Providers.Music
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "04-25-2013";
|
return "4";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user