@@ -100,7 +100,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
100
100
{
101
101
buildMockCaptions ( videoId ) ;
102
102
}
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
+
104
106
105
107
using ( var _context = CTDbContext . CreateDbContext ( ) )
106
108
{
@@ -165,10 +167,10 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
165
167
166
168
foreach ( string language in allLanguages )
167
169
{
168
- var existing = await _captionQueries . GetCaptionsAsync ( video . Id , language ) ;
170
+ var existing = await _captionQueries . GetCaptionsAsync ( video . Id , SOURCEINTERNALREF , language ) ;
169
171
captionsMap [ language ] = existing ;
170
172
171
- startAfterMap [ language ] = TimeSpan . Zero ;
173
+ startAfterMap [ language ] = TimeSpan . Zero ;
172
174
if ( existing . Any ( ) )
173
175
{
174
176
TimeSpan lastCaptionTime = existing . Select ( c => c . End ) . Max ( ) ;
@@ -196,10 +198,9 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
196
198
{
197
199
var theLanguage = captionsInLanguage . Key ;
198
200
var theCaptions = captionsInLanguage . Value ;
199
-
200
- if ( theCaptions . Any ( ) )
201
+ if ( theCaptions . Count > 0 )
201
202
{
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 ) ;
203
204
GetLogger ( ) . LogInformation ( $ "Find Existing Transcriptions null={ t == null } ") ;
204
205
// Did we get the default or an existing Transcription entity?
205
206
if ( t == null )
@@ -211,7 +212,7 @@ protected async override Task OnConsume(string videoId, TaskParameters taskParam
211
212
Language = theLanguage ,
212
213
VideoId = video . Id ,
213
214
Label = $ "{ theLanguage } (ClassTranscribe)",
214
- SourceInternalRef = "ClassTranscribe/Azure" ,
215
+ SourceInternalRef = SOURCEINTERNALREF , //
215
216
SourceLabel = "ClassTranscribe (Azure" + ( phraseHints . Length > 0 ? " with phrase hints)" : ")" )
216
217
} ;
217
218
_context . Add ( t ) ;
0 commit comments