提交 57caaa36 编写于 作者: F feilong

添加是否覆盖询问

上级 69a74f45
......@@ -75,6 +75,8 @@ class Top:
self.y_label = output.y_label
self.month_count = output.month_count
self.override_all_gif = False
def build(self):
self.__load_dataframe()
# self.__exit()
......@@ -94,16 +96,31 @@ class Top:
self.df = df[i:end]
filename = os.path.join(self.output, f'{j}.{self.ext}')
# self.__build_race(filename)
self.__build_race(filename)
gifs.append(filename)
i += step
j += 1
# 合并 gif 生成mp4
all = f'{self.output}.mp4'
# concat_gif_list(gifs, all)
if os.path.exists(all):
ret = input(f"文件:{all}已存在,是否覆盖?[y/n]:")
if ret == 'y':
concat_gif_list(gifs, all)
else:
concat_gif_list(gifs, all)
# 合成 mp4 和 音频
if self.audio is not None:
all_with_audio = f'{self.output}_with_audio.mp4'
merge_video_audio(all, self.audio, all_with_audio)
if os.path.exists(all_with_audio):
ret = input(f"文件:{all_with_audio}已存在,是否覆盖?[y/n]:")
if ret == 'y':
merge_video_audio(all, self.audio, all_with_audio)
else:
merge_video_audio(all, self.audio, all_with_audio)
else:
print(f"音频文件{self.audio}不存在,请自行准备一个合适的音频文件。")
def __load_dataframe(self):
if self.input_type == 'json_dir':
......@@ -178,6 +195,23 @@ class Top:
matplotlib.rc("font", family='FZFangSong-Z02')
def __build_race(self, filename):
build = False
if self.override_all_gif:
build = True
else:
if os.path.exists(filename):
ret = input(f"文件:{filename}已存在,是否覆盖?[a/y/n]:")
if ret == 'y':
build = True
elif ret == 'a':
build = True
self.override_all_gif = True
else:
build = True
if not build:
return
bar_chart_race(
df=self.df,
filename=filename,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册