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 4171810 commit 893b01e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Providers/SubDivx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace subbuzz.Providers
public class SubDivx : ISubBuzzProvider
{
internal const string NAME = "subdivx";
private const string ServerUrl = "https://subf2m.co";
private const string ServerUrl = "https://subdivx.com";
private static readonly string[] CacheRegionSub = { "subdivx", "sub" };
private static readonly string[] CacheRegionSubPage = { "subdivx", "subpage" };
private static readonly string[] CacheRegionSearch = { "subdivx", "search" };
Expand Down
70 changes: 70 additions & 0 deletions Providers/SubDl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Subtitles;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Providers;
using subbuzz.Configuration;
using subbuzz.Helpers;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace subbuzz.Providers
{
public class SubDl : ISubBuzzProvider
{
internal const string NAME = "subdl";
private const string ServerUrl = "https://api.subdl.com";
private static readonly string[] CacheRegionSub = { "subdl", "sub" };
private static readonly string[] CacheRegionSubPage = { "subdl", "subpage" };
private static readonly string[] CacheRegionSearch = { "subdl", "search" };

private readonly Logger _logger;
private readonly Http.Download _downloader;
private readonly IFileSystem _fileSystem;
private readonly ILocalizationManager _localizationManager;
private readonly ILibraryManager _libraryManager;

public string Name => $"[{Plugin.NAME}] <b>{NAME}</b>";

public IEnumerable<VideoContentType> SupportedMediaTypes =>
new List<VideoContentType> { VideoContentType.Episode, VideoContentType.Movie };

private PluginConfiguration GetOptions()
=> Plugin.Instance.Configuration;

public SubDl(
Logger logger,
IFileSystem fileSystem,
ILocalizationManager localizationManager,
ILibraryManager libraryManager)
{
_logger = logger;
_fileSystem = fileSystem;
_localizationManager = localizationManager;
_libraryManager = libraryManager;
_downloader = new Http.Download(logger);

}

public async Task<SubtitleResponse> GetSubtitles(string id, CancellationToken cancellationToken)
{
return await _downloader.GetSubtitles(id, cancellationToken).ConfigureAwait(false);
}

public async Task<IEnumerable<RemoteSubtitleInfo>> Search(SubtitleSearchRequest request,

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for jellyfin-10.9

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for jellyfin-10.8

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for emby-4.8

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for emby-4.8

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for emby-4.7

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 56 in Providers/SubDl.cs

View workflow job for this annotation

GitHub Actions / Build for emby-4.7

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
CancellationToken cancellationToken)
{
var watch = System.Diagnostics.Stopwatch.StartNew();
var res = new List<SubtitleInfo>();

// TODO:

watch.Stop();
_logger.LogInformation($"Search duration: {watch.ElapsedMilliseconds / 1000.0} sec. Subtitles found: {res.Count}");

return res;
}
}
}

0 comments on commit 893b01e

Please sign in to comment.