diff --git a/app/static/js/edits.js b/app/static/js/edits.js index 730fdac..454a612 100644 --- a/app/static/js/edits.js +++ b/app/static/js/edits.js @@ -90,6 +90,18 @@ async function sortClips(edit, sort) { } } +function getClip(edit, position) { + const response = {} + let pos = 0 + edit.clips.forEach(function(clip) { + if (clip.position < position && clip.position + clip.duration > position) { + response.item = clip.id + response.position = position - clip.position + } + }); + return response +} + async function loadEdit(id, args) { var data = window.data = {} data.id = id @@ -235,8 +247,11 @@ async function loadEdit(id, args) { data.title = data.edit.name data.byline = data.edit.description data.link = `${pandora.proto}://${data.site}/edits/${data.edit.id}` - const poster = data.edit.posterFrames[0] - if (poster) { + let poster = data.edit.posterFrames[0] + if (args.parts[2] && args.parts[2].indexOf(':') > -1) { + poster = getClip(data.edit, parseDuration(args.parts[2])) + } + if (poster && poster.item) { data.poster = `${pandora.proto}://${data.site}/${poster.item}/480p${poster.position}.jpg` } else { data.poster = data.videos[0].src.split('/48')[0] + `/480p${data.videos[0].in}.jpg`