def indexing_works_for_userless_versions(self): # for https://www.pivotaltracker.com/story/show/16776381 add_moderation(self.video, self.team, self.user) lang = self.video.subtitle_language() v = SubtitleVersion(language=lang, version_no = lang.subtitleversion_set.all().count(), datetime_started=datetime.now()) v.save() _update_search_index(self.video)#TeamVideo.objects.get(video=self.video, team=self.team))
def _copy_subtitles(fromlang, tolang, maxout=None): version = SubtitleVersion(language=tolang, note="Automagically-copied") version.save() i = 0 for x in fromlang.version().subtitle_set.all(): s = x.duplicate_for(version=version, draft=None) s.save() i += 1 if maxout and maxout < i: break
def _copy_subtitles(fromlang, tolang, maxout=None): version = SubtitleVersion(language=tolang, note="Automagically-copied") version.datetime_started = datetime.datetime.now() version.save() i = 0 for x in fromlang.version().subtitle_set.all(): s = x.duplicate_for(version=version, draft=None) s.subtitle_text = "Sub %s for lang (%s)" % (i, tolang.language) s.save() i += 1 if maxout and maxout == i: break
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
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
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
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
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
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
def _create_trans(video, latest_version=None, lang_code=None, forked=False): translation = SubtitleLanguage() translation.video = video translation.language = lang_code translation.is_original = False translation.is_forked = forked if not forked: translation.standard_language = video.subtitle_language() translation.save() v = SubtitleVersion() v.language = translation if latest_version: v.version_no = latest_version.version_no + 1 else: v.version_no = 1 v.datetime_started = datetime.now() v.save() if latest_version is not None: for s in latest_version.subtitle_set.all(): s.duplicate_for(v).save() return translation