Skip to content

Commit f5627d7

Browse files
authored
Merge pull request #492 from classtranscribe/make-epub-read-from-captions
toggle chapter
2 parents 70d5932 + c08b791 commit f5627d7

File tree

2 files changed

+294
-250
lines changed

2 files changed

+294
-250
lines changed

ClassTranscribeDatabase/CaptionQueries.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public async Task<List<Caption>> GetCaptionsAsync(string videoId, string sourceI
2525
{
2626
try
2727
{
28-
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId && t.SourceInternalRef== sourceInternalRef
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
}
@@ -37,6 +37,26 @@ public async Task<List<Caption>> GetCaptionsAsync(string videoId, string sourceI
3737
}
3838
}
3939

40+
/// <summary>
41+
/// Get the text descriptions for a given videoId
42+
/// </summary>
43+
/// <param name="language">Language of the captions to fetch.</param>
44+
public async Task<List<Caption>> GetDescriptionsAsync(string videoId, string language) // = "en-US"
45+
{
46+
try
47+
{
48+
var transcriptionId = _context.Transcriptions.Where(t => t.Language == language && t.VideoId == videoId
49+
&& t.TranscriptionType == TranscriptionType.TextDescription).First().Id;
50+
return await GetCaptionsAsync(transcriptionId);
51+
}
52+
catch (System.InvalidOperationException)
53+
{
54+
// If Transcriptions do not exist then First() will throw InvalidOperationException
55+
56+
return new List<Caption>();
57+
}
58+
}
59+
4060
/// <summary>
4161
/// Get the captions for a given transcriptionId
4262
/// </summary>

0 commit comments

Comments
 (0)