{{- $cache := "" -}} {{- $caption := .Caption -}} {{- $public := print "public/" .Source -}} {{- $timestamp := print "#t=" .Start "," .End -}} {{- $immutable := print (.Slug | humanize | urlize) "-" (.Source | sha256 | truncate 8 "") -}} {{- $extension := path.Ext .Source -}} {{- $fileCache := print $.Author "/media/" $immutable $extension -}} {{- if not (fileExists (path.Join "public/" $fileCache)) -}} {{- with $remote := resources.GetRemote .Source -}} {{- with .Err -}} {{- if fileExists $public -}} {{- else -}} {{- $caption = "No local video data found for source" -}} {{- end -}} {{- else -}} {{- end -}} {{- $cache = . | resources.Copy $fileCache -}} {{- $cache = $cache.RelPermalink -}} {{- else -}} {{- $caption = "No remote video data found for source" -}} {{- end -}} {{- else -}} {{- $cache = resources.Get (path.Join "public/" $fileCache) -}} {{- $cache = $cache.Content | resources.FromString $fileCache -}} {{- $cache = $cache.RelPermalink -}} {{- end -}}