Example #1
0
        private static string GetVersion()
        {
            SkiVideoEntity video   = new SkiVideoEntity("http://test/video.MP4", DateTime.Now);
            string         version = video.SlalomTrackerVersion;

            return(version);
        }
Example #2
0
        public JsonResult Get()
        {
            SkiVideoEntity video   = new SkiVideoEntity("http://test/video.MP4", DateTime.Now);
            string         version = video.SlalomTrackerVersion;

            return(Json($"Version: {version}"));
        }
Example #3
0
        public IActionResult Get(string recordedDate, string mp4Filename)
        {
            string vttContent;

            try
            {
                Storage        storage = new Storage();
                SkiVideoEntity entity  = storage.GetSkiVideoEntity(recordedDate, mp4Filename);
                if (entity == null)
                {
                    throw new ApplicationException($"Unable to load SkiVideo {recordedDate}, {mp4Filename}");
                }
                WebVtt vtt = new WebVtt(entity);
                vttContent = vtt.Create();

                _logger.LogInformation($"Created WebVtt for {recordedDate}, {mp4Filename}");

                return(Content(vttContent, new Microsoft.Net.Http.Headers.MediaTypeHeaderValue("text/vtt")));
            }
            catch (Exception e)
            {
                _logger.LogError("Unable to create WebVtt: " + e.Message);
                return(StatusCode(500));
            }
        }
Example #4
0
        public CoursePass FromSkiVideo(SkiVideoEntity video)
        {
            CenterLineDegreeOffset = video.CenterLineDegreeOffset;
            RopeLengthOff = video.RopeLengthM;
            
            KnownCourses courses = new KnownCourses();
            Course = courses.ByName(video.CourseName);

            return FromUrl(video.JsonUrl);
        }
Example #5
0
        public void AddMetadataTest()
        {
            CoursePassFactory factory = new CoursePassFactory();
            string            json    = File.ReadAllText("./Video/GOPR0565.json");
            CoursePass        pass    = factory.FromJson(json);
            SkiVideoEntity    entity  = new SkiVideoEntity(URL, new DateTime(2018, 08, 24));

            Storage storage = new Storage();

            storage.AddMetadata(entity, json);
        }
Example #6
0
        private static void PrintCreationTime(string inputFile)
        {
            VideoTasks video    = new VideoTasks(inputFile);
            DateTime   creation = video.GetCreationTime();

            Console.WriteLine(
                $"File: {inputFile}, video creationtime " +
                creation.ToString("MM/dd/yyyy h:mm tt"));

            SkiVideoEntity entity = new SkiVideoEntity("http://localhost/TEST.MP4", creation);
            string         obj    = Newtonsoft.Json.JsonConvert.SerializeObject(entity);

            System.Console.WriteLine("Object:\n" + obj);
        }
Example #7
0
        public void TestCreateVtt()
        {
            Storage        storage    = new Storage();
            SkiVideoEntity entity     = storage.GetSkiVideoEntity(RECORDED_DATE, VIDEO_FILE);
            WebVtt         vtt        = new WebVtt(entity);
            string         vttContent = vtt.Create();

            if (vttContent == null)
            {
                System.Console.WriteLine("Nothing..");
            }
            else
            {
                System.Console.WriteLine("Content: " + vttContent);
            }
        }
Example #8
0
        private static async Task UpdateThumbnailAsync(Storage storage, SkiVideoEntity video)
        {
            Logger.Log($"Updating thumbnail for {video.PartitionKey}, {video.RowKey}");
            double thumbnailAtSeconds = 0; // video.EntryTime;

            string     localVideoPath = Storage.DownloadVideo(video.HotUrl ?? video.Url);
            VideoTasks _videoTasks    = new VideoTasks(localVideoPath);

            string localThumbnailPath = await _videoTasks.GetThumbnailAsync(thumbnailAtSeconds);

            string modifiedThumbnailPath = localThumbnailPath.Replace("_ts.PNG", ".PNG");

            System.IO.File.Move(localThumbnailPath, modifiedThumbnailPath);
            string thumbnailUrl = storage.UploadThumbnail(modifiedThumbnailPath, video.RecordedTime);

            Logger.Log($"New thumbnail at {thumbnailUrl}");
        }
Example #9
0
 public IActionResult UpdateVideo()
 {
     try
     {
         string         json  = GetJsonFromBody();
         SkiVideoEntity video = JsonConvert.DeserializeObject <SkiVideoEntity>(json);
         if (video == null)
         {
             string message = $"Error reading video instance from payload:\n{json}";
             throw new ApplicationException(message);
         }
         Storage storage = new Storage();
         storage.UpdateMetadata(video);
         return(StatusCode(200));
     }
     catch (Exception e)
     {
         _logger.LogError(e.Message);
         return(StatusCode(500, e.Message));
     }
 }
        private Measurement GetMeasurement(SkiVideoEntity entity, double seconds)
        {
            List <Measurement> measurements = null;

            if (!string.IsNullOrWhiteSpace(entity.CourseName))
            {
                CoursePassFactory factory = new CoursePassFactory();
                CoursePass        pass    = factory.FromSkiVideo(entity);
                measurements = pass.Measurements;
            }
            else
            {
                WebClient client = new WebClient();
                string    json   = client.DownloadString(entity.JsonUrl);
                measurements = Measurement.DeserializeMeasurements(json);
            }

            Measurement measurement = measurements.
                                      FindHandleAtSeconds(seconds + entity.EntryTime);

            return(measurement);
        }
        public IActionResult Get(double seconds, string recordedDate, string mp4Filename)
        {
            try
            {
                Storage        storage = new Storage();
                SkiVideoEntity entity  = storage.GetSkiVideoEntity(recordedDate, mp4Filename);
                if (entity == null)
                {
                    throw new ApplicationException($"Unable to load SkiVideo {recordedDate}, {mp4Filename}");
                }

                Measurement measurement = GetMeasurement(entity, seconds);

                return(Content(measurement.ToString(),
                               new MediaTypeHeaderValue("application/json")));
            }
            catch (Exception e)
            {
                _logger.LogError("Unable to find handle position: " + e.Message);
                return(StatusCode(500));
            }
        }
Example #12
0
        private Course GetCourseFromMetadata(Storage storage, string jsonUrl)
        {
            string         date     = ParseDate(jsonUrl);
            string         filename = GetMP4FromJsonUrl(jsonUrl);
            SkiVideoEntity entity   = storage.GetSkiVideoEntity(date, filename);

            // Should probably throw an exception here?
            if (entity == null)
            {
                Console.WriteLine($"Couldn't load video metadata for {jsonUrl}");
                return(null);
            }

            if (string.IsNullOrEmpty(entity.CourseName))
            {
                Console.WriteLine($"No course saved for {jsonUrl}");
                return(null);
            }

            KnownCourses courses = new KnownCourses();

            return(courses.ByName(entity.CourseName));
        }
Example #13
0
        private static async Task DeleteGoogleVideoAsync(GoogleStorage gstore, Storage storage, SkiVideoEntity video)
        {
            Logger.Log($"Deleting {video.HotUrl} recorded @ {video.RecordedTime}.");
            await gstore.DeleteAsync(video.HotUrl);

            video.HotUrl = "";
            storage.UpdateMetadata(video);
            Logger.Log($"Metadata updated for video recorded @ {video.RecordedTime}.");
        }
Example #14
0
        private static void PrintVersion()
        {
            SkiVideoEntity video = new SkiVideoEntity("http://test/test", DateTime.Now);

            Console.WriteLine("Version: " + video.SlalomTrackerVersion);
        }
Example #15
0
        private static void PrintVersion()
        {
            SkiVideoEntity video = new SkiVideoEntity();

            Console.WriteLine(video.SlalomTrackerVersion);
        }