diff --git a/Directory.Build.props b/Directory.Build.props
index 1fbdbed..a82213b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -2,6 +2,7 @@
net7.0
+ latest
enable
enable
diff --git a/YouTubeSummariser.sln b/YouTubeSummariser.sln
index 334343a..c06350a 100644
--- a/YouTubeSummariser.sln
+++ b/YouTubeSummariser.sln
@@ -7,9 +7,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F0754B28-F0B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTubeSummariser.ApiApp", "src\YouTubeSummariser.ApiApp\YouTubeSummariser.ApiApp.csproj", "{D2B6ACCD-125F-4AB8-B072-0F3C104AEBB2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YouTubeSummariser.Services", "src\YouTubeSummariser.Services\YouTubeSummariser.Services.csproj", "{47F2E24C-23E7-4E07-B52A-7A33C5165645}"
+EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTubeSummariser.WebApp.Wasm", "src\YouTubeSummariser.WebApp.Wasm\YouTubeSummariser.WebApp.Wasm.csproj", "{BA0E2490-C014-4325-85C3-5132FEBE1844}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YouTubeSummariser.Components", "src\YouTubeSummariser.Components\YouTubeSummariser.Components.csproj", "{8F0B64D6-E1A2-487F-8978-AA91A2732AF3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YouTubeSummariser.Components", "src\YouTubeSummariser.Components\YouTubeSummariser.Components.csproj", "{8F0B64D6-E1A2-487F-8978-AA91A2732AF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,10 @@ Global
{D2B6ACCD-125F-4AB8-B072-0F3C104AEBB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D2B6ACCD-125F-4AB8-B072-0F3C104AEBB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D2B6ACCD-125F-4AB8-B072-0F3C104AEBB2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {47F2E24C-23E7-4E07-B52A-7A33C5165645}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {47F2E24C-23E7-4E07-B52A-7A33C5165645}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {47F2E24C-23E7-4E07-B52A-7A33C5165645}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {47F2E24C-23E7-4E07-B52A-7A33C5165645}.Release|Any CPU.Build.0 = Release|Any CPU
{BA0E2490-C014-4325-85C3-5132FEBE1844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA0E2490-C014-4325-85C3-5132FEBE1844}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA0E2490-C014-4325-85C3-5132FEBE1844}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -35,6 +41,7 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D2B6ACCD-125F-4AB8-B072-0F3C104AEBB2} = {F0754B28-F0B2-414C-83DB-06854DBF508E}
+ {47F2E24C-23E7-4E07-B52A-7A33C5165645} = {F0754B28-F0B2-414C-83DB-06854DBF508E}
{BA0E2490-C014-4325-85C3-5132FEBE1844} = {F0754B28-F0B2-414C-83DB-06854DBF508E}
{8F0B64D6-E1A2-487F-8978-AA91A2732AF3} = {F0754B28-F0B2-414C-83DB-06854DBF508E}
EndGlobalSection
diff --git a/src/YouTubeSummariser.ApiApp/Program.cs b/src/YouTubeSummariser.ApiApp/Program.cs
index 4439256..da40bd1 100644
--- a/src/YouTubeSummariser.ApiApp/Program.cs
+++ b/src/YouTubeSummariser.ApiApp/Program.cs
@@ -8,14 +8,14 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-
-using YouTubeSummariser.ApiApp.Configurations;
-using YouTubeSummariser.ApiApp.Services;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Abstractions;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Configurations;
using Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Enums;
using Microsoft.OpenApi.Models;
+using YouTubeSummariser.Services;
+using YouTubeSummariser.Services.Configurations;
+
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults(worker => worker.UseNewtonsoftJson())
//.ConfigureFunctionsWorkerDefaults()
diff --git a/src/YouTubeSummariser.ApiApp/Triggers/SummariseHttpTrigger.cs b/src/YouTubeSummariser.ApiApp/Triggers/SummariseHttpTrigger.cs
index 63e146f..84d1866 100644
--- a/src/YouTubeSummariser.ApiApp/Triggers/SummariseHttpTrigger.cs
+++ b/src/YouTubeSummariser.ApiApp/Triggers/SummariseHttpTrigger.cs
@@ -8,8 +8,8 @@
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
-using YouTubeSummariser.ApiApp.Models;
-using YouTubeSummariser.ApiApp.Services;
+using YouTubeSummariser.Services;
+using YouTubeSummariser.Services.Models;
namespace YouTubeSummariser.ApiApp.Triggers;
@@ -78,12 +78,22 @@ public async Task SummariseAsync([HttpTrigger(AuthorizationLev
try
{
- var transcript = await this._youtube.GetTranscriptAsync(payload.VideoUrl, payload.VideoLanguageCode);
- var completion = await this._openai.GetCompletionsAsync(transcript, payload.SummaryLanguageCode);
-
response = req.CreateResponse(HttpStatusCode.OK);
response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
+ var transcript = await this._youtube.GetTranscriptAsync(payload.VideoUrl, payload.VideoLanguageCode);
+ if (string.IsNullOrWhiteSpace(transcript) == true)
+ {
+ var message = "The given YouTube video doesn't provide transcripts.";
+ this._logger.LogInformation(message);
+
+ await response.WriteStringAsync(message);
+
+ return response;
+ }
+
+ var completion = await this._openai.GetCompletionsAsync(transcript, payload.SummaryLanguageCode);
+
await response.WriteStringAsync(completion);
return response;
diff --git a/src/YouTubeSummariser.ApiApp/YouTubeSummariser.ApiApp.csproj b/src/YouTubeSummariser.ApiApp/YouTubeSummariser.ApiApp.csproj
index 07884f8..849149b 100644
--- a/src/YouTubeSummariser.ApiApp/YouTubeSummariser.ApiApp.csproj
+++ b/src/YouTubeSummariser.ApiApp/YouTubeSummariser.ApiApp.csproj
@@ -9,14 +9,16 @@
-
-
+
+
+
+
PreserveNewest
diff --git a/src/YouTubeSummariser.ApiApp/Configurations/OpenAISettings.cs b/src/YouTubeSummariser.Services/Configurations/OpenAISettings.cs
similarity index 92%
rename from src/YouTubeSummariser.ApiApp/Configurations/OpenAISettings.cs
rename to src/YouTubeSummariser.Services/Configurations/OpenAISettings.cs
index a5f8a9d..bd318b5 100644
--- a/src/YouTubeSummariser.ApiApp/Configurations/OpenAISettings.cs
+++ b/src/YouTubeSummariser.Services/Configurations/OpenAISettings.cs
@@ -1,4 +1,4 @@
-namespace YouTubeSummariser.ApiApp.Configurations;
+namespace YouTubeSummariser.Services.Configurations;
///
/// This represents the settings entity for the OpenAI API.
diff --git a/src/YouTubeSummariser.ApiApp/Configurations/PromptSettings.cs b/src/YouTubeSummariser.Services/Configurations/PromptSettings.cs
similarity index 92%
rename from src/YouTubeSummariser.ApiApp/Configurations/PromptSettings.cs
rename to src/YouTubeSummariser.Services/Configurations/PromptSettings.cs
index a60da3f..7890c56 100644
--- a/src/YouTubeSummariser.ApiApp/Configurations/PromptSettings.cs
+++ b/src/YouTubeSummariser.Services/Configurations/PromptSettings.cs
@@ -1,4 +1,4 @@
-namespace YouTubeSummariser.ApiApp.Configurations;
+namespace YouTubeSummariser.Services.Configurations;
///
/// This represents the settings entity for the prompt.
diff --git a/src/YouTubeSummariser.ApiApp/Models/SummariseRequestModel.cs b/src/YouTubeSummariser.Services/Models/SummariseRequestModel.cs
similarity index 92%
rename from src/YouTubeSummariser.ApiApp/Models/SummariseRequestModel.cs
rename to src/YouTubeSummariser.Services/Models/SummariseRequestModel.cs
index 3af9296..e945c72 100644
--- a/src/YouTubeSummariser.ApiApp/Models/SummariseRequestModel.cs
+++ b/src/YouTubeSummariser.Services/Models/SummariseRequestModel.cs
@@ -1,4 +1,4 @@
-namespace YouTubeSummariser.ApiApp.Models;
+namespace YouTubeSummariser.Services.Models;
///
/// This represents the request model entity containing YouTube video details.
diff --git a/src/YouTubeSummariser.ApiApp/Services/OpenAIService.cs b/src/YouTubeSummariser.Services/Services/OpenAIService.cs
similarity index 96%
rename from src/YouTubeSummariser.ApiApp/Services/OpenAIService.cs
rename to src/YouTubeSummariser.Services/Services/OpenAIService.cs
index 16988b6..c71e892 100644
--- a/src/YouTubeSummariser.ApiApp/Services/OpenAIService.cs
+++ b/src/YouTubeSummariser.Services/Services/OpenAIService.cs
@@ -1,8 +1,8 @@
using Azure.AI.OpenAI;
-using YouTubeSummariser.ApiApp.Configurations;
+using YouTubeSummariser.Services.Configurations;
-namespace YouTubeSummariser.ApiApp.Services;
+namespace YouTubeSummariser.Services;
///
/// This provides interfaces to the class.
diff --git a/src/YouTubeSummariser.ApiApp/Services/YouTubeService.cs b/src/YouTubeSummariser.Services/Services/YouTubeService.cs
similarity index 92%
rename from src/YouTubeSummariser.ApiApp/Services/YouTubeService.cs
rename to src/YouTubeSummariser.Services/Services/YouTubeService.cs
index 706a3cc..53cdec1 100644
--- a/src/YouTubeSummariser.ApiApp/Services/YouTubeService.cs
+++ b/src/YouTubeSummariser.Services/Services/YouTubeService.cs
@@ -1,6 +1,6 @@
using Aliencube.YouTubeSubtitlesExtractor.Abstractions;
-namespace YouTubeSummariser.ApiApp.Services;
+namespace YouTubeSummariser.Services;
///
/// This provides interfaces to the class.
@@ -38,6 +38,11 @@ public async Task GetTranscriptAsync(string videoUrl, string languageCod
var subtitle = await this._youtube
.ExtractSubtitleAsync(videoUrl, languageCode)
.ConfigureAwait(false);
+ if (subtitle == null)
+ {
+ return string.Empty;
+ }
+
var transcript = subtitle.Content
.Select(p => p.Text)
.Aggregate((a, b) => $"{a}\n{b}");
diff --git a/src/YouTubeSummariser.Services/YouTubeSummariser.Services.csproj b/src/YouTubeSummariser.Services/YouTubeSummariser.Services.csproj
new file mode 100644
index 0000000..fd908d7
--- /dev/null
+++ b/src/YouTubeSummariser.Services/YouTubeSummariser.Services.csproj
@@ -0,0 +1,15 @@
+
+
+
+ netstandard2.0
+
+ YouTubeSummariser.Services
+ YouTubeSummariser.Services
+
+
+
+
+
+
+
+