|
@@ -4,6 +4,7 @@ from pathlib import Path
|
|
import zipfile
|
|
import zipfile
|
|
from io import BytesIO
|
|
from io import BytesIO
|
|
from chardet.universaldetector import UniversalDetector
|
|
from chardet.universaldetector import UniversalDetector
|
|
|
|
+import pandas as pd
|
|
try:
|
|
try:
|
|
from app.aianchor.config import *
|
|
from app.aianchor.config import *
|
|
except ImportError:
|
|
except ImportError:
|
|
@@ -14,6 +15,10 @@ DEFAULT_ENCODING = "utf-8"
|
|
class VideoMakerError(Exception):
|
|
class VideoMakerError(Exception):
|
|
pass
|
|
pass
|
|
|
|
|
|
|
|
+def json2table(filename: str):
|
|
|
|
+ table = pd.read_json(filename)
|
|
|
|
+ print(table)
|
|
|
|
+
|
|
def guess_codec(filenames: list) -> str:
|
|
def guess_codec(filenames: list) -> str:
|
|
codec_detector = UniversalDetector()
|
|
codec_detector = UniversalDetector()
|
|
for filename in filenames:
|
|
for filename in filenames:
|
|
@@ -51,6 +56,7 @@ def check_zip(zip_filepath:str):
|
|
# excel 裡的圖檔跟zip裡的檔案要一致
|
|
# excel 裡的圖檔跟zip裡的檔案要一致
|
|
if not table.loc[i, ['素材']].isna().item():
|
|
if not table.loc[i, ['素材']].isna().item():
|
|
img = table.loc[i, ['素材']].item()
|
|
img = table.loc[i, ['素材']].item()
|
|
|
|
+ img = str(img)
|
|
img_files = [x.strip() for x in img.split(',')]
|
|
img_files = [x.strip() for x in img.split(',')]
|
|
for img in img_files:
|
|
for img in img_files:
|
|
if Path(img).suffix:
|
|
if Path(img).suffix:
|
|
@@ -133,7 +139,7 @@ def check_and_extract_zip(zip_filepath:str, working_dirpath:str):
|
|
elif len(target_filenames) > 1:
|
|
elif len(target_filenames) > 1:
|
|
raise VideoMakerError(f'too many same name img files as {img} in zip')
|
|
raise VideoMakerError(f'too many same name img files as {img} in zip')
|
|
|
|
|
|
- save_filepath = working_dir_Path / input_dir / true_filenames[target_filenames[0][1]][0]
|
|
|
|
|
|
+ save_filepath = working_dir_Path / input_dir / img_dir / true_filenames[target_filenames[0][1]][0]
|
|
if not save_filepath.exists():
|
|
if not save_filepath.exists():
|
|
with open(save_filepath, 'wb') as output_file: # 建立並開啟新檔案
|
|
with open(save_filepath, 'wb') as output_file: # 建立並開啟新檔案
|
|
with zf.open(filenames[target_filenames[0][1]], 'r') as origin_file: # 開啟原檔案
|
|
with zf.open(filenames[target_filenames[0][1]], 'r') as origin_file: # 開啟原檔案
|