|
|
@@ -36,16 +36,22 @@ def result(job_key):
|
|
|
def cargar_plataforma(video_id):
|
|
|
data = d.videoData(video_id)
|
|
|
|
|
|
- tsplit=data["title"].split("-")
|
|
|
- prof=tsplit[0]
|
|
|
- texto1=tsplit[1].strip()
|
|
|
- texto2=tsplit[2].strip()
|
|
|
+ prof = None
|
|
|
+ if "profesor" in data:
|
|
|
+ prof = data["profesor"]
|
|
|
+
|
|
|
+ tsplit = data["title"].split("-")
|
|
|
+ texto1 = tsplit[1].strip()
|
|
|
+ texto2 = tsplit[2].strip()
|
|
|
|
|
|
tmp = { "video": data["yt"],
|
|
|
"diapos": "[]",
|
|
|
"titulo": "%s - %s" % (texto1, texto2),
|
|
|
"auth_token": "4b494d6c7ffc74d387d8cfdef8ca1691"
|
|
|
}
|
|
|
+ if prof is not None:
|
|
|
+ tmp["profesor"] = prof
|
|
|
+
|
|
|
r = requests.post('https://plataforma.especificosba.com.ar/back/crearVideo.php', json = tmp );
|
|
|
if r.status_code == 200:
|
|
|
return {"status":"Ok"}
|
|
|
@@ -83,21 +89,27 @@ def jobs():
|
|
|
def upload_video(_id,prof,texto1,texto2):
|
|
|
vid=d.processed(_id)
|
|
|
ul_file = vid["out_fname"]
|
|
|
- titulo = ("%s - %s - %s" % (prof,texto1,texto2))
|
|
|
- thumb_file = thumb.create_thumb(prof,texto1,texto2)
|
|
|
- job = upload.delay(titulo, thumb_file, ul_file)
|
|
|
+ profname = prof
|
|
|
+ try:
|
|
|
+ profname = ("%s %s" % (prof["nombre"], prof["apellido"]))
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ titulo = ("%s - %s - %s" % (profname,texto1,texto2))
|
|
|
+ thumb_file = thumb.create_thumb(profname,texto1,texto2)
|
|
|
+ job = upload.delay(titulo, prof, thumb_file, ul_file)
|
|
|
job.meta["type"]="Youtube"
|
|
|
job.meta["target"]=titulo
|
|
|
|
|
|
|
|
|
@job('default',connection=conn, timeout=3600*2, result_ttl=360)
|
|
|
-def upload(title,thumb_path,video_path):
|
|
|
+def upload(title,prof,thumb_path,video_path):
|
|
|
import youtube_upload.main
|
|
|
j=get_current_job()
|
|
|
job_start=datetime.datetime.now()
|
|
|
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 })
|
|
|
+ d.insert_uploaded({'title': title,'profesor':prof,'yt': v_id, 'video':video_path, 'enqueued_at': job_start, 'finished_at': job_end })
|
|
|
j.meta["working"]=False
|
|
|
j.save()
|
|
|
return v_id
|
|
|
@@ -121,7 +133,7 @@ def long_job(arg):
|
|
|
|
|
|
|
|
|
@job('default',connection=conn, timeout=360*2, result_ttl=360)
|
|
|
-def crop_video(in_fname,start_time,end_time,out_fname):
|
|
|
+def crop_video(in_fname,start_time,end_time,censuras,out_fname):
|
|
|
job = get_current_job()
|
|
|
job.meta["type"]="Crop"
|
|
|
job.save()
|
|
|
@@ -138,23 +150,30 @@ def crop_video(in_fname,start_time,end_time,out_fname):
|
|
|
}
|
|
|
|
|
|
process = [ 'ffmpeg',
|
|
|
- '-loglevel', 'error',
|
|
|
- '-stats',
|
|
|
- '-analyzeduration', '16M',
|
|
|
- '-i', in_fname,
|
|
|
+ '-analyzeduration', '8M',
|
|
|
+ '-i', in_fname
|
|
|
+ ]
|
|
|
+ if censuras is not None and len(censuras) > 0:
|
|
|
+ s = ""
|
|
|
+ print(censuras)
|
|
|
+ for c in censuras:
|
|
|
+ s += "volume=enable='between(t,%d,%d)':volume=0, " % (int(c["inicio"]),int(c["fin"]))
|
|
|
+ s=s[:-2] #borro ", " del final
|
|
|
+ process = process + [ "-c:a", "libfdk_aac", "-af", s ]
|
|
|
+ else:
|
|
|
+ process += ["-c:a", "copy"]
|
|
|
+
|
|
|
+ process += [
|
|
|
'-ss', str(start_time),
|
|
|
'-t', str(end_time),
|
|
|
- '-c', 'copy',
|
|
|
+ '-c:v', 'copy',
|
|
|
'-movflags', '+faststart',
|
|
|
- '-f','mp4',
|
|
|
- out_fname
|
|
|
- ]
|
|
|
-
|
|
|
+ '-f', 'mp4', out_fname
|
|
|
+ ]
|
|
|
out = run_process(process)
|
|
|
if out == "":
|
|
|
out = "Proceso finalizado"
|
|
|
|
|
|
-#
|
|
|
test_broken = [ "ffprobe", "-loglevel", "warning", out_fname ]
|
|
|
is_broken = Popen(test_broken, stderr=PIPE)
|
|
|
l = is_broken.stderr.readline()
|
|
|
@@ -183,6 +202,7 @@ def run_process(process = None):
|
|
|
return { "status": "error",
|
|
|
"error": "Argumento process invalido"
|
|
|
}
|
|
|
+ print(" ".join(process))
|
|
|
proc=Popen(process, stderr=PIPE, universal_newlines=True)
|
|
|
job = get_current_job()
|
|
|
while True:
|