diff --git a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs b/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
index 403236b3d..86a974229 100644
--- a/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
+++ b/MediaBrowser.Common/Extensions/ResourceNotFoundException.cs
@@ -25,4 +25,25 @@ namespace MediaBrowser.Common.Extensions
}
}
+
+ public class RateLimitExceededException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public RateLimitExceededException()
+ {
+
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The message.
+ public RateLimitExceededException(string message)
+ : base(message)
+ {
+
+ }
+ }
}
diff --git a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs
index e26a6392c..3954897ca 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/OpenSubtitleDownloader.cs
@@ -136,7 +136,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
if ((DateTime.UtcNow - _lastRateLimitException).TotalHours < 1)
{
- throw new Exception("OpenSubtitles rate limit reached");
+ throw new RateLimitExceededException("OpenSubtitles rate limit reached");
}
var resultDownLoad = await OpenSubtitles.DownloadSubtitlesAsync(downloadsList, cancellationToken).ConfigureAwait(false);
@@ -144,7 +144,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
if ((resultDownLoad.Status ?? string.Empty).IndexOf("407", StringComparison.OrdinalIgnoreCase) != -1)
{
_lastRateLimitException = DateTime.UtcNow;
- throw new Exception("OpenSubtitles rate limit reached");
+ throw new RateLimitExceededException("OpenSubtitles rate limit reached");
}
if (!(resultDownLoad is MethodResponseSubtitleDownload))
diff --git a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
index b69e37136..483d8827e 100644
--- a/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
+++ b/MediaBrowser.Providers/MediaInfo/SubtitleDownloader.cs
@@ -10,6 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Extensions;
namespace MediaBrowser.Providers.MediaInfo
{
@@ -139,7 +140,7 @@ namespace MediaBrowser.Providers.MediaInfo
request.IndexNumberEnd = episode.IndexNumberEnd;
request.SeriesName = episode.SeriesName;
}
-
+
try
{
var searchResults = await _subtitleManager.SearchSubtitles(request, cancellationToken).ConfigureAwait(false);
@@ -154,6 +155,9 @@ namespace MediaBrowser.Providers.MediaInfo
return true;
}
}
+ catch (RateLimitExceededException)
+ {
+ }
catch (Exception ex)
{
_logger.ErrorException("Error downloading subtitles", ex);
diff --git a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
index f7cd9dd13..be2ecf04a 100644
--- a/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
+++ b/MediaBrowser.Providers/Subtitles/SubtitleManager.cs
@@ -133,7 +133,8 @@ namespace MediaBrowser.Providers.Subtitles
{
//var isText = MediaStream.IsTextFormat(response.Format);
- using (var fs = _fileSystem.GetFileStream(savePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true))
+ using (var fs = _fileSystem.GetFileStream(savePath, FileOpenMode.Create, FileAccessMode.Write,
+ FileShareMode.Read, true))
{
await stream.CopyToAsync(fs).ConfigureAwait(false);
}
@@ -154,6 +155,10 @@ namespace MediaBrowser.Providers.Subtitles
}
}
}
+ catch (RateLimitExceededException)
+ {
+ throw;
+ }
catch (Exception ex)
{
EventHelper.FireEventIfNotNull(SubtitleDownloadFailure, this, new SubtitleDownloadFailureEventArgs