Esempio n. 1
0
def _add_subtitles(sub_lang, num_subs, translated_from=None):
    version = SubtitleVersion(language=sub_lang, note="Automagically-created")
    version.save()
    for i in xrange(0, num_subs):
        subtitle = Subtitle(version=version,
                            subtitle_id="%s" % i,
                            subtitle_order=i,
             subtitle_text = "Sub %s for lang (%s)" % (i, sub_lang.language))
        if not translated_from:
             subtitle.start_time=i * 1.0
             subtitle.end_time =i + 0.8
             
        else:
            subtitle.subtitle_text += " translated from (%s)" % (translated_from)
        subtitle.save()
    return version    
Esempio n. 2
0
def _add_subtitles(sub_lang, num_subs, translated_from=None):
    version = SubtitleVersion(language=sub_lang, note="Automagically-created")
    version.save()
    for i in xrange(0, num_subs):
        subtitle = Subtitle(version=version,
                            subtitle_id="%s" % i,
                            subtitle_order=i,
                            subtitle_text="Sub %s for lang (%s)" %
                            (i, sub_lang.language))
        if not translated_from:
            subtitle.start_time = i * 1.0
            subtitle.end_time = i + 0.8

        else:
            subtitle.subtitle_text += " translated from (%s)" % (
                translated_from)
        subtitle.save()
    return version
Esempio n. 3
0
def _append_subs(version,
                 num_subs=2,
                 include_timing=False,
                 make_new_version=True):
    if make_new_version:
        version = SubtitleVersion(version_no=version.version_no + 1,
                                  language=version.language)
    if include_timing:
        last = version.ordered_subtitles()[-1]
        start_time = last.end_time + 1
    for i in range(0, num_subs):
        subtitle = Subtitle(version=version,
                            subtitle_id="%s" % i,
                            subtitle_order=i,
                            subtitle_text="Sub %s for lang (%s)" %
                            (i, version.language.language))
        if include_timing:
            subtitle.start_time = i * 1.0 + start_time
            subtitle.end_time = i + 0.8 + start_time