David vor 10 Jahren
Ursprung
Commit
3216610a05
6 geänderte Dateien mit 19 neuen und 12 gelöschten Zeilen
  1. 0 0
      back/especificosos-nuevo.png
  2. 3 3
      back/mover.py
  3. 11 6
      back/tasks.py
  4. 1 1
      back/thumb.py
  5. 2 2
      back/web.py
  6. 2 0
      front/controllers/processedCtrl.js

+ 0 - 0
back/especificosos-nuevo.png


+ 3 - 3
back/mover.py

@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
 import os
-from db import db
+from db import db,file_info
 from subprocess import Popen,PIPE
 from constants import RAW_PATH,INCOMING_PATH
 
@@ -11,7 +11,6 @@ for fname in os.listdir(INCOMING_PATH):
         out_fname=os.path.join(RAW_PATH, os.path.basename(fname).replace('flv','mp4'))
         in_fname=os.path.join(INCOMING_PATH, fname)
         if os.path.isfile(out_fname):
-            print("%s exists" % out_fname)
             #exists
             continue
         process=[ 'ffmpeg',
@@ -25,4 +24,5 @@ for fname in os.listdir(INCOMING_PATH):
 
         print(" ".join(process))
         proc=Popen(process, universal_newlines=True)
-d.insert_raw_list()
+        proc.wait()
+        d.insert_raw(file_info(out_fname))

+ 11 - 6
back/tasks.py

@@ -61,15 +61,13 @@ def upload_video(_id,prof,texto1,texto2):
     vid=d.processed(_id)
     ul_file = vid["out_fname"]
     titulo = ("%s - %s - %s" % (prof,texto1,texto2))
-    print("pre-thumb")
     thumb_file = thumb.create_thumb(prof,texto1,texto2)
-    print(thumb_file)
-    #job = jobrunner(upload (titulo, thumb_file, ul_file)) 
-    #FIXME
     job = upload.delay(titulo, thumb_file, ul_file)
+    job.meta["type"]="Youtube"
+    job.meta["target"]=titulo
 
 
-@job('default',connection=conn, timeout=3600*2, result_ttl=3600*2)
+@job('default',connection=conn, timeout=3600*2, result_ttl=360)
 def upload(title,thumb_path,video_path):
     import youtube_upload.main
     j=get_current_job()
@@ -77,6 +75,8 @@ def upload(title,thumb_path,video_path):
     v_id=youtube_upload.main.main(title,thumb_path,video_path,job=j)
     job_end=datetime.datetime.now()
     d.insert_uploaded({'title': title,'yt': v_id, 'video':video_path, 'enqueued_at': job_start, 'finished_at': job_end })
+    j.meta["working"]=False
+    j.save()
     return v_id
 
 @job('default',connection=conn, timeout=30, result_ttl=135)
@@ -97,7 +97,7 @@ def long_job(arg):
 
 
 
-@job('default',connection=conn, timeout=360*2, result_ttl=360*2)
+@job('default',connection=conn, timeout=360*2, result_ttl=360)
 def crop_video(in_fname,start_time,end_time,out_fname):
     job_start = datetime.datetime.now()
     if not os.path.isfile(in_fname):
@@ -122,6 +122,9 @@ def crop_video(in_fname,start_time,end_time,out_fname):
                 out_fname
               ]
 
+    job = get_current_job()
+    job.meta["type"]="Crop"
+    job.save()
     out = run_process(process)
     if out == "":
         out = "Proceso finalizado"
@@ -136,6 +139,8 @@ def crop_video(in_fname,start_time,end_time,out_fname):
                 'in_fname':  in_fname,
                 'out_fname': out_fname
                 })
+    job.meta["working"]=False
+    job.save()
     return out
 
 def run_process(process = None):

+ 1 - 1
back/thumb.py

@@ -5,9 +5,9 @@ from wand.image import Image
 from wand.drawing import Drawing 
 from wand.color import Color
 
-draw = Drawing()
 
 def create_thumb(prof,texto1,texto2):
+    draw = Drawing()
     with tempfile.NamedTemporaryFile(suffix='.png',delete=False) as fp:
         with Image(filename='especificosos-nuevo.png') as img:
             draw.font = "Helvetica"

+ 2 - 2
back/web.py

@@ -66,10 +66,10 @@ def crop():
                                 data["desc"])
 
     job = tasks.crop_video.delay(
-                            (video["file"],
+                            video["file"],
                             str(data["inicio"]),
                             str(data["fin"]),
-                            out_filename,))
+                            out_filename)
     ret["job_id"]=job.get_id()
     return jsonify(ret)
 

+ 2 - 0
front/controllers/processedCtrl.js

@@ -2,6 +2,8 @@ app.controller('processedCtrl', ['$scope', '$http', function ($scope, $http) {
 	$scope.update = function() {
 		$http.get('back/list/processed').success(function(data) {
 	   		$scope.videolist = data.list.map(function(el) {
+				if (el.end_time==0) return el;
+				if (el.start_time==0) return el;
 				if (el.end_time.indexOf(":") == -1 ) { //1800 => 0:30:00
 					el.end_time=toHHMMSS(el.end_time);
 				}