本文整理匯總了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