1- # 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
2- # 1. 不得用于任何商业用途。
3- # 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
4- # 3. 不得进行大规模爬取或对平台造成运营干扰。
5- # 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
1+ # 声明:本代码仅供学习和研究目的使用。使用者应遵守以下原则:
2+ # 1. 不得用于任何商业用途。
3+ # 2. 使用时应遵守目标平台的使用条款和robots.txt规则。
4+ # 3. 不得进行大规模爬取或对平台造成运营干扰。
5+ # 4. 应合理控制请求频率,避免给目标平台带来不必要的负担。
66# 5. 不得用于任何非法或不当的用途。
7- #
8- # 详细许可条款请参阅项目根目录下的LICENSE文件。
9- # 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
7+ #
8+ # 详细许可条款请参阅项目根目录下的LICENSE文件。
9+ # 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
1010
1111
1212# -*- coding: utf-8 -*-
@@ -27,15 +27,16 @@ class BiliStoreFactory:
2727 STORES = {
2828 "csv" : BiliCsvStoreImplement ,
2929 "db" : BiliDbStoreImplement ,
30- "json" : BiliJsonStoreImplement
30+ "json" : BiliJsonStoreImplement ,
3131 }
3232
3333 @staticmethod
3434 def create_store () -> AbstractStore :
3535 store_class = BiliStoreFactory .STORES .get (config .SAVE_DATA_OPTION )
3636 if not store_class :
3737 raise ValueError (
38- "[BiliStoreFactory.create_store] Invalid save option only supported csv or db or json ..." )
38+ "[BiliStoreFactory.create_store] Invalid save option only supported csv or db or json ..."
39+ )
3940 return store_class ()
4041
4142
@@ -67,7 +68,8 @@ async def update_bilibili_video(video_item: Dict):
6768 "source_keyword" : source_keyword_var .get (),
6869 }
6970 utils .logger .info (
70- f"[store.bilibili.update_bilibili_video] bilibili video id:{ video_id } , title:{ save_content_item .get ('title' )} " )
71+ f"[store.bilibili.update_bilibili_video] bilibili video id:{ video_id } , title:{ save_content_item .get ('title' )} "
72+ )
7173 await BiliStoreFactory .create_store ().store_content (content_item = save_content_item )
7274
7375
@@ -87,7 +89,8 @@ async def update_up_info(video_item: Dict):
8789 "is_official" : video_item_card .get ("official_verify" ).get ("type" ),
8890 }
8991 utils .logger .info (
90- f"[store.bilibili.update_up_info] bilibili user_id:{ video_item_card .get ('mid' )} " )
92+ f"[store.bilibili.update_up_info] bilibili user_id:{ video_item_card .get ('mid' )} "
93+ )
9194 await BiliStoreFactory .create_store ().store_creator (creator = saver_up_info )
9295
9396
@@ -103,6 +106,7 @@ async def update_bilibili_video_comment(video_id: str, comment_item: Dict):
103106 parent_comment_id = str (comment_item .get ("parent" , 0 ))
104107 content : Dict = comment_item .get ("content" )
105108 user_info : Dict = comment_item .get ("member" )
109+ like_count : int = comment_item .get ("like" , 0 )
106110 save_comment_item = {
107111 "comment_id" : comment_id ,
108112 "parent_comment_id" : parent_comment_id ,
@@ -115,10 +119,12 @@ async def update_bilibili_video_comment(video_id: str, comment_item: Dict):
115119 "sign" : user_info .get ("sign" ),
116120 "avatar" : user_info .get ("avatar" ),
117121 "sub_comment_count" : str (comment_item .get ("rcount" , 0 )),
122+ "like_count" : like_count ,
118123 "last_modify_ts" : utils .get_current_timestamp (),
119124 }
120125 utils .logger .info (
121- f"[store.bilibili.update_bilibili_video_comment] Bilibili video comment: { comment_id } , content: { save_comment_item .get ('content' )} " )
126+ f"[store.bilibili.update_bilibili_video_comment] Bilibili video comment: { comment_id } , content: { save_comment_item .get ('content' )} "
127+ )
122128 await BiliStoreFactory .create_store ().store_comment (comment_item = save_comment_item )
123129
124130
@@ -131,7 +137,12 @@ async def store_video(aid, video_content, extension_file_name):
131137 extension_file_name:
132138 """
133139 await BilibiliVideo ().store_video (
134- {"aid" : aid , "video_content" : video_content , "extension_file_name" : extension_file_name })
140+ {
141+ "aid" : aid ,
142+ "video_content" : video_content ,
143+ "extension_file_name" : extension_file_name ,
144+ }
145+ )
135146
136147
137148async def batch_update_bilibili_creator_fans (creator_info : Dict , fans_list : List [Dict ]):
@@ -144,10 +155,14 @@ async def batch_update_bilibili_creator_fans(creator_info: Dict, fans_list: List
144155 "sign" : fan_item .get ("sign" ),
145156 "avatar" : fan_item .get ("face" ),
146157 }
147- await update_bilibili_creator_contact (creator_info = creator_info , fan_info = fan_info )
158+ await update_bilibili_creator_contact (
159+ creator_info = creator_info , fan_info = fan_info
160+ )
148161
149162
150- async def batch_update_bilibili_creator_followings (creator_info : Dict , followings_list : List [Dict ]):
163+ async def batch_update_bilibili_creator_followings (
164+ creator_info : Dict , followings_list : List [Dict ]
165+ ):
151166 if not followings_list :
152167 return
153168 for following_item in followings_list :
@@ -157,10 +172,14 @@ async def batch_update_bilibili_creator_followings(creator_info: Dict, following
157172 "sign" : following_item .get ("sign" ),
158173 "avatar" : following_item .get ("face" ),
159174 }
160- await update_bilibili_creator_contact (creator_info = following_info , fan_info = creator_info )
175+ await update_bilibili_creator_contact (
176+ creator_info = following_info , fan_info = creator_info
177+ )
161178
162179
163- async def batch_update_bilibili_creator_dynamics (creator_info : Dict , dynamics_list : List [Dict ]):
180+ async def batch_update_bilibili_creator_dynamics (
181+ creator_info : Dict , dynamics_list : List [Dict ]
182+ ):
164183 if not dynamics_list :
165184 return
166185 for dynamic_item in dynamics_list :
@@ -183,7 +202,9 @@ async def batch_update_bilibili_creator_dynamics(creator_info: Dict, dynamics_li
183202 "total_forwards" : dynamic_forward ,
184203 "total_liked" : dynamic_like ,
185204 }
186- await update_bilibili_creator_dynamic (creator_info = creator_info , dynamic_info = dynamic_info )
205+ await update_bilibili_creator_dynamic (
206+ creator_info = creator_info , dynamic_info = dynamic_info
207+ )
187208
188209
189210async def update_bilibili_creator_contact (creator_info : Dict , fan_info : Dict ):
0 commit comments