Esempio n. 1
0
        private static CatalogueVideo MapVideoResponseToCatalogueVideo(List <IndexedVideoResponse> responses, string widgetLink, string videoPlayerUrl)
        {
            var englishIndex = responses[0];

            var cosmosDoc = new CatalogueVideo
            {
                doctype           = "catalogueVideo",
                durationInSeconds = englishIndex.durationInSeconds,
                id             = englishIndex.id,
                name           = englishIndex.name,
                thumbnailId    = englishIndex.videos[0].thumbnailId,
                videoPlayerUrl = videoPlayerUrl,
                widgetUrl      = widgetLink,
                languages      = new List <string>(),
                transcription  = new List <LanguageTranscription>(),
                labels         = new List <LanguageLabels>()
            };

            foreach (var response in responses)
            {
                cosmosDoc.transcription.Add(new LanguageTranscription()
                {
                    languageCode  = response.videos[0].language,
                    transcription = response.videos[0].insights.transcript
                });
                cosmosDoc.labels.Add(new LanguageLabels()
                {
                    languageCode = response.videos[0].language,
                    labels       = response.videos[0].insights.labels
                });
                cosmosDoc.languages.Add(response.videos[0].language);
            }

            return(cosmosDoc);
        }
Esempio n. 2
0
 public async Task StoreVideoDetails(CatalogueVideo details)
 {
     try
     {
         ItemResponse <CatalogueVideo> response = await this.container.CreateItemAsync <CatalogueVideo>(details, new PartitionKey(details.id));
     }
     catch (CosmosException ex) when(ex.StatusCode == HttpStatusCode.Conflict)
     {
         Console.WriteLine("Item in database with id: {0} already exists\n", details.id);
     }
 }