Prechádzať zdrojové kódy

cut => crop, jobrunner for cropping, fix tati fucking up

David 10 rokov pred
rodič
commit
c60f595012
6 zmenil súbory, kde vykonal 31 pridanie a 19 odobranie
  1. 2 2
      back/tasks.py
  2. 15 7
      back/web.py
  3. 1 1
      front/app.js
  4. 8 5
      front/controllers/cutCtrl.js
  5. 1 0
      front/index.html
  6. 4 4
      front/views/cut.html

+ 2 - 2
back/tasks.py

@@ -17,7 +17,7 @@ date_fmt='%d/%m/%Y, %H:%M'
 
 
 def jobrunner(fn,args):
-    job = fn.delay(args)
+    job = fn.delay(*args)
     job_key_list.append(job.get_id())
     return job
 
@@ -70,7 +70,7 @@ def upload_video(title,thumb_path,video_path):
 
 
 @job('default',connection=conn, timeout=360*2, result_ttl=360*2)
-def cut_video(in_fname,start_time,end_time,out_fname):
+def crop_video(in_fname,start_time,end_time,out_fname):
     job_start = datetime.datetime.now()
     if not os.path.isfile(in_fname):
         return { "status":"error",

+ 15 - 7
back/web.py

@@ -15,6 +15,7 @@ d=db()
 def index():
     return "Hello world"
 
+@app.route(BASE_PATH + '/list/raw/')
 @app.route(BASE_PATH + '/list/raw')
 def raw_list():
     ret={'list': d.raw() }
@@ -27,11 +28,12 @@ def raw_file(video_id):
     return jsonify(ret)
 
 @app.route(BASE_PATH + '/list/processed/')
+@app.route(BASE_PATH + '/list/processed')
 def processed_list():
     ret={'list': d.processed() }
     return jsonify(ret)
-@app.route(BASE_PATH + '/cut/', methods=["POST"])
-def cut():
+@app.route(BASE_PATH + '/crop/', methods=["POST"])
+def crop():
     ret={"status":"Procesando"}
     today=datetime.date.today()
     data = request.get_json()
@@ -41,14 +43,20 @@ def cut():
                                 today.strftime('%Y%m%d'),
                                 data["desc"])
 
-    job = tasks.cut_video.delay(video["file"],
-                                str(data["inicio"]),
-                                str(data["fin"]),
-                                out_filename)
+    job = tasks.jobrunner(tasks.crop_video, 
+                            (video["file"],
+                            str(data["inicio"]),
+                            str(data["fin"]),
+                            out_filename,))
+    #job = tasks.crop_video.delay(video["file"],
+    #                            str(data["inicio"]),
+    #                            str(data["fin"]),
+    #                            out_filename)
     ret["job_id"]=job.get_id()
     return jsonify(ret)
 
-@app.route(BASE_PATH + '/jobs/')
+@app.route(BASE_PATH + '/list/jobs/')
+@app.route(BASE_PATH + '/list/jobs')
 def jobs():
     working = tasks.jobs()
     finished = d.getJobs()

+ 1 - 1
front/app.js

@@ -9,7 +9,7 @@ app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $lo
 	})
 	.when('/jobs', {
 		templateUrl: 'views/jobs.html',
-		controller: 'rawCtrl'
+		controller: 'jobsCtrl'
 	})
 	.when('/processed', {
 		templateUrl: 'views/processed.html',

+ 8 - 5
front/controllers/cutCtrl.js

@@ -1,4 +1,4 @@
-app.controller('cutCtrl', function ($scope, $http,video) {
+app.controller('cutCtrl', function ($scope, $http,video,notify) {
 	$scope.inicio=0;
 	$scope.fin=0;
 	$scope.curso="";
@@ -13,10 +13,13 @@ app.controller('cutCtrl', function ($scope, $http,video) {
 					fin: $scope.fin,
 					id: $scope.video._id
 				};
-		$http.post('/back/cut/', data).success(
-			function(data,state) {
-				console.log(data);
-			});
+		$http.post('/back/crop/', data)
+		.success(function(data,state) {
+			notify({message:data.status,classes:"alert"});
+		})
+		.error(function(data) {
+			notify({message:data.status,classes:"alert alert-danger"});
+		});
 	};
 
 	function getVideoTime(){

+ 1 - 0
front/index.html

@@ -16,6 +16,7 @@
 	<script type="text/javascript" src="/app.js"></script>
 	<script type="text/javascript" src="/controllers/rawCtrl.js"></script>
 	<script type="text/javascript" src="/controllers/processedCtrl.js"></script>
+	<script type="text/javascript" src="/controllers/jobsCtrl.js"></script>
 	<script type="text/javascript" src="/controllers/cutCtrl.js"></script>
     <base href="/" />
 </head>

+ 4 - 4
front/views/cut.html

@@ -12,13 +12,13 @@
 				<div class="col-md-6">
 					<div class="form-group">
 					    <label>Inicio</label>
-					    <input type="text" class="form-control" placeholder="inicio">
+					    <input type="text" class="form-control" ng-model="inicio" placeholder="inicio">
 					</div>
 				</div>
 				<div class="col-md-6">
 					<div class="form-group">
 					    <label>Fin</label>
-					    <input type="text" class="form-control" placeholder="inicio">
+					    <input type="text" class="form-control" ng-model="fin" placeholder="fin">
 					</div>
 				</div>
 			</div>
@@ -27,13 +27,13 @@
 				<div class="col-md-6">
 					<div class="form-group">
 					    <label>Curso</label>
-					    <input type="text" class="form-control" placeholder="inicio">
+					    <input type="text" class="form-control" ng-model="curso" placeholder="Curso">
 					</div>
 				</div>
 				<div class="col-md-6">
 					<div class="form-group">
 					    <label>Descripcion</label>
-					    <input type="text" class="form-control" placeholder="inicio">
+					    <input type="text" class="form-control" ng-model="desc" placeholder="Descripcion">
 					</div>
 				</div>
 			</div>