• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EsupPortail / Esup-Pod / 6377635546

02 Oct 2023 08:21AM UTC coverage: 70.396% (-1.6%) from 71.99%
6377635546

push

github

web-flow
Merge pull request #900 from EsupPortail/develop

[DONE] #3.4.0

1509 of 1509 new or added lines in 58 files covered. (100.0%)

9288 of 13194 relevant lines covered (70.4%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pod/video_encode_transcript/transcripting_tasks.py
1
# pip3 install celery==5.2.7
2
# pip3 install webvtt-py
3
# pip3 install redis==4.5.4
4
from celery import Celery
×
5
from tempfile import NamedTemporaryFile
×
6
import logging
×
7
import os
×
8

9
# call local settings directly
10
# no need to load pod application to send statement
11
try:
×
12
    from ..custom import settings_local
×
13
except ImportError:
×
14
    from .. import settings as settings_local
×
15

16
logger = logging.getLogger(__name__)
×
17

18
ENCODING_TRANSCODING_CELERY_BROKER_URL = getattr(
×
19
    settings_local, "ENCODING_TRANSCODING_CELERY_BROKER_URL", ""
20
)
21

22
transcripting_app = Celery(
×
23
    "transcripting_tasks", broker=ENCODING_TRANSCODING_CELERY_BROKER_URL
24
)
25
transcripting_app.conf.task_routes = {
×
26
    "pod.video_encode_transcript.transcripting_tasks.*": {"queue": "transcripting"}
27
}
28
transcripting_app.autodiscover_tasks(packages=None, related_name="", force=False)
×
29

30

31
# celery \
32
# -A pod.video_encode_transcript.transcripting_tasks worker \
33
# -l INFO -Q transcripting
34
@transcripting_app.task
×
35
def start_transcripting_task(video_id, mp3filepath, duration, lang):
×
36
    """Start the transcripting of the video."""
37
    from .transcript_model import start_transcripting
×
38
    from .importing_transcript_tasks import start_importing_transcript_task
×
39
    from ..main.settings import MEDIA_ROOT
×
40

41
    print("Start the transcripting of the video %s" % video_id)
×
42
    print(video_id, mp3filepath, duration, lang)
×
43
    msg, text_webvtt = start_transcripting(mp3filepath, duration, lang)
×
44
    print("End of the transcripting of the video")
×
45
    media_temp_dir = os.path.join(MEDIA_ROOT, "temp")
×
46
    if not os.path.exists(media_temp_dir):
×
47
        os.mkdir(media_temp_dir)
×
48
    temp_vtt_file = NamedTemporaryFile(dir=media_temp_dir, delete=False, suffix=".vtt")
×
49
    text_webvtt.save(temp_vtt_file.name)
×
50
    start_importing_transcript_task.delay(video_id, msg, temp_vtt_file.name)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc