本文整理汇总了Python中videos.models.SubtitleLanguage.was_complete方法的典型用法代码示例。如果您正苦于以下问题:Python SubtitleLanguage.was_complete方法的具体用法?Python SubtitleLanguage.was_complete怎么用?Python SubtitleLanguage.was_complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类videos.models.SubtitleLanguage
的用法示例。
在下文中一共展示了SubtitleLanguage.was_complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_subtitles
# 需要导入模块: from videos.models import SubtitleLanguage [as 别名]
# 或者: from videos.models.SubtitleLanguage import was_complete [as 别名]
def save_subtitles(self, parser):
video = self.cleaned_data['video']
key = str(uuid4()).replace('-', '')
video._make_writelock(self.user, key)
video.save()
if not video.has_original_language():
self._save_original_language(
video, self.cleaned_data['video_language'])
language = video.subtitle_language(self.cleaned_data['language'])
if not language:
language = SubtitleLanguage(video=video, is_original=False, is_forked=True)
language.language = self.cleaned_data['language']
language.save()
try:
old_version = language.subtitleversion_set.all()[:1].get()
version_no = old_version.version_no + 1
except ObjectDoesNotExist:
old_version = None
version_no = 0
if not self.is_version_same(old_version, parser):
version = SubtitleVersion(
language=language, version_no=version_no,
datetime_started=datetime.now(), user=self.user,
note=u'Uploaded', is_forked=True, time_change=1, text_change=1)
version.save()
ids = []
for i, item in enumerate(parser):
id = int(random.random()*10e12)
while id in ids:
id = int(random.random()*10e12)
ids.append(id)
caption = Subtitle(**item)
caption.version = version
caption.subtitle_id = str(id)
caption.subtitle_order = i+1
caption.save()
version.save()
version.update_percent_done()
language.was_complete = True
language.is_complete = True
language.save()
video.release_writelock()
video.save()
return language