add delete methon 4 import excel

parent 0107388b
......@@ -404,7 +404,7 @@ def detect_with_ocr(video_path: str, book_path: str, start_time: float, end_time
up_b, down_b = context.caption_boundings[0], context.caption_boundings[1]
else:
# 此处start_time + 300是为了节省用户调整视频开始时间的功夫(强行跳过前5分钟)
up_b, down_b = get_position(video_path, start_time +300)
up_b, down_b = get_position(video_path, 0)
context.caption_boundings = [up_b, down_b]
context.detected = True
......
......@@ -9,9 +9,11 @@ import base64
import hashlib
import urllib.parse
user_name = "盲"
user_name = "盲文出版社"
dd_url_prefix = "https://oapi.dingtalk.com/robot/send?access_token=a7e6b223bc0a6e4b5e3f64b1570d0c884db0d833592f5e84b020c2896130d659"
# dd_url_prefix = "https://oapi.dingtalk.com/robot/send?access_token=12a5e64b24e7345fed2415c5c2f9101180763e327b21727cd35fdaa3fb274e74"
secret = 'SEC252452789bc17cfb1e6c973f837426fa0f9fd50c8793239c070e9d3c021d8109'
# secret = "SECb5d68b27bd2e4694667d36c0f91336f3641b3287b945906a83997353f961d415"
def notify(err):
timestamp = str(round(time.time() * 1000))
......
......@@ -23,7 +23,8 @@ def read_xls(file_path):
speed = ""
for col in range(sheet.ncols):
cell_value = sheet.cell_value(row, col)
print(cell_value)
cell_value = str(cell_value) if cell_value != None else ""
# print(cell_value)
if col_index == 0:
start_time = cell_value if cell_value != None else ""
if col_index == 2:
......@@ -67,7 +68,8 @@ def read_xlsx(file_path):
speed = ""
for cell in row:
cell_value = cell.value
print(cell_value)
cell_value = str(cell_value) if cell_value != None else ""
# print(cell_value)
if col_index == 0:
start_time = cell_value if cell_value != None else ""
if col_index == 2:
......@@ -87,7 +89,7 @@ def read_xlsx(file_path):
col_index = col_index + 1
if suggest != "" and aside != "":
new_element = Element(start_time, end_time, subtitle, suggest, aside, speed)
new_element.print_self()
# new_element.print_self()
elements.append(new_element)
checkLength(elements)
return elements
......@@ -97,12 +99,15 @@ def checkLength(elements):
if int("".join(filter(str.isdigit, element.suggest))) < len(element.aside):
raise Exception("旁白字数没有按照推荐要求")
# elements = read_xlsx("C:/Users/AIA/Desktop/1/3/1.xlsx")
# elements = read_xlsx("C:/Users/AIA/Desktop/1/121/1.xlsx")
# print(len(elements))
# print(">>>")
# for element in elements:
# element.print_self()
# print(type("".join(filter(str.isdigit, element.suggest))))
# print(type(element.st_time_sec))
# print(len(element.aside))
# print(len(element.st_time_sec))
# arrays = [1,2,3,4,5]
# arrays = arrays.pop(2)
......
......@@ -1521,7 +1521,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
idx += 1
return idx
def removeByCurTime(self, cur_time, aside):
def removeByCurTime(self, cur_time, aside, remove_flag=True):
"""确认表格中适合cur_time的插入位置
Args:
......@@ -1538,7 +1538,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if float(cur_time) == float(self.projectContext.all_elements[idx].st_time_sec):
if aside != self.projectContext.all_elements[idx].aside:
print("移除旧的,再新增")
self.projectContext.all_elements.pop(idx)
if remove_flag:
self.projectContext.all_elements.pop(idx)
else:
same_flag = True
break
......@@ -1597,6 +1598,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
speed (str): 旁白语速
"""
# 注意,这里需要用同一对象,不能生成多个Element
self.check_org_aside(elements)
for new_element in elements:
start_time = new_element.st_time_sec
suggest = new_element.suggest
......@@ -1637,6 +1639,46 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.refresh_tab_slot()
self.prompt_dialog.show_with_msg("操作成功!!请查看变化")
def check_org_aside(self, elements):
start_time_map = {}
remove_list = []
# new_list = []
for new_element in elements:
start_time_map[new_element.st_time_sec] = ""
# print(">>>>>>remove start")
for aside in self.projectContext.aside_list: # 使用切片复制整个列表
aside.print_self()
if aside.aside != None and aside.aside != "" and aside.st_time_sec not in start_time_map:
# self.projectContext.aside_list.remove(aside)
remove_list.append(aside)
# print("")
# else:
# new_list.append(aside)
# self.projectContext.aside_list=new_list
# self.refresh_tab_slot(True)
print(">>>>>>remove end")
for item in remove_list:
item.print_self()
idx = 0
del_row = 0
while idx < len(self.projectContext.aside_list):
if item.st_time_sec == self.projectContext.aside_list[idx].st_time_sec:
self.projectContext.aside_list.pop(idx)
del_row, _ = self.removeByCurTime(item.st_time_sec, item.aside, False)
break
idx += 1
self.pb_tableWidget_idx = idx
self.refresh_tab_slot()
self.del_line_operation_slot(row=(del_row + 1))
# for aside in self.projectContext.aside_list:
# if item.st_time_sec == aside.st_time_sec:
# self.projectContext.aside_list.remove(aside)
# self.refresh_tab_slot()
# break
# self.projectContext.aside_list.remove(item)
# self.refresh_tab_slot()
def getSeconds(self, time_str):
hours, minutes = map(int, time_str.split('.'))
seconds = hours * 3600 + minutes * 60
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment