diff --git a/pod/video_encode_transcript/importing_transcript_tasks.py b/pod/video_encode_transcript/importing_transcript_tasks.py index ef22e0af7e..c528561f15 100644 --- a/pod/video_encode_transcript/importing_transcript_tasks.py +++ b/pod/video_encode_transcript/importing_transcript_tasks.py @@ -1,6 +1,8 @@ from celery import Celery from .. import settings import logging +import io +import webvtt logger = logging.getLogger(__name__) ENCODING_TRANSCODING_CELERY_BROKER_URL = getattr( @@ -20,12 +22,17 @@ } -# celery -A pod.video_encode_transcript.importing_tasks worker -l INFO -Q importing +# celery \ +# -A pod.video_encode_transcript.importing_transcript_tasks worker \ +# -l INFO -Q importing_transcript @importing_transcript_app.task -def start_importing_transcript_task(video_id, msg, webvtt): +def start_importing_transcript_task(video_id, msg, textwebvtt): """Start the encoding of the video.""" print("Start the importing transcript of the video ID : %s" % video_id) from pod.video.models import Video from .transcript import save_vtt_and_notify video_to_encode = Video.objects.get(id=video_id) - save_vtt_and_notify(video_to_encode, msg, webvtt) + textwebvtt = "WEBVTT\\n\\n" + textwebvtt + f = io.StringIO(textwebvtt) + new_vtt = webvtt.read_buffer(f) + save_vtt_and_notify(video_to_encode, msg, new_vtt) diff --git a/pod/video_encode_transcript/transcript.py b/pod/video_encode_transcript/transcript.py index c42fa67b4d..8e33da31e1 100644 --- a/pod/video_encode_transcript/transcript.py +++ b/pod/video_encode_transcript/transcript.py @@ -105,7 +105,7 @@ def main_threaded_transcript(video_to_encode_id): else: mp3filepath = mp3file.path if USE_DISTANT_ENCODING_TRANSCODING: - start_transcripting_task( + start_transcripting_task.delay( video_to_encode.id, mp3filepath, video_to_encode.duration, diff --git a/pod/video_encode_transcript/transcripting_tasks.py b/pod/video_encode_transcript/transcripting_tasks.py index 5fecf8d429..53ed38fd45 100644 --- a/pod/video_encode_transcript/transcripting_tasks.py +++ b/pod/video_encode_transcript/transcripting_tasks.py @@ -26,11 +26,13 @@ } -# celery -A pod.video_encode_transcript.encoding_tasks worker -l INFO -Q encoding +# celery \ +# -A pod.video_encode_transcript.transcripting_tasks worker \ +# -l INFO -Q transcripting @transcripting_app.task def start_transcripting_task(video_id, mp3filepath, duration, lang): """Start the encoding of the video.""" print("Start the transcripting of the video %s" % video_id) msg, webvtt = start_transcripting(mp3filepath, duration, lang) print("End of the transcripting of the video") - start_importing_transcript_task.delay(video_id, msg, webvtt) + start_importing_transcript_task.delay(video_id, msg, str(webvtt))