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 _create_versions(self, lang, num_versions=1, num_subs=None, user=None):
            versions = []
            lang = refresh_obj(lang)
            for num in xrange(0, num_versions):
                v = SubtitleVersion(language=lang)
                if lang.subtitleversion_set.all().count() > 0:
                    v.version_no = lang.subtitleversion_set.all()[0].version_no + 1
                else:

                    v.version_no = 1    
                v.datetime_started  = datetime.now()
                v.user = user or self.user or User.objects.all()[0]
                v.save()
                versions.append(v)
                for i in xrange(0,3):
                    s = Subtitle(version=v, subtitle_text="%s%s%s" % (lang.pk, v.version_no, i), subtitle_order=i, subtitle_id="%s-%s-"  % (v.pk, i))
                    s.save()
            return versions
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
Esempio n. 4
0
        def _make_subs(self, lang, num=10):
            version_no = 0
            if lang.subtitleversion_set.all().exists():
                version_no = lang.subtitleversion_set.all()[0].version_no + 1
            v = SubtitleVersion(language=lang, is_forked=False,
                                datetime_started=datetime.now(),
                                version_no=version_no)
            v.save()
            for x  in xrange(0, num):
                subtitle = Subtitle(
                    subtitle_id = str(x),
                    subtitle_order = x,
                    subtitle_text = "Sub %s for %s" % ( x, lang),
                    start_time = x,
                    end_time = x + 0.9

                )
                subtitle.save()
            return v
Esempio n. 5
0
        def _make_subs(self, lang, num=10):
            v = SubtitleVersion(language=lang, is_forked=False, datetime_started=datetime.now())
            try:
                version_no  = lang.subtitleversion_set.all()[:1].get().version_no + 1
            except SubtitleVersion.DoesNotExist:
                version_no = 0

            v.version_no = version_no
            v.save()
            for x  in xrange(0, num):
                subtitle = Subtitle(
                    subtitle_id = str(x),
                    subtitle_order = x,
                    subtitle_text = "Sub %s for %s" % ( x, lang),
                    start_time = x,
                    end_time = x + 0.9
                )
                subtitle.save()
            return v
Esempio n. 6
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