<commit_before>"""
Views related to operations on course objects
"""
import json
import logging
import os

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response

from opaque_keys import InvalidKeyError
from util.json_request import JsonResponse
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError, InsufficientSpecificationError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.keys import UsageKey
from xmodule.video_module.transcripts_utils import (
    GetTranscriptsFromYouTubeException,
    TranscriptsRequestValidationException,
    download_youtube_subs,
)
from xmodule.video_module import manage_video_subtitles_save

from ..transcripts_ajax import get_transcripts_presence
from ..course import get_course_and_check_access


log = logging.getLogger(__name__)

__all__ = ['utility_captions_handler']


# pylint: disable=unused-argument
@login_required
def utility_captions_handler(request, course_key_string):
    """
    The restful handler for captions requests in the utilities area.
    It provides the list of course videos as well as their status. It also lets
    the user update the captions by pulling the latest version from YouTube.

    GET<commit_msg>HACK: Disable broken import on captions<commit_after>"""
Views related to operations on course objects
"""
import json
import logging
import os

from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseBadRequest, HttpResponseNotFound
from django.utils.translation import ugettext as _
from django.views.decorators.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response

from opaque_keys import InvalidKeyError
from util.json_request import JsonResponse
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError, InsufficientSpecificationError
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.keys import UsageKey
from xmodule.video_module.transcripts_utils import (
    GetTranscriptsFromYouTubeException,
    TranscriptsRequestValidationException,
    download_youtube_subs,
)
from xmodule.video_module import manage_video_subtitles_save

# from ..transcripts_ajax import get_transcripts_presence
from ..course import get_course_and_check_access


log = logging.getLogger(__name__)

__all__ = ['utility_captions_handler']


# pylint: disable=unused-argument
@login_required
def utility_captions_handler(request, course_key_string):
    """
    The restful handler for captions requests in the utilities area.
    It provides the list of course videos as well as their status. It also lets
    the user update the captions by pulling the latest version from YouTube.

    GET
{'fraction_non_alphanumeric': 0.044359949302915085, 'fraction_numerical': 0.0, 'mean_word_length': 6.158730158730159, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6076230', 'n_tokens_mistral': 871, 'n_tokens_neox': 838, 'n_words': 274}