]> git.0d.be Git - pige-extractor.git/commitdiff
add support for fade in/out (pass ?fade=0.2, with 0.2 being the duration)
authorFrédéric Péters <fpeters@0d.be>
Sun, 15 May 2016 14:07:42 +0000 (16:07 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 15 May 2016 14:16:17 +0000 (16:16 +0200)
download.cgi

index c12134b7e3e13a4f6b9e7da0ccff2cda98ce85e1..b8b5d5f0df0188b321e46031358c389233b22f49 100755 (executable)
@@ -24,7 +24,7 @@ for i, dirname in enumerate(BASE_DIR):
 
 syslog.openlog('pigebox')
 
-d = cgi.parse()
+cgi_params = cgi.parse()
 
 if os.environ.get('PATH_INFO'):
     # filename has to be of date-start-end.extension
@@ -58,16 +58,16 @@ if os.environ.get('PATH_INFO'):
     end = datetime.datetime(date.year, date.month, date.day,
             end_time.hour, end_time.minute, end_time.second,
             end_time.microsecond)
-elif d:
-    end = '%s:%s' % (d.get('end_hour')[0], d.get('end_min')[0])
+elif cgi_params:
+    encgi_params = '%s:%s' % (cgi_params.get('encgi_params_hour')[0], cgi_params.get('encgi_params_min')[0])
 
     start = datetime.datetime.strptime('%s %s:%s' % (
-           d.get('date')[0], d.get('start_hour')[0], d.get('start_min')[0]),
+           cgi_params.get('cgi_paramsate')[0], cgi_params.get('start_hour')[0], cgi_params.get('start_min')[0]),
            '%d/%m/%Y %H:%M')
     end = datetime.datetime.strptime('%s %s:%s' % (
-           d.get('date')[0], d.get('end_hour')[0], d.get('end_min')[0]),
+           cgi_params.get('cgi_paramsate')[0], cgi_params.get('encgi_params_hour')[0], cgi_params.get('encgi_params_min')[0]),
            '%d/%m/%Y %H:%M')
-    if d.get('wav'):
+    if cgi_params.get('wav'):
         ext = 'wav'
     else:
         ext = 'ogg'
@@ -154,6 +154,11 @@ command.append('trim')
 command.append('=%s.%06d' % ((start - floor_start).seconds, (start - floor_start).microseconds))
 command.append('=%s.%06d' % ((end - floor_start).seconds, (end - floor_start).microseconds))
 
+if cgi_params.get('fade'): # fade duration, ex: 0.2
+    command.append('fade')
+    command.append(cgi_params.get('fade')[0])
+    command.append('0') # apply fade to both start and end
+
 if '--test' in sys.argv:
     print ' '.join(command)
 else: