Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
josdion committed Oct 24, 2024
1 parent 9e7fab3 commit f4a29a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Providers/SubBuzz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest
var watch = System.Diagnostics.Stopwatch.StartNew();
var tasks = new Dictionary<string, Task<IEnumerable<RemoteSubtitleInfo>>>();

#if JELLYFIN
// Jellyfin search request times out after 30 seconds, so ignore searches not completed in time.
var maxDuration = 29000;
#else
// For emby use 3 minutes timeout
var maxDuration = 3 * 60 * 1000;
#endif

_logger.LogInformation($"Start subtitle search for {request.Name} [{request.Language}].");

foreach (var p in Providers)
Expand All @@ -92,15 +100,13 @@ public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest

foreach (var task in tasks)
{
#if JELLYFIN
// Jellyfin search request times out after 30 seconds, so ignore searches not completed in time.
var elapsedTime = watch.ElapsedMilliseconds;
if (!task.Value.Wait((int)(elapsedTime >= 29000 ? 1 : 29000 - elapsedTime), cancellationToken))
if (!task.Value.Wait((int)(elapsedTime >= maxDuration ? 1 : maxDuration - elapsedTime), cancellationToken))
{
_logger.LogInformation($"The response from {task.Key} is ignored because it did not complete in time.");
continue;
}
#endif


List<SubtitleInfo> subs = (List<SubtitleInfo>)await task.Value;

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Subtitles plugin for [Emby](https://emby.media/) and [Jellyfin](https://jellyfin
* [Addic7ed.com](https://www.addic7ed.com)
* [Opensubtitles.com](https://www.opensubtitles.com)
* [Podnapisi.NET](https://www.podnapisi.net)
* [Subf2m.co](https://subf2m.co)
* [Subs.sab.bz](https://subs.sab.bz)
* [Subsunacs.net](https://subsunacs.net)
* [Yavka.net](https://www.yavka.net)
Expand Down
2 changes: 1 addition & 1 deletion subbuzz.emby.4.8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<LangVersion>latest</LangVersion>
<RootNamespace>subbuzz</RootNamespace>
<AssemblyName>subbuzz</AssemblyName>
<DefineConstants>EMBY</DefineConstants>
<DefineConstants>EMBY,NO_HTML</DefineConstants>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PackageProjectUrl>https://github.com/josdion/subbuzz</PackageProjectUrl>
Expand Down

0 comments on commit f4a29a8

Please sign in to comment.