'Entry point for transcript handlers for student_view.
Request GET contains:
(optional) `videoId` for `translation` dispatch.
`is_bumper=1` flag for bumper case.
Dispatches, (HTTP GET):
/translation/[language_id]
/download
/available_translations/
Explanations:
`download`: returns SRT or TXT file.
`translation`: depends on HTTP methods:
Provide translation for requested language, SJSON format is sent back on success,
Proper language_id should be in url.
`available_translations`:
Returns list of languages, for which transcript files exist.
For \'en\' check if SJSON exists. For non-`en` check if SRT file exists.'

@XBlock.handler
def transcript(self, request, dispatch):

    is_bumper = request.GET.get('is_bumper', False)
    transcripts = self.get_transcripts_info(is_bumper)
    if dispatch.startswith('translation'):
        language = dispatch.replace('translation', '').strip('/')
        if (not language):
            log.info('Invalid    /translation    request:    no    language.')
            return Response(status=400)
        if (language not in (['en'] + transcripts['transcripts'].keys())):
            log.info('Video:    transcript    facilities    are    not    available    for    given    language.')
            return Response(status=404)
        if (language != self.transcript_language):
            self.transcript_language = language
        try:
            transcript = self.translation(request.GET.get('videoId', None), transcripts)
        except (TypeError, NotFoundError) as ex:
            log.debug(ex.message)
            return self.get_static_transcript(request, transcripts)
        except (TranscriptException, UnicodeDecodeError, TranscriptsGenerationException) as ex:
            log.info(ex.message)
            response = Response(status=404)
        else:
            response = Response(transcript, headerlist=[('Content-Language', language)])
            response.content_type = Transcript.mime_types['sjson']
    elif (dispatch == 'download'):
        lang = request.GET.get('lang', None)
        try:
            (transcript_content, transcript_filename, transcript_mime_type) = self.get_transcript(transcripts, transcript_format=self.transcript_download_format, lang=lang)
        except (NotFoundError, ValueError, KeyError, UnicodeDecodeError):
            log.debug('Video@download    exception')
            return Response(status=404)
        else:
            response = Response(transcript_content, headerlist=[('Content-Disposition', 'attachment;    filename="{}"'.format(transcript_filename.encode('utf8'))), ('Content-Language', self.transcript_language)], charset='utf8')
            response.content_type = transcript_mime_type
    elif dispatch.startswith('available_translations'):
        available_translations = self.available_translations(transcripts)
        if available_translations:
            response = Response(json.dumps(available_translations))
            response.content_type = 'application/json'
        else:
            response = Response(status=404)
    else:
        log.debug('Dispatch    is    not    allowed')
        response = Response(status=404)
    return response
