Browse Source

match -- if else

luojunhui 5 months ago
parent
commit
f8bd73384f
2 changed files with 13 additions and 1 deletions
  1. 2 1
      applications/etl_function/__init__.py
  2. 11 0
      tasks/newContentIdTask.py

+ 2 - 1
applications/etl_function/__init__.py

@@ -131,7 +131,8 @@ async def download_video(file_path, platform, video_url, download_type="video"):
                             await f.write(chunk)
 
             else:
-                print(response.status)
+                print("下载失败")
+                return False
     return file_path
 
 

+ 11 - 0
tasks/newContentIdTask.py

@@ -520,6 +520,17 @@ class NewContentIdTask(object):
                         platform=params['platform'],
                         video_url=params['video_url']
                     )
+                    if not file_path:
+                        update_sql = f"""
+                                            UPDATE {self.article_crawler_video_table}
+                                            SET download_status = %s
+                                            WHERE id = %s;
+                                            """
+                        await self.mysql_client.async_insert(
+                            sql=update_sql,
+                            params=(VIDEO_DOWNLOAD_FAIL_STATUS, params['id'])
+                        )
+                        return False
                     # download cover
                     cover_path = await download_cover(
                         file_path=local_cover_path,