update musicbrainz providers
This commit is contained in:
parent
345ad10665
commit
21df06bba9
|
@ -7,6 +7,7 @@ using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Providers;
|
using MediaBrowser.Model.Providers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
@ -266,7 +267,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -287,6 +288,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -299,7 +304,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -326,6 +331,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -421,7 +430,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -441,6 +450,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +466,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -470,6 +483,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -517,7 +534,9 @@ namespace MediaBrowser.Providers.Music
|
||||||
|
|
||||||
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
|
using (var stream = await _httpClient.Get(options).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
list = _json.DeserializeFromStream<List<MbzUrl>>(stream);
|
var results = _json.DeserializeFromStream<List<MbzUrl>>(stream);
|
||||||
|
|
||||||
|
list = results;
|
||||||
}
|
}
|
||||||
_lastMbzUrlQueryTicks = DateTime.UtcNow.Ticks;
|
_lastMbzUrlQueryTicks = DateTime.UtcNow.Ticks;
|
||||||
}
|
}
|
||||||
|
@ -550,11 +569,13 @@ namespace MediaBrowser.Providers.Music
|
||||||
internal async Task<Stream> GetMusicBrainzResponse(string url, bool isSearch, CancellationToken cancellationToken)
|
internal async Task<Stream> GetMusicBrainzResponse(string url, bool isSearch, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var urlInfo = await GetMbzUrl().ConfigureAwait(false);
|
var urlInfo = await GetMbzUrl().ConfigureAwait(false);
|
||||||
|
var throttleMs = urlInfo.throttleMs;
|
||||||
|
|
||||||
if (urlInfo.throttleMs > 0)
|
if (throttleMs > 0)
|
||||||
{
|
{
|
||||||
// MusicBrainz is extremely adamant about limiting to one request per second
|
// MusicBrainz is extremely adamant about limiting to one request per second
|
||||||
await Task.Delay(urlInfo.throttleMs, cancellationToken).ConfigureAwait(false);
|
_logger.Debug("Throttling MusicBrainz by {0}ms", throttleMs.ToString(CultureInfo.InvariantCulture));
|
||||||
|
await Task.Delay(throttleMs, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
url = urlInfo.url.TrimEnd('/') + url;
|
url = urlInfo.url.TrimEnd('/') + url;
|
||||||
|
@ -564,7 +585,8 @@ namespace MediaBrowser.Providers.Music
|
||||||
Url = url,
|
Url = url,
|
||||||
CancellationToken = cancellationToken,
|
CancellationToken = cancellationToken,
|
||||||
UserAgent = _appHost.Name + "/" + _appHost.ApplicationVersion,
|
UserAgent = _appHost.Name + "/" + _appHost.ApplicationVersion,
|
||||||
ResourcePool = _musicBrainzResourcePool
|
ResourcePool = _musicBrainzResourcePool,
|
||||||
|
BufferContent = throttleMs > 0
|
||||||
};
|
};
|
||||||
|
|
||||||
return await _httpClient.Get(options).ConfigureAwait(false);
|
return await _httpClient.Get(options).ConfigureAwait(false);
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -108,6 +108,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new List<RemoteSearchResult>();
|
return new List<RemoteSearchResult>();
|
||||||
|
@ -122,7 +126,7 @@ namespace MediaBrowser.Providers.Music
|
||||||
reader.MoveToContent();
|
reader.MoveToContent();
|
||||||
|
|
||||||
// Loop through each element
|
// Loop through each element
|
||||||
while (reader.Read())
|
while (!reader.EOF)
|
||||||
{
|
{
|
||||||
if (reader.NodeType == XmlNodeType.Element)
|
if (reader.NodeType == XmlNodeType.Element)
|
||||||
{
|
{
|
||||||
|
@ -149,6 +153,10 @@ namespace MediaBrowser.Providers.Music
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reader.Read();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user