-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 GitHub Actions / Build for jellyfin-10.9
Check warning on line 56 in Providers/SubDl.cs GitHub Actions / Build for jellyfin-10.8
Check warning on line 56 in Providers/SubDl.cs GitHub Actions / Build for emby-4.8
Check warning on line 56 in Providers/SubDl.cs GitHub Actions / Build for emby-4.8
Check warning on line 56 in Providers/SubDl.cs GitHub Actions / Build for emby-4.7
Check warning on line 56 in Providers/SubDl.cs GitHub Actions / Build for emby-4.7
|
||
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; | ||
} | ||
} | ||
} |