第一步优化勾选功能

This commit is contained in:
27942
2026-02-05 01:48:46 +08:00
parent 65b01af819
commit 86c642d454
195 changed files with 6720 additions and 6738 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -3435,7 +3435,7 @@ class MainWindow(QMainWindow):
use_batch_upload = self.batch_upload_checkbox.isChecked()
self.log_text.append(f"批量上传模式: {'已勾选' if use_batch_upload else '未勾选'}")
# 获取最大批量数
# 获取最大批量数(单次上限数)
batch_limit = 5 # 默认值
try:
batch_limit_text = self.batch_limit_input.text().strip()
@@ -3445,9 +3445,32 @@ class MainWindow(QMainWindow):
batch_limit = 1
except (ValueError, AttributeError):
batch_limit = 5
self.log_text.append(f"最大批量数: {batch_limit}")
self.log_text.append(f"单次上限数: {batch_limit}")
for user_id, items in grouped_by_user_id.items():
def _skip_expired_and_append(f, f_index, items, related_config_indices, into_videos, into_non_videos, is_video):
"""若定时过期则更新状态并返回 True失败(定时过期)),否则加入列表并返回 False"""
f_time_start = f.get('time_start', '')
if self._is_schedule_time_expired(f_time_start):
self.log_text.append(f" 跳过序号 {f_index}:定时发布时间已过期 ({f_time_start})")
matching_idx = next((it['config_index'] for it in items if it['config'].get('序号') == f_index), None)
if matching_idx is not None:
self._update_table_status(matching_idx, "失败(定时过期)", is_config_index=True)
self.configs[matching_idx]['情况'] = '失败(定时过期)'
self.batch_failed_count = getattr(self, "batch_failed_count", 0) + 1
self.set_status_cards(failed=self.batch_failed_count)
return True
if is_video:
into_videos.append(f)
else:
into_non_videos.append(f)
return False
# 按 config 顺序确定多多ID 的迭代顺序先出现的多多ID 先处理)
def _first_config_index(pair):
return min(it['config_index'] for it in pair[1])
sorted_groups = sorted(grouped_by_user_id.items(), key=_first_config_index)
for user_id, items in sorted_groups:
all_files = []
related_config_indices = []
for item in items:
@@ -3455,158 +3478,114 @@ class MainWindow(QMainWindow):
if item['config_index'] not in related_config_indices:
related_config_indices.append(item['config_index'])
# 按序号排序所有文件
def get_sort_key(f):
try:
return int(f.get('index', '0'))
except (ValueError, TypeError):
return 0
all_files_sorted = sorted(all_files, key=get_sort_key)
# 准备工作线程需要的配置同一个多多ID共用基准配置
first_config = items[0].get('config', {})
# 按序号顺序处理,遇到视频时收集连续视频进行批量上传
i = 0
while i < len(all_files_sorted):
current_file = all_files_sorted[i]
is_video = current_file['path'].is_file() and any(
current_file['path'].suffix.lower() == ext for ext in video_extensions)
if is_video and use_batch_upload:
# 收集从当前位置开始的连续视频按序号顺序最多batch_limit个
video_batch = []
batch_config_indices = []
j = i
while j < len(all_files_sorted) and len(video_batch) < batch_limit:
f = all_files_sorted[j]
f_is_video = f['path'].is_file() and any(
f['path'].suffix.lower() == ext for ext in video_extensions)
if f_is_video:
# 检查定时发布时间是否已过期
f_time_start = f.get('time_start', '')
if self._is_schedule_time_expired(f_time_start):
f_index = f.get('index', '')
self.log_text.append(f" 跳过序号 {f_index}:定时发布时间已过期 ({f_time_start})")
# 更新表格状态为"已跳过"
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == f_index),
None)
if matching_idx is not None:
self._update_table_status(matching_idx, "已跳过(定时过期)", is_config_index=True)
self.configs[matching_idx]['情况'] = '已跳过(定时过期)'
# 跳过视为失败,更新失败统计
self.batch_failed_count = getattr(self, "batch_failed_count", 0) + 1
self.set_status_cards(failed=self.batch_failed_count)
j += 1
continue
video_batch.append(f)
f_index = f.get('index', '')
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == f_index),
related_config_indices[0] if related_config_indices else 0)
if matching_idx not in batch_config_indices:
batch_config_indices.append(matching_idx)
j += 1
else:
# 遇到非视频文件,停止收集
break
if video_batch:
if len(video_batch) > 1:
# 批量上传多个视频
self.batch_task_queue.append({
'type': 'batch_video',
'config': first_config,
'files': video_batch,
'user_id': user_id,
'count': len(video_batch),
'config_indices': batch_config_indices
})
else:
# 只有1个视频单独上传
vid_index = video_batch[0].get('index', '')
matching_config = next(
(it['config'] for it in items if it['config'].get('序号') == vid_index),
first_config)
self.batch_task_queue.append({
'type': 'single_video',
'config': matching_config,
'files': video_batch,
'user_id': user_id,
'count': 1,
'config_indices': batch_config_indices
})
i = j
elif is_video:
# 未勾选批量上传,逐个上传视频
vid_index = current_file.get('index', '')
# 检查定时发布时间是否已过期
f_time_start = current_file.get('time_start', '')
if self._is_schedule_time_expired(f_time_start):
self.log_text.append(f" 跳过序号 {vid_index}:定时发布时间已过期 ({f_time_start})")
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == vid_index),
None)
if matching_idx is not None:
self._update_table_status(matching_idx, "已跳过(定时过期)", is_config_index=True)
self.configs[matching_idx]['情况'] = '已跳过(定时过期)'
# 跳过视为失败,更新失败统计
self.batch_failed_count = getattr(self, "batch_failed_count", 0) + 1
self.set_status_cards(failed=self.batch_failed_count)
if not use_batch_upload:
# 未勾选批量上传按序号一条一条上传先完成当前多多ID的 1,2,3,4 再处理下一个多多ID
i = 0
while i < len(all_files_sorted):
current_file = all_files_sorted[i]
is_video = current_file['path'].is_file() and any(
current_file['path'].suffix.lower() == ext for ext in video_extensions)
f_index = current_file.get('index', '')
if _skip_expired_and_append(current_file, f_index, items, related_config_indices, [], [], is_video):
i += 1
continue
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == vid_index),
(it['config_index'] for it in items if it['config'].get('序号') == f_index),
related_config_indices[0] if related_config_indices else 0)
matching_config = next(
(it['config'] for it in items if it['config'].get('序号') == vid_index),
(it['config'] for it in items if it['config'].get('序号') == f_index),
first_config)
self.batch_task_queue.append({
'type': 'single_video',
'config': matching_config,
'files': [current_file],
'user_id': user_id,
'count': 1,
'config_indices': [matching_idx]
})
if is_video:
self.batch_task_queue.append({
'type': 'single_video',
'config': matching_config,
'files': [current_file],
'user_id': user_id,
'count': 1,
'config_indices': [matching_idx]
})
else:
self.batch_task_queue.append({
'type': 'image_folder',
'config': matching_config,
'files': [current_file],
'user_id': user_id,
'count': 1,
'config_indices': [matching_idx]
})
i += 1
else:
# 图片文件夹
f_idx = current_file.get('index', '')
# 检查定时发布时间是否已过期
f_time_start = current_file.get('time_start', '')
if self._is_schedule_time_expired(f_time_start):
self.log_text.append(f" 跳过序号 {f_idx}:定时发布时间已过期 ({f_time_start})")
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == f_idx),
None)
if matching_idx is not None:
self._update_table_status(matching_idx, "已跳过(定时过期)", is_config_index=True)
self.configs[matching_idx]['情况'] = '已跳过(定时过期)'
# 跳过视为失败,更新失败统计
self.batch_failed_count = getattr(self, "batch_failed_count", 0) + 1
self.set_status_cards(failed=self.batch_failed_count)
i += 1
else:
# 勾选批量上传严格按序号顺序处理。遇到图文立即上传第一次遇到视频时收集该多多ID下全部视频按上限分批上传再继续后续序号图文照常上传
ordered_list = [] # (f, is_video) 按序号顺序,已排除定时过期
for f in all_files_sorted:
is_video = f['path'].is_file() and any(
f['path'].suffix.lower() == ext for ext in video_extensions)
f_index = f.get('index', '')
if _skip_expired_and_append(f, f_index, items, related_config_indices, [], [], is_video):
continue
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == f_idx),
related_config_indices[0])
matching_config = next(
(it['config'] for it in items if it['config'].get('序号') == f_idx),
first_config)
self.batch_task_queue.append({
'type': 'image_folder',
'config': matching_config,
'files': [current_file],
'user_id': user_id,
'count': 1,
'config_indices': [matching_idx]
})
i += 1
ordered_list.append((f, is_video))
videos_in_order = [f for (f, iv) in ordered_list if iv]
videos_emitted = False
for (f, is_video) in ordered_list:
f_index = f.get('index', '')
if not is_video:
matching_idx = next(
(it['config_index'] for it in items if it['config'].get('序号') == f_index),
related_config_indices[0])
matching_config = next(
(it['config'] for it in items if it['config'].get('序号') == f_index),
first_config)
self.batch_task_queue.append({
'type': 'image_folder',
'config': matching_config,
'files': [f],
'user_id': user_id,
'count': 1,
'config_indices': [matching_idx]
})
else:
if not videos_emitted:
for start in range(0, len(videos_in_order), batch_limit):
chunk = videos_in_order[start:start + batch_limit]
batch_config_indices = []
for fc in chunk:
fi = fc.get('index', '')
midx = next((it['config_index'] for it in items if it['config'].get('序号') == fi), None)
if midx is not None and midx not in batch_config_indices:
batch_config_indices.append(midx)
if len(chunk) > 1:
self.batch_task_queue.append({
'type': 'batch_video',
'config': first_config,
'files': chunk,
'user_id': user_id,
'count': len(chunk),
'config_indices': batch_config_indices
})
else:
vid_index = chunk[0].get('index', '')
matching_config = next(
(it['config'] for it in items if it['config'].get('序号') == vid_index),
first_config)
self.batch_task_queue.append({
'type': 'single_video',
'config': matching_config,
'files': chunk,
'user_id': user_id,
'count': 1,
'config_indices': batch_config_indices
})
videos_emitted = True
# 已在该序号前统一发过视频批次,此处跳过
if self.batch_task_queue:
self._process_next_batch_task()

Binary file not shown.

View File

@@ -22,5 +22,5 @@
"top_topics_and_observing_domains": [ ]
} ],
"hex_encoded_hmac_key": "434BF7DBD7DA573B45E0A11AD9045A61B6221D14AE2F9A341E2FEF659AF071F6",
"next_scheduled_calculation_time": "13414862793246926"
"next_scheduled_calculation_time": "13414862793246996"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 354 KiB

After

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 KiB

After

Width:  |  Height:  |  Size: 354 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,3 @@
2026/02/04-20:45:35.466 912c Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/MANIFEST-000001
2026/02/04-20:45:35.467 912c Recovering log #9
2026/02/04-20:45:35.467 912c Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/000009.log
2026/02/05-01:40:46.701 1d58c Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/MANIFEST-000001
2026/02/05-01:40:46.702 1d58c Recovering log #9
2026/02/05-01:40:46.702 1d58c Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/000009.log

View File

@@ -1,3 +1,3 @@
2026/02/04-20:35:48.438 9368 Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/MANIFEST-000001
2026/02/04-20:35:48.438 9368 Recovering log #9
2026/02/04-20:35:48.439 9368 Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/000009.log
2026/02/05-01:38:43.801 1d548 Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/MANIFEST-000001
2026/02/05-01:38:43.802 1d548 Recovering log #9
2026/02/05-01:38:43.802 1d548 Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\File System\Origins/000009.log

View File

@@ -1,3 +1,3 @@
2026/02/04-20:45:38.914 104c Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/MANIFEST-000001
2026/02/04-20:45:38.915 104c Recovering log #3
2026/02/04-20:45:38.916 104c Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/000003.log
2026/02/05-01:40:52.054 1d48c Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/MANIFEST-000001
2026/02/05-01:40:52.055 1d48c Recovering log #3
2026/02/05-01:40:52.056 1d48c Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/000003.log

View File

@@ -1,3 +1,3 @@
2026/02/04-20:35:42.877 53ac Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/MANIFEST-000001
2026/02/04-20:35:42.878 53ac Recovering log #3
2026/02/04-20:35:42.880 53ac Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/000003.log
2026/02/05-01:38:51.717 1b1fc Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/MANIFEST-000001
2026/02/05-01:38:51.717 1b1fc Recovering log #3
2026/02/05-01:38:51.719 1b1fc Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\GCM Store/000003.log

Binary file not shown.

View File

@@ -1,3 +1,3 @@
2026/02/04-20:45:34.814 81a4 Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/MANIFEST-000001
2026/02/04-20:45:34.818 81a4 Recovering log #3
2026/02/04-20:45:34.822 81a4 Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/000003.log
2026/02/05-01:40:46.289 1d470 Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/MANIFEST-000001
2026/02/05-01:40:46.293 1d470 Recovering log #3
2026/02/05-01:40:46.298 1d470 Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/000003.log

View File

@@ -1,3 +1,3 @@
2026/02/04-20:35:40.779 33c Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/MANIFEST-000001
2026/02/04-20:35:40.783 33c Recovering log #3
2026/02/04-20:35:40.786 33c Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/000003.log
2026/02/05-01:38:39.736 1d5dc Reusing MANIFEST C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/MANIFEST-000001
2026/02/05-01:38:39.740 1d5dc Recovering log #3
2026/02/05-01:38:39.743 1d5dc Reusing old log C:\Users\27942\Desktop\codes\haha\user\user_data\Default\Local Storage\leveldb/000003.log

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More