Browse Source

merge master

luojunhui 1 tháng trước cách đây
mục cha
commit
967f7dc98a

+ 37 - 0
tasks/crawler_channel_account_videos.py

@@ -2,6 +2,7 @@
 @author: luojunhui
 @author: luojunhui
 @tool: pycharm && deepseek
 @tool: pycharm && deepseek
 """
 """
+import json
 
 
 from applications.db import DatabaseConnector
 from applications.db import DatabaseConnector
 from config import long_articles_config
 from config import long_articles_config
@@ -16,3 +17,39 @@ class CrawlerChannelAccountVideos:
         self.db_client = DatabaseConnector(db_config=long_articles_config)
         self.db_client = DatabaseConnector(db_config=long_articles_config)
         self.db_client.connect()
         self.db_client.connect()
 
 
+    def get_channel_account_list(self):
+        """
+        get channel account list from database
+        """
+        return
+
+    def crawler_each_account(self, channel_account_id: str, channel_account_name: str):
+        """
+        get channel account videos
+        """
+        response = get_channel_account_videos(channel_account_id)
+        if response['ret'] == 200:
+            response_data = response['data']
+            last_buffer = response_data['lastBuffer']
+            continue_flag = response_data['continueFlag']
+            video_list = response_data['object']
+            for video in video_list[:1]:
+                video_id = video['id']
+                account_name = video['nickname']
+                object_desc = video['objectDesc']
+                title = object_desc['description']
+                media = object_desc['media'][0]
+                url = media['Url']
+                decode_key = media['decodeKey']
+                url_token = media['urlToken']
+                download_url = url + url_token
+                print(json.dumps(video, ensure_ascii=False, indent=4))
+        else:
+            print(f"crawler channel account {channel_account_name} videos failed")
+            return
+
+
+if __name__ == '__main__':
+    crawler_channel_account_videos = CrawlerChannelAccountVideos()
+    account_id = 'v2_060000231003b20faec8c5eb8a1cc3d1c902e43cb0774ec288165f96c810e3553f5069c92d73@finder'
+    crawler_channel_account_videos.crawler_each_account(channel_account_id=account_id, channel_account_name="")