mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Rename part 1
This commit is contained in:
parent
ed0532724c
commit
249f44e5bf
@ -3,7 +3,7 @@ using System;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.VobSub.Ocr
|
||||
{
|
||||
public static class OcrHelper
|
||||
public static class OcrHelper_1
|
||||
{
|
||||
public static string PostOcr(string input, string language)
|
||||
{
|
@ -15,7 +15,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
/// <summary>
|
||||
/// OCR via Google Cloud Vision API - see https://cloud.google.com/vision/docs/ocr
|
||||
/// </summary>
|
||||
public class GoogleCloudVisionApi : IOcrStrategy
|
||||
public class GoogleCloudVisionApi_1 : IOcrStrategy_1
|
||||
{
|
||||
private readonly string _apiKey;
|
||||
private readonly HttpClient _httpClient;
|
||||
@ -35,7 +35,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
return 16;
|
||||
}
|
||||
|
||||
public GoogleCloudVisionApi(string apiKey)
|
||||
public GoogleCloudVisionApi_1(string apiKey)
|
||||
{
|
||||
_apiKey = apiKey;
|
||||
_httpClient = HttpClientHelper.MakeHttpClient();
|
||||
@ -81,17 +81,17 @@ namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
var result = _httpClient.PostAsync(uri, new StringContent(requestBodyString)).Result;
|
||||
if ((int)result.StatusCode == 400)
|
||||
{
|
||||
throw new OcrException("API key invalid (or perhaps billing is not enabled)?");
|
||||
throw new OcrException_1("API key invalid (or perhaps billing is not enabled)?");
|
||||
}
|
||||
|
||||
if ((int)result.StatusCode == 403)
|
||||
{
|
||||
throw new OcrException("\"Perhaps billing is not enabled (or API key is invalid)?\"");
|
||||
throw new OcrException_1("\"Perhaps billing is not enabled (or API key is invalid)?\"");
|
||||
}
|
||||
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new OcrException($"An error occurred calling Cloud Vision API - status code: {result.StatusCode}");
|
||||
throw new OcrException_1($"An error occurred calling Cloud Vision API - status code: {result.StatusCode}");
|
||||
}
|
||||
|
||||
content = result.Content.ReadAsStringAsync().Result;
|
||||
@ -107,7 +107,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
message = "Perhaps billing is not enabled (or API key is invalid)?";
|
||||
}
|
||||
throw new OcrException(message, webException);
|
||||
throw new OcrException_1(message, webException);
|
||||
}
|
||||
|
||||
var resultList = new List<string>();
|
||||
@ -136,7 +136,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
if (firstTextAnnotation["description"] is string description)
|
||||
{
|
||||
result = OcrHelper.PostOcr(description, language);
|
||||
result = OcrHelper_1.PostOcr(description, language);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,12 +3,12 @@ using System.Drawing;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
public class GoogleOcrService : IOcrStrategy
|
||||
public class GoogleOcrService_1 : IOcrStrategy_1
|
||||
{
|
||||
|
||||
private readonly IOcrStrategy _ocrStrategy;
|
||||
private readonly IOcrStrategy_1 _ocrStrategy;
|
||||
|
||||
public GoogleOcrService(IOcrStrategy translationStrategy)
|
||||
public GoogleOcrService_1(IOcrStrategy_1 translationStrategy)
|
||||
{
|
||||
_ocrStrategy = translationStrategy;
|
||||
}
|
@ -3,7 +3,7 @@ using System.Drawing;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
public interface IOcrStrategy
|
||||
public interface IOcrStrategy_1
|
||||
{
|
||||
string GetName();
|
||||
string GetUrl();
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
public class OcrException : Exception
|
||||
{
|
||||
public OcrException(WebException webException) : base("",webException)
|
||||
{
|
||||
}
|
||||
|
||||
public OcrException(string message, Exception exception) : base(message, exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public OcrException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
22
src/libse/VobSub/Ocr/Service/OcrException_1.cs
Normal file
22
src/libse/VobSub/Ocr/Service/OcrException_1.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Core.VobSub.Ocr.Service
|
||||
{
|
||||
public class OcrException_1 : Exception
|
||||
{
|
||||
public OcrException_1(WebException webException) : base("",webException)
|
||||
{
|
||||
}
|
||||
|
||||
public OcrException_1(string message, Exception exception) : base(message, exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public OcrException_1(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -347,7 +347,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
private NOcrThreadResult[] _nOcrThreadResults;
|
||||
private bool _ocrThreadStop;
|
||||
|
||||
private IOcrStrategy _ocrService;
|
||||
private IOcrStrategy_1 _ocrService;
|
||||
|
||||
private readonly Keys _italicShortcut = UiUtil.GetKeys(Configuration.Settings.Shortcuts.MainListViewItalic);
|
||||
private readonly Keys _mainGeneralGoToNextSubtitle = UiUtil.GetKeys(Configuration.Settings.Shortcuts.GeneralGoToNextSubtitle);
|
||||
@ -5252,7 +5252,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
|
||||
{
|
||||
if (_ocrService == null)
|
||||
{
|
||||
_ocrService = new GoogleOcrService(new GoogleCloudVisionApi(textBoxCloudVisionApiKey.Text));
|
||||
_ocrService = new GoogleOcrService_1(new GoogleCloudVisionApi_1(textBoxCloudVisionApiKey.Text));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user