3535def refresh_modrinth_with_modify_date () -> bool :
3636 log .info ("Start fetching expired Modrinth data." )
3737
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 ()
4070
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 ,
5975 )
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." )
7678
7779 return True
7880
@@ -141,6 +143,7 @@ def sync_modrinth_queue() -> bool:
141143
142144 return True
143145
146+
144147def sync_modrinth_by_search ():
145148 """
146149 从搜索接口拉取 modrinth 的 new project id
@@ -164,7 +167,9 @@ def sync_modrinth_by_search():
164167 projects_detail_info .append (result )
165168
166169 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+ )
168173
169174 if config .telegram_bot :
170175 notice = SearchSyncNotification (
0 commit comments