Skip to content

Commit

Permalink
WIP: subdl
Browse files Browse the repository at this point in the history
  • Loading branch information
josdion committed Oct 27, 2024
1 parent cebcf56 commit 76af64f
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Configuration/Jellyfin/configPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ <h2 class="sectionTitle">Subdl.com Account</h2>
config.OpenSubApiKey = apiKey;
config.OpenSubToken = token;

page.querySelector("#EnableSubdlCom").checked = config.EnableSubdlCom;
page.querySelector('#SubdlApiKey').value = config.SubdlApiKey || '';
config.EnableSubdlCom = form.querySelector("#EnableSubdlCom").checked;
config.SubdlApiKey = form.querySelector('#SubdlApiKey').value;

config.SubPostProcessing.EncodeSubtitlesToUTF8 = form.querySelector("#EncodeSubtitlesToUTF8").checked;
config.SubPostProcessing.AdjustDuration = form.querySelector("#AdjustDuration").checked;
Expand Down Expand Up @@ -312,7 +312,7 @@ <h2 class="sectionTitle">Subdl.com Account</h2>
}

el.innerHtml = "&nbsp;";
Dashboard.processErrorResponse({ statusText: "Request failed - " + msg });
Dashboard.processErrorResponse({ statusText: "Validate OpenSubtitles Account: Request failed - " + msg });
return;
}
});
Expand Down
6 changes: 4 additions & 2 deletions Providers/SubBuzz.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public SubBuzz(
{ PodnapisiNet.NAME, new PodnapisiNet(_logger.GetLogger<PodnapisiNet>(), fileSystem, localizationManager, libraryManager) },
{ Subf2m.NAME, new Subf2m(_logger.GetLogger<Subf2m>(), fileSystem, localizationManager, libraryManager) },
{ SubDl.NAME, new SubDl(_logger.GetLogger<SubDl>(), fileSystem, localizationManager, libraryManager) },
//{ Subscene.NAME, new Subscene(_logger.GetLogger<Subscene>(), fileSystem, localizationManager, libraryManager) },
{ YifySubtitles.NAME, new YifySubtitles(_logger.GetLogger<YifySubtitles>(), fileSystem, localizationManager, libraryManager) },
{ Addic7ed.NAME, new Addic7ed(_logger.GetLogger<Addic7ed>(), fileSystem, localizationManager, libraryManager) },
};
Expand Down Expand Up @@ -161,13 +160,16 @@ private static void FormatInfoNoHtml(SubtitleInfo s, string provider)
if (s.IsHearingImpaired ?? false) s.Name = "[HI/SDH] " + s.Name;
#endif
#if EMBY || JELLYFIN_108
var brRepl = " &#9734; ";
if (s.MachineTranslated ?? false) s.Name = "[MT] " + s.Name;
if (s.AiTranslated ?? false) s.Name = "[AI] " + s.Name;
#else
var brRepl = "\n";
#endif

var regex = new System.Text.RegularExpressions.Regex(@"<br.*?>",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
s.Comment = regex.Replace(s.Comment, " &#9734; ");
s.Comment = regex.Replace(s.Comment, brRepl);

var parser = new AngleSharp.Html.Parser.HtmlParser();
var nodeList = parser.ParseFragment(s.Comment, null);
Expand Down
7 changes: 6 additions & 1 deletion Providers/SubDl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,12 @@ protected async Task<List<SubtitleInfo>> Search(SearchInfo si, string apiKey, Ca
if (relName.Trim() != subItem.Release)
subInfo += "<br>" + relName;
}
subInfo += (subItem.Comment.IsNotNullOrWhiteSpace()) ? $"<br>{subItem.Comment}" : "";
if (subItem.Comment.IsNotNullOrWhiteSpace())
{
var comment = Utils.TrimString(subItem.Comment, "\n").Replace("\n\n", "\n").Replace("\n\n", "\n").Replace("\n", "<br>");
subInfo += $"<br>{comment}";
}

subInfo += "<br>" + subItem.Author;

var item = new SubtitleInfo
Expand Down
2 changes: 1 addition & 1 deletion Providers/YifySubtitles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected async Task<List<SubtitleInfo>> ParseHtml(System.IO.Stream html, Search

string subInfoBase = linkTag.InnerHtml;
var regexInfo = new Regex(@"<span.*/span>");
subInfoBase = regexInfo.Replace(subInfoBase, "").Trim();
subInfoBase = regexInfo.Replace(subInfoBase, "").Trim().Replace("\n", " ");
string subInfo = subTitle + (subInfoBase.IsNullOrWhiteSpace() ? "" : "<br>" + subInfoBase);
subInfo += string.Format("<br>{0}", subUploader);

Expand Down
48 changes: 48 additions & 0 deletions subbuzz.emby.4.9.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj/emby-4.9</BaseIntermediateOutputPath>
<BaseOutputPath>bin/emby-4.9</BaseOutputPath>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<LangVersion>latest</LangVersion>
<RootNamespace>subbuzz</RootNamespace>
<AssemblyName>subbuzz</AssemblyName>
<DefineConstants>EMBY,NO_HTML</DefineConstants>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PackageProjectUrl>https://github.com/josdion/subbuzz</PackageProjectUrl>
<Nullable>annotations</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="API\ControllerJellyfin.cs" />
<Compile Remove="PluginServiceRegistrator.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="mediabrowser.server.core" Version="4.9.*-*" />
<PackageReference Include="SharpCompress" Version="0.33.0" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Text.Json" Version="6.0.10" />
</ItemGroup>

<ItemGroup>
<None Remove="Configuration\*.html" />
<None Remove="Configuration\*.js" />
<None Remove="Configuration\**" />
<None Remove="thumb.png" />
<EmbeddedResource Include="Configuration\*.html" />
<EmbeddedResource Include="Configuration\*.js" />
<EmbeddedResource Include="Configuration\Emby\*.js" />
<EmbeddedResource Include="Configuration\Emby\*.html" />
<EmbeddedResource Include="thumb.png" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

</Project>
45 changes: 45 additions & 0 deletions subbuzz.jellyfin.10.10.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj/jellyfin-10.10</BaseIntermediateOutputPath>
<BaseOutputPath>bin/jellyfin-10.10</BaseOutputPath>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<RootNamespace>subbuzz</RootNamespace>
<AssemblyName>subbuzz</AssemblyName>
<DefineConstants>JELLYFIN,NO_HTML</DefineConstants>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<PackageProjectUrl>https://github.com/josdion/subbuzz</PackageProjectUrl>
<Nullable>annotations</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

<ItemGroup>
<Compile Remove="API\ControllerEmby.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.10.*-*" IncludeAssets="compile" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" IncludeAssets="compile" />
<FrameworkReference Include="Microsoft.AspNetCore.App" Version="2.2.8" IncludeAssets="compile" />
<PackageReference Include="SharpCompress" Version="0.37.2" />
</ItemGroup>

<ItemGroup>
<None Remove="Configuration\*.html" />
<None Remove="Configuration\*.js" />
<None Remove="Configuration\**" />
<EmbeddedResource Include="Configuration\*.html" />
<EmbeddedResource Include="Configuration\*.js" />
<EmbeddedResource Include="Configuration\Jellyfin\*.js" />
<EmbeddedResource Include="Configuration\Jellyfin\*.html" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

</Project>
12 changes: 12 additions & 0 deletions subbuzz.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "subbuzz.emby.4.8", "subbuzz
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "subbuzz.jellyfin.10.9", "subbuzz.jellyfin.10.9.csproj", "{AEA78E87-44CA-4DC3-B83E-EDBB3A68B434}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "subbuzz.emby.4.9", "subbuzz.emby.4.9.csproj", "{B1979726-10BD-46F6-953D-10E5B04B9F50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "subbuzz.jellyfin.10.10", "subbuzz.jellyfin.10.10.csproj", "{D64C04CA-0585-4943-BF19-DCF2CABDE7FE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +37,14 @@ Global
{AEA78E87-44CA-4DC3-B83E-EDBB3A68B434}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AEA78E87-44CA-4DC3-B83E-EDBB3A68B434}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AEA78E87-44CA-4DC3-B83E-EDBB3A68B434}.Release|Any CPU.Build.0 = Release|Any CPU
{B1979726-10BD-46F6-953D-10E5B04B9F50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1979726-10BD-46F6-953D-10E5B04B9F50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1979726-10BD-46F6-953D-10E5B04B9F50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1979726-10BD-46F6-953D-10E5B04B9F50}.Release|Any CPU.Build.0 = Release|Any CPU
{D64C04CA-0585-4943-BF19-DCF2CABDE7FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D64C04CA-0585-4943-BF19-DCF2CABDE7FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D64C04CA-0585-4943-BF19-DCF2CABDE7FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D64C04CA-0585-4943-BF19-DCF2CABDE7FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 76af64f

Please sign in to comment.