當前位置: 首頁>>代碼示例>>Python>>正文


Python SubtitleLanguage.was_complete方法代碼示例

本文整理匯總了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
開發者ID:MechanisM,項目名稱:mirosubs,代碼行數:59,代碼來源:forms.py


注:本文中的videos.models.SubtitleLanguage.was_complete方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。