Skip to content

Commit fc32e88

Browse files
authored
Merge pull request #438 from classtranscribe/staging
Push to production
2 parents 0ef3c37 + ea0018c commit fc32e88

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

ClassTranscribeDatabase/CaptionQueries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public CaptionQueries(CTDbContext context)
2121
/// Get the captions for a given videoId
2222
/// </summary>
2323
/// <param name="language">Language of the captions to fetch.</param>
24-
public async Task<List<Caption>> GetCaptionsAsync(string videoId, string language = "en-US")
24+
public async Task<List<Caption>> GetCaptionsAsync(string videoId, string sourceInternalRef, string language) // = "en-US"
2525
{
2626
try
2727
{
28-
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId
28+
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId && t.SourceInternalRef== sourceInternalRef
2929
&& t.TranscriptionType == TranscriptionType.Caption).First().Id;
3030
return await GetCaptionsAsync(transcriptionId);
3131
}

ClassTranscribeServer/Controllers/EPubsController.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ public async Task<ActionResult<List<EPubSceneData>>> GetEpubData(string mediaId,
104104
SourceType = ResourceType.Media,
105105
SourceId = mediaId
106106
};
107-
108-
var captions = await _captionQueries.GetCaptionsAsync(media.VideoId, epub.Language);
107+
const string SOURCEINTERNALREF= "ClassTranscribe/Azure"; // Do not change me; this is a key inside the database
108+
// to indicate the source of the captions was this code
109+
var captions = await _captionQueries.GetCaptionsAsync(media.VideoId, SOURCEINTERNALREF, epub.Language);
109110
_logger.LogInformation($"GetEpubData({mediaId}) - returning combined SceneData");
110111

111112
return GetSceneData(sceneArray, captions);

TaskEngine/Tasks/TranscriptionTask.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
100100
{
101101
buildMockCaptions(videoId);
102102
}
103-
103+
const string SOURCEINTERNALREF= "ClassTranscribe/Azure"; // Do not change me; this is a key inside the database
104+
// to indicate the source of the captions was this code
105+
104106

105107
using (var _context = CTDbContext.CreateDbContext())
106108
{
@@ -165,10 +167,10 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
165167

166168
foreach (string language in allLanguages)
167169
{
168-
var existing = await _captionQueries.GetCaptionsAsync(video.Id, language);
170+
var existing = await _captionQueries.GetCaptionsAsync(video.Id, SOURCEINTERNALREF, language);
169171
captionsMap[language] = existing;
170172

171-
startAfterMap[language] = TimeSpan.Zero;
173+
startAfterMap[language] = TimeSpan.Zero;
172174
if (existing.Any())
173175
{
174176
TimeSpan lastCaptionTime = existing.Select(c => c.End).Max();
@@ -196,10 +198,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
196198
{
197199
var theLanguage = captionsInLanguage.Key;
198200
var theCaptions = captionsInLanguage.Value;
199-
200-
if (theCaptions.Any())
201+
if (theCaptions.Count>0)
201202
{
202-
var t = _context.Transcriptions.SingleOrDefault(t => t.VideoId == video.Id && t.Language == theLanguage);
203+
var t = _context.Transcriptions.SingleOrDefault(t => t.VideoId == video.Id && t.SourceInternalRef == SOURCEINTERNALREF && t.Language == theLanguage && t.TranscriptionType == TranscriptionType.Caption);
203204
GetLogger().LogInformation($"Find Existing Transcriptions null={t == null}");
204205
// Did we get the default or an existing Transcription entity?
205206
if (t == null)
@@ -211,7 +212,7 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
211212
Language = theLanguage,
212213
VideoId = video.Id,
213214
Label = $"{theLanguage} (ClassTranscribe)",
214-
SourceInternalRef = "ClassTranscribe/Azure",
215+
SourceInternalRef = SOURCEINTERNALREF, //
215216
SourceLabel = "ClassTranscribe (Azure" + (phraseHints.Length>0 ?" with phrase hints)" : ")")
216217
};
217218
_context.Add(t);

0 commit comments

Comments
 (0)