private string GetVideoRuntime() { if (!IsUpdate) { var retry = 1; var duration = string.Empty; while (retry < 5) { try { duration = VideoFileProperties.GetMediaInfoDuration(FullAssetName, IsUpdate); if (!string.IsNullOrEmpty(duration)) { break; } } catch (AccessViolationException sysException) { log.Error($"[GetVideoRuntime] AccessViolationException: {sysException.Message}"); if (sysException.InnerException != null) { log.Error($"[GetVideoRuntime] AccessViolationException Inner exception: {sysException.InnerException.Message}"); } } catch (Exception gvrException) { log.Error($"[GetVideoRuntime] General Exception: {gvrException.Message}"); if (gvrException.InnerException != null) { log.Error($"[GetVideoRuntime] General Inner exception: {gvrException.InnerException.Message}"); } } log.Info($"Get video duration experienced an error, retry attempt: {++retry}"); Thread.Sleep(3000); } return(duration); } return(AdiMapping.ADI_FILE.Asset.Metadata .App_Data .FirstOrDefault(r => r.Name == "Run_Time") ?.Value); }
/// <summary> /// Function to update the asset metadata section /// </summary> /// <returns></returns> private bool SetAssetData() { try { if (!IsUpdate) { log.Info("ITV Metadata conversion completed Successfully, starting media operations"); using (ITVConversionContext mediaContext = new ITVConversionContext()) { MediaLocation = string.Empty; foreach (var location in mediaContext.MediaLocations.ToList()) { FullAssetName = Path.Combine(location.MediaLocation, MediaFileName); if (File.Exists(FullAssetName)) { //set media location used in later logging and calls MediaLocation = location.MediaLocation; //set the bool delete from source object DeleteFromSource = location.DeleteFromSource; log.Info($"Source Media found in location: {MediaLocation} and DeleteFromSource Flag is: {DeleteFromSource}"); //Change to move later on but confirm with dale log.Info($"Copying Media File: {FullAssetName} to {MediaDirectory}"); //create the destination filename //updated to ensure correct video file name is used. string destFname = Path.Combine(MediaDirectory, GetVideoFileName()); //Begin the file movement and file operations if (FileDirectoryOperations.CopyFile(FullAssetName, destFname)) { log.Info($"Media file successfully copied, obtaining file hash for file: {destFname}"); MediaChecksum = VideoFileProperties.GetFileHash(destFname); log.Info($"Source file Hash for {destFname}: {MediaChecksum}"); string fsize = VideoFileProperties.GetFileSize(destFname).ToString(); log.Info($"Source file Size for {destFname}: {fsize}"); AdiMapping.Asset_ID = AdiMapping.ADI_FILE.Asset.Asset.FirstOrDefault().Metadata.AMS.Asset_ID; AdiMapping.SetContent("\\media"); AdiMapping.SetOrUpdateAdiValue("VOD", "Content_CheckSum", MediaChecksum, false); AdiMapping.SetOrUpdateAdiValue("VOD", "Content_FileSize", fsize, false); bool blockPlatform = Convert.ToBoolean(ITV2ADI_CONFIG.BlockQamContentOnOTT); log.Info($"Block platform flag = {blockPlatform}"); if (blockPlatform) { log.Info($"Adding Block_Platform flag with a value of BLOCK_OTT to media metadata section."); AdiMapping.SetOrUpdateAdiValue("VOD", "Block_Platform", "BLOCK_OTT", false); } log.Info("Media metadata and operations completed successfully."); MediaFileName = destFname; return(true); } else { throw new Exception($"File transfer of media file: {MediaFileName} failed, pre and post hashes do not match!"); } } } if (IsUpdate && string.IsNullOrEmpty(MediaLocation)) { log.Info("Update package does not have a media file, continuing with metadata package only."); return(true); } } log.Error($"Media file: {MediaFileName} was not found in the media locations configured, failing ingest."); return(false); } else { return(true); } } catch (Exception SAD_EX) { log.Error($"Failed to Map Asset Data - {SAD_EX.Message}"); if (log.IsDebugEnabled) { log.Debug($"STACK TRACE: {SAD_EX.StackTrace}"); } return(false); } }