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

EsupPortail / Esup-Pod / 5462629459

pending completion
5462629459

Pull #899

github

web-flow
Merge e759dacb6 into c94f0e331
Pull Request #899: [DONE] Ptitloup/feature new encoding

400 of 400 new or added lines in 14 files covered. (100.0%)

8968 of 12675 relevant lines covered (70.75%)

0.71 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
# call local settings directly
9
# no need to load pod application to send statement
10
try:
×
11
    from ..custom import settings_local
×
12
except ImportError:
×
13
    from .. import settings as settings_local
×
14

15
logger = logging.getLogger(__name__)
×
16

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

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

32

33
# celery \
34
# -A pod.video_encode_transcript.transcripting_tasks worker \
35
# -l INFO -Q transcripting
36
@transcripting_app.task
×
37
def start_transcripting_task(video_id, mp3filepath, duration, lang):
×
38
    """Start the transcripting of the video."""
39
    from .transcript_model import start_transcripting
×
40
    from .importing_transcript_tasks import start_importing_transcript_task
×
41
    from ..main.settings import MEDIA_ROOT
×
42
    print("Start the transcripting of the video %s" % video_id)
×
43
    print(video_id, mp3filepath, duration, lang)
×
44
    msg, text_webvtt = start_transcripting(mp3filepath, duration, lang)
×
45
    print("End of the transcripting of the video")
×
46
    media_temp_dir = os.path.join(MEDIA_ROOT, "temp")
×
47
    if not os.path.exists(media_temp_dir):
×
48
        os.mkdir(media_temp_dir)
×
49
    temp_vtt_file = NamedTemporaryFile(
×
50
        dir=media_temp_dir,
51
        delete=False,
52
        suffix=".vtt"
53
    )
54
    text_webvtt.save(temp_vtt_file.name)
×
55
    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

© 2026 Coveralls, Inc