public Guid?GetSkierTagId(SkiVideoEntity video) { try { if (string.IsNullOrEmpty(video.Skier)) { return(null); } string skier = video.Skier.Trim(); var tag = m_tags.Where(t => t.Name == skier).FirstOrDefault(); if (tag == null) { if (HasEnoughOfSkier(skier)) { tag = m_trainingApi.CreateTag(m_projectId, skier); m_tags.Add(tag); } } return(tag.Id); } catch (Exception e) { Logger.Log($"Unable to get SkierTag for {video.Skier}\n" + e); return(null); } }
private Guid?GetTagId(SkiVideoEntity video, string tagName, Func <TrainingModels.Tag, SkiVideoEntity, bool> tagSelector, Func <SkiVideoEntity, string, bool> enoughSelector) { // Forgive the ridiculous nature of all the Func<> parameters, but this generalizes this // function so that the derived classes can specify their own implementation of what // constitutes a tag without repeating itself; i.e. skier, ropeLength, etc... var tag = tags.Where(t => tagSelector(t, video)).FirstOrDefault(); // No tags, see if we have enough data to create one. if (tag == null && EnoughForTag(tagName, enoughSelector)) { tag = CreateTag(video, tagName); } if (tag != null) { return(tag.Id); } else { return(null); } }
public void AddMetadata(SkiVideoEntity entity, string json) { string blobName = GetBlobName(entity.Url, entity.RecordedTime); string jsonUrl = UploadMeasurements(blobName, json); entity.JsonUrl = jsonUrl; AddTableEntity(entity); Logger.Log("Uploaded metadata for video:" + entity.Url); }
public void UpdateMetadata(SkiVideoEntity entity) { CloudTableClient client = _account.CreateCloudTableClient(); CloudTable table = client.GetTableReference(SKITABLE); TableOperation update = TableOperation.Merge(entity); update.Entity.ETag = "*"; // Allow last-writer wins approach. Task updateTask = table.ExecuteAsync(update); updateTask.Wait(); }
protected override bool EnoughSelector(SkiVideoEntity video, string tag) { double rope; if (!double.TryParse(tag, out rope)) { return(false); } return(video.RopeLengthM == rope); }
protected override bool TagSelector(TrainingModels.Tag tag, SkiVideoEntity video) { if (tag == null || video == null) { return(false); } else { return(tag.Name == video.RopeLengthM.ToString()); } }
protected override bool TagSelector(TrainingModels.Tag tag, SkiVideoEntity video) { if (tag == null || video == null) { return(false); } else { return(tag.Name == video.Skier.Trim()); } }
private void AddTableEntity(SkiVideoEntity entity) { CloudTableClient client = _account.CreateCloudTableClient(); CloudTable table = client.GetTableReference(SKITABLE); TableOperation insert = TableOperation.InsertOrReplace(entity); Task createTask = table.CreateIfNotExistsAsync(); createTask.Wait(); Task insertTask = table.ExecuteAsync(insert); insertTask.Wait(); }
private IList <Guid> GetTagIds(SkiVideoEntity video) { // // Returns a list of Guids, even though there is only 1 item, or return null if none. // List <Guid> tagIds = null; var tag = GetTagId(video, GetTagValue(video), TagSelector, EnoughSelector); if (tag != null) { tagIds = new List <Guid>(); tagIds.Add((Guid)tag); } return(tagIds); }
public Guid?GetRopeTagId(SkiVideoEntity video) { if (video.RopeLengthM == 0) { return(null); } string rope = video.RopeLengthM.ToString(); var tag = m_tags.Where(t => t.Name == rope).FirstOrDefault(); if (tag == null) { if (HasEnoughOfRope(video.RopeLengthM)) { tag = m_trainingApi.CreateTag(m_projectId, rope); m_tags.Add(tag); } } return(tag.Id); }
public SkiVideoEntity GetSkiVideoEntity(string recordedDate, string mp4Filename) { // ParitionKey format YYYY-MM-DD // RowKey format e.g. GOPR01444.MP4 SkiVideoEntity entity = null; try { CloudTableClient client = _account.CreateCloudTableClient(); CloudTable table = client.GetTableReference(SKITABLE); TableOperation retrieve = TableOperation.Retrieve <SkiVideoEntity>(recordedDate, mp4Filename); Task <TableResult> retrieveTask = table.ExecuteAsync(retrieve); retrieveTask.Wait(); entity = (SkiVideoEntity)retrieveTask.Result.Result; } catch (Exception e) { Logger.Log($"Unable to retrieve SkiVideoEntity; ParitionKey {recordedDate}, RowKey {mp4Filename}", e); } return(entity); }
private TrainingModels.Tag CreateTag(SkiVideoEntity video, string tagName) { TrainingModels.Tag tag = trainingApi.CreateTag(ProjectId, tagName); tags.Add(tag); return(tag); }
protected abstract bool TagSelector(TrainingModels.Tag tag, SkiVideoEntity video);
protected override bool EnoughSelector(SkiVideoEntity video, string tag) { return(video.Skier.Trim() == tag); }
protected override string GetTagValue(SkiVideoEntity video) { return(video.RopeLengthM.ToString()); }
public WebVtt(SkiVideoEntity skiVideo) { _skiVideo = skiVideo; }
public void TestSkiVideoEntity() { SkiVideoEntity entity = new SkiVideoEntity(); Console.WriteLine(entity.SlalomTrackerVersion); }
protected abstract bool EnoughSelector(SkiVideoEntity video, string tag);
protected abstract string GetTagValue(SkiVideoEntity video);
protected override string GetTagValue(SkiVideoEntity video) { return(video.Skier.Trim()); }