diff bin/vidref @ 1954:3ae1e7f8db23

vidref playback smoothness, autodelete short clips, manual-delete clips, vidref keyboard shortcuts Ignore-this: 6daccf686fd66561029f3252ed4dbafd
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 06 Jun 2019 02:28:28 +0000
parents 9f0f2b39ad95
children 9ee42b88299b
line wrap: on
line diff
--- a/bin/vidref	Thu Jun 06 05:50:34 2019 +0000
+++ b/bin/vidref	Thu Jun 06 02:28:28 2019 +0000
@@ -24,9 +24,9 @@
 from light9.vidref import videorecorder
 from rdflib import URIRef
 from light9.newtypes import Song
-from light9.namespaces import L9
 from rdfdb.syncedgraph import SyncedGraph
 from cycloneerr import PrettyErrorHandler
+from typing import cast
 
 parser = optparse.OptionParser()
 parser.add_option("-v", "--verbose", action="store_true", help="logging.DEBUG")
@@ -96,13 +96,12 @@
         self.set_status(202)
 
 
-def takeUri(songPath: bytes):
-    p = songPath.decode('ascii').split('/')
-    take = p[-1].replace('.mp4', '')
-    song = p[-2].split('_')
-    return URIRef('/'.join(
-        ['http://light9.bigasterisk.com/show', song[-2], song[-1], take]))
+
+class Clips(PrettyErrorHandler, cyclone.web.RequestHandler):
 
+    def delete(self):
+        clip = URIRef(self.get_argument('uri'))
+        videorecorder.deleteClip(clip)
 
 class ReplayMap(PrettyErrorHandler, cyclone.web.RequestHandler):
 
@@ -120,12 +119,12 @@
                          ):].decode('ascii')
 
             clips.append({
-                'uri': takeUri(vid),
+                'uri': videorecorder.takeUri(vid),
                 'videoUrl': url,
                 'songToVideo': pts
             })
 
-        clips.sort(key=lambda c: len(c['songToVideo']))
+        clips.sort(key=lambda c: len(cast(list, c['songToVideo'])))
         clips = clips[-3:]
         clips.sort(key=lambda c: c['uri'], reverse=True)
 
@@ -153,6 +152,7 @@
                 'default_filename': 'setup.html'
             }),
             (r'/live', Live),
+            (r'/clips', Clips),
             (r'/replayMap', ReplayMap),
             (r'/snapshot', Snapshot),
             (r'/snapshot/(.*)', SnapshotPic, {