35
35
def refresh_modrinth_with_modify_date () -> bool :
36
36
log .info ("Start fetching expired Modrinth data." )
37
37
38
- if config .sync_modrinth :
39
- modrinth_expired_data , modrinth_removed_data = fetch_expired_and_removed_modrinth_data ()
38
+ modrinth_expired_data , modrinth_removed_data = (
39
+ fetch_expired_and_removed_modrinth_data ()
40
+ )
41
+
42
+ log .info (
43
+ f"Modrinth expired data fetched: { len (modrinth_expired_data )} , removed data: { len (modrinth_removed_data )} "
44
+ )
45
+
46
+ # 删除已经源删除的 modrinth 数据
47
+ if modrinth_removed_data :
48
+ log .info (f"Start removing modrinth data: { len (modrinth_removed_data )} " )
49
+ remove_projects (modrinth_removed_data )
50
+ log .info (f"Removed { len (modrinth_removed_data )} modrinth data." )
51
+ log .debug (f"Modrinth removed data: { modrinth_removed_data } " )
52
+
53
+ # 刷新过期的 modrinth 数据
54
+ log .info ("Start syncing Modrinth expired data..." )
55
+ modrinth_pause_event .set ()
56
+ modrinth_pool , modrinth_futures = create_tasks_pool (
57
+ sync_project , # 需要 ProjectDetail 返回值
58
+ modrinth_expired_data ,
59
+ MAX_WORKERS ,
60
+ "refresh_modrinth" ,
61
+ )
62
+
63
+ projects_detail_info = []
64
+ for future in as_completed (modrinth_futures ):
65
+ result = future .result ()
66
+ if result :
67
+ projects_detail_info .append (result )
68
+ else :
69
+ modrinth_pool .shutdown ()
40
70
41
- log .info (f"Modrinth expired data fetched: { len (modrinth_expired_data )} , removed data: { len (modrinth_removed_data )} " )
42
-
43
- # 删除已经源删除的 modrinth 数据
44
- if modrinth_removed_data :
45
- log .info (f"Start removing modrinth data: { len (modrinth_removed_data )} " )
46
- remove_projects (modrinth_removed_data )
47
- log .info (f"Removed { len (modrinth_removed_data )} modrinth data." )
48
- log .debug (f"Modrinth removed data: { modrinth_removed_data } " )
49
-
50
-
51
- # 刷新过期的 modrinth 数据
52
- log .info ("Start syncing Modrinth expired data..." )
53
- modrinth_pause_event .set ()
54
- modrinth_pool , modrinth_futures = create_tasks_pool (
55
- sync_project , # 需要 ProjectDetail 返回值
56
- modrinth_expired_data ,
57
- MAX_WORKERS ,
58
- "refresh_modrinth" ,
71
+ if config .telegram_bot :
72
+ notification = RefreshNotification (
73
+ platform = Platform .MODRINTH ,
74
+ projects_detail_info = projects_detail_info ,
59
75
)
60
-
61
- projects_detail_info = []
62
- for future in as_completed (modrinth_futures ):
63
- result = future .result ()
64
- if result :
65
- projects_detail_info .append (result )
66
- else :
67
- modrinth_pool .shutdown ()
68
-
69
- if config .telegram_bot :
70
- notification = RefreshNotification (
71
- platform = Platform .MODRINTH ,
72
- projects_detail_info = projects_detail_info ,
73
- )
74
- notification .send_to_telegram ()
75
- log .info ("Modrinth refresh message sent to telegram." )
76
+ notification .send_to_telegram ()
77
+ log .info ("Modrinth refresh message sent to telegram." )
76
78
77
79
return True
78
80
@@ -141,6 +143,7 @@ def sync_modrinth_queue() -> bool:
141
143
142
144
return True
143
145
146
+
144
147
def sync_modrinth_by_search ():
145
148
"""
146
149
从搜索接口拉取 modrinth 的 new project id
@@ -164,7 +167,9 @@ def sync_modrinth_by_search():
164
167
projects_detail_info .append (result )
165
168
166
169
pool .shutdown ()
167
- log .info (f"Modrinth sync new project by search finished, total: { len (new_project_ids )} " )
170
+ log .info (
171
+ f"Modrinth sync new project by search finished, total: { len (new_project_ids )} "
172
+ )
168
173
169
174
if config .telegram_bot :
170
175
notice = SearchSyncNotification (
0 commit comments