def _add_lang_to_video(video, props, translated_from=None): if props.get('is_original', False): video.subtitle_language().delete() sub_lang = SubtitleLanguage( video=video, is_original=props.get('is_original', False), is_complete=props.get('is_complete', False), language=props.get('code'), has_version=True, had_version=True, is_forked=True, ) sub_lang.save() num_subs = props.get("num_subs", 0) if not translated_from: _add_subtitles(sub_lang, num_subs) if translated_from: sub_lang.is_original = False sub_lang.is_forked = False sub_lang.standard_language = translated_from sub_lang.save() _copy_subtitles(translated_from, sub_lang, num_subs) for translation_prop in props.get("translations", []): _add_lang_to_video(video, translation_prop, translated_from=sub_lang) sub_lang.is_complete = props.get("is_complete", False) sub_lang.save() from videos.tasks import video_changed_tasks video_changed_tasks.delay(sub_lang.video.id) return sub_lang
def _add_lang_to_video(video, props, translated_from=None): sub_lang = SubtitleLanguage( video=video, is_original = props.get('is_original', False), is_complete = props.get('is_complete', False), language = props.get('code'), has_version=True, had_version=True, is_forked=True, ) sub_lang.save() num_subs = props.get("num_subs", 0) if not translated_from: _add_subtitles(sub_lang, num_subs) if translated_from: sub_lang.is_original = False sub_lang.is_forked = False sub_lang.standard_language = translated_from sub_lang.save() _copy_subtitles(translated_from ,sub_lang, num_subs) for translation_prop in props.get("translations", []): _add_lang_to_video(video, translation_prop, translated_from=sub_lang) sub_lang.update_percent_done() print 'adding lang ', sub_lang sub_lang.save() return sub_lang
def _add_lang_to_video(video, props, translated_from=None): sub_lang = SubtitleLanguage( video=video, is_original=props.get('is_original', False), is_complete=props.get('is_complete', False), language=props.get('code'), has_version=True, had_version=True, is_forked=True, ) sub_lang.save() num_subs = props.get("num_subs", 0) if not translated_from: _add_subtitles(sub_lang, num_subs) if translated_from: sub_lang.is_original = False sub_lang.is_forked = False sub_lang.standard_language = translated_from sub_lang.save() _copy_subtitles(translated_from, sub_lang, num_subs) for translation_prop in props.get("translations", []): _add_lang_to_video(video, translation_prop, translated_from=sub_lang) sub_lang.update_percent_done() sub_lang.save() return sub_lang
def _add_lang_to_video(video, props, translated_from=None): if props.get("is_original", False): video.subtitle_language().delete() sub_lang = SubtitleLanguage( video=video, is_original=props.get("is_original", False), is_complete=props.get("is_complete", False), language=props.get("code"), has_version=True, had_version=True, is_forked=True, ) sub_lang.save() num_subs = props.get("num_subs", 0) if not translated_from: _add_subtitles(sub_lang, num_subs) if translated_from: sub_lang.is_original = False sub_lang.is_forked = False sub_lang.standard_language = translated_from sub_lang.save() _copy_subtitles(translated_from, sub_lang, num_subs) for translation_prop in props.get("translations", []): _add_lang_to_video(video, translation_prop, translated_from=sub_lang) sub_lang.is_complete = props.get("is_complete", False) sub_lang.save() from videos.tasks import video_changed_tasks video_changed_tasks.delay(sub_lang.video.id) return sub_lang
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