Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
accessibility_movie_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵心治
accessibility_movie_2
Commits
6119b401
Commit
6119b401
authored
Aug 07, 2023
by
陈晓勇(工程师)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add delete methon 4 import excel
parent
0107388b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
7 deletions
+56
-7
detect_with_ocr.py
detect_with_ocr.py
+1
-1
ding_utils.py
ding_utils.py
+3
-1
excel_utils.py
excel_utils.py
+9
-4
main_window.py
main_window.py
+43
-1
No files found.
detect_with_ocr.py
View file @
6119b401
...
@@ -404,7 +404,7 @@ def detect_with_ocr(video_path: str, book_path: str, start_time: float, end_time
...
@@ -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
]
up_b
,
down_b
=
context
.
caption_boundings
[
0
],
context
.
caption_boundings
[
1
]
else
:
else
:
# 此处start_time + 300是为了节省用户调整视频开始时间的功夫(强行跳过前5分钟)
# 此处start_time + 300是为了节省用户调整视频开始时间的功夫(强行跳过前5分钟)
up_b
,
down_b
=
get_position
(
video_path
,
start_time
+
30
0
)
up_b
,
down_b
=
get_position
(
video_path
,
0
)
context
.
caption_boundings
=
[
up_b
,
down_b
]
context
.
caption_boundings
=
[
up_b
,
down_b
]
context
.
detected
=
True
context
.
detected
=
True
...
...
ding_utils.py
View file @
6119b401
...
@@ -9,9 +9,11 @@ import base64
...
@@ -9,9 +9,11 @@ import base64
import
hashlib
import
hashlib
import
urllib.parse
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=a7e6b223bc0a6e4b5e3f64b1570d0c884db0d833592f5e84b020c2896130d659"
# dd_url_prefix = "https://oapi.dingtalk.com/robot/send?access_token=12a5e64b24e7345fed2415c5c2f9101180763e327b21727cd35fdaa3fb274e74"
secret
=
'SEC252452789bc17cfb1e6c973f837426fa0f9fd50c8793239c070e9d3c021d8109'
secret
=
'SEC252452789bc17cfb1e6c973f837426fa0f9fd50c8793239c070e9d3c021d8109'
# secret = "SECb5d68b27bd2e4694667d36c0f91336f3641b3287b945906a83997353f961d415"
def
notify
(
err
):
def
notify
(
err
):
timestamp
=
str
(
round
(
time
.
time
()
*
1000
))
timestamp
=
str
(
round
(
time
.
time
()
*
1000
))
...
...
excel_utils.py
View file @
6119b401
...
@@ -23,7 +23,8 @@ def read_xls(file_path):
...
@@ -23,7 +23,8 @@ def read_xls(file_path):
speed
=
""
speed
=
""
for
col
in
range
(
sheet
.
ncols
):
for
col
in
range
(
sheet
.
ncols
):
cell_value
=
sheet
.
cell_value
(
row
,
col
)
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
:
if
col_index
==
0
:
start_time
=
cell_value
if
cell_value
!=
None
else
""
start_time
=
cell_value
if
cell_value
!=
None
else
""
if
col_index
==
2
:
if
col_index
==
2
:
...
@@ -67,7 +68,8 @@ def read_xlsx(file_path):
...
@@ -67,7 +68,8 @@ def read_xlsx(file_path):
speed
=
""
speed
=
""
for
cell
in
row
:
for
cell
in
row
:
cell_value
=
cell
.
value
cell_value
=
cell
.
value
print
(
cell_value
)
cell_value
=
str
(
cell_value
)
if
cell_value
!=
None
else
""
# print(cell_value)
if
col_index
==
0
:
if
col_index
==
0
:
start_time
=
cell_value
if
cell_value
!=
None
else
""
start_time
=
cell_value
if
cell_value
!=
None
else
""
if
col_index
==
2
:
if
col_index
==
2
:
...
@@ -87,7 +89,7 @@ def read_xlsx(file_path):
...
@@ -87,7 +89,7 @@ def read_xlsx(file_path):
col_index
=
col_index
+
1
col_index
=
col_index
+
1
if
suggest
!=
""
and
aside
!=
""
:
if
suggest
!=
""
and
aside
!=
""
:
new_element
=
Element
(
start_time
,
end_time
,
subtitle
,
suggest
,
aside
,
speed
)
new_element
=
Element
(
start_time
,
end_time
,
subtitle
,
suggest
,
aside
,
speed
)
new_element
.
print_self
()
#
new_element.print_self()
elements
.
append
(
new_element
)
elements
.
append
(
new_element
)
checkLength
(
elements
)
checkLength
(
elements
)
return
elements
return
elements
...
@@ -97,12 +99,15 @@ def checkLength(elements):
...
@@ -97,12 +99,15 @@ def checkLength(elements):
if
int
(
""
.
join
(
filter
(
str
.
isdigit
,
element
.
suggest
)))
<
len
(
element
.
aside
):
if
int
(
""
.
join
(
filter
(
str
.
isdigit
,
element
.
suggest
)))
<
len
(
element
.
aside
):
raise
Exception
(
"旁白字数没有按照推荐要求"
)
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(len(elements))
# print(">>>")
# for element in elements:
# for element in elements:
# element.print_self()
# element.print_self()
# print(type("".join(filter(str.isdigit, element.suggest))))
# print(type("".join(filter(str.isdigit, element.suggest))))
# print(type(element.st_time_sec))
# print(len(element.aside))
# print(len(element.aside))
# print(len(element.st_time_sec))
# arrays = [1,2,3,4,5]
# arrays = [1,2,3,4,5]
# arrays = arrays.pop(2)
# arrays = arrays.pop(2)
...
...
main_window.py
View file @
6119b401
...
@@ -1521,7 +1521,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -1521,7 +1521,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
idx
+=
1
idx
+=
1
return
idx
return
idx
def
removeByCurTime
(
self
,
cur_time
,
aside
):
def
removeByCurTime
(
self
,
cur_time
,
aside
,
remove_flag
=
True
):
"""确认表格中适合cur_time的插入位置
"""确认表格中适合cur_time的插入位置
Args:
Args:
...
@@ -1538,6 +1538,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -1538,6 +1538,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if
float
(
cur_time
)
==
float
(
self
.
projectContext
.
all_elements
[
idx
]
.
st_time_sec
):
if
float
(
cur_time
)
==
float
(
self
.
projectContext
.
all_elements
[
idx
]
.
st_time_sec
):
if
aside
!=
self
.
projectContext
.
all_elements
[
idx
]
.
aside
:
if
aside
!=
self
.
projectContext
.
all_elements
[
idx
]
.
aside
:
print
(
"移除旧的,再新增"
)
print
(
"移除旧的,再新增"
)
if
remove_flag
:
self
.
projectContext
.
all_elements
.
pop
(
idx
)
self
.
projectContext
.
all_elements
.
pop
(
idx
)
else
:
else
:
same_flag
=
True
same_flag
=
True
...
@@ -1597,6 +1598,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -1597,6 +1598,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
speed (str): 旁白语速
speed (str): 旁白语速
"""
"""
# 注意,这里需要用同一对象,不能生成多个Element
# 注意,这里需要用同一对象,不能生成多个Element
self
.
check_org_aside
(
elements
)
for
new_element
in
elements
:
for
new_element
in
elements
:
start_time
=
new_element
.
st_time_sec
start_time
=
new_element
.
st_time_sec
suggest
=
new_element
.
suggest
suggest
=
new_element
.
suggest
...
@@ -1637,6 +1639,46 @@ class MainWindow(QMainWindow, Ui_MainWindow):
...
@@ -1637,6 +1639,46 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self
.
refresh_tab_slot
()
self
.
refresh_tab_slot
()
self
.
prompt_dialog
.
show_with_msg
(
"操作成功!!请查看变化"
)
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
):
def
getSeconds
(
self
,
time_str
):
hours
,
minutes
=
map
(
int
,
time_str
.
split
(
'.'
))
hours
,
minutes
=
map
(
int
,
time_str
.
split
(
'.'
))
seconds
=
hours
*
3600
+
minutes
*
60
seconds
=
hours
*
3600
+
minutes
*
60
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment