Forráskód Böngészése

2024-06-06
上线了新etl, 目的是解决封面下载失败的问题

取消了自动加白名单的功能

罗俊辉 11 hónapja
szülő
commit
2aca6d8251
1 módosított fájl, 11 hozzáadás és 11 törlés
  1. 11 11
      applications/functions/async_etl.py

+ 11 - 11
applications/functions/async_etl.py

@@ -201,9 +201,12 @@ class AsyncETL(object):
         """
         headers = self.request_header(type_="cover")
         response = requests.get(url=self.cover_url, headers=headers)
-        with open(file_path, "wb") as f:
-            f.write(response.content)
-        return file_path
+        if b"<html>" in response.content:
+            return None
+        else:
+            with open(file_path, "wb") as f:
+                f.write(response.content)
+            return file_path
 
     async def etl_deal(self):
         """
@@ -219,15 +222,12 @@ class AsyncETL(object):
         oss_video = await upload_to_oss(
             local_video_path=file_path,
         )
-        # 读取cover, 若img是html格式,则不上传
-        with open(cover_path, "rb") as f:
-            img_data = f.read()
-        if b"<html>" in img_data:
-            oss_cover = None
-        else:
+        if cover_path:
             oss_cover = await upload_to_oss(
-                local_video_path=cover_path
-            )
+                    local_video_path=cover_path
+                )
+        else:
+            oss_cover = None
         # publish to pq
         result = await self.publish_by__request(
             video_path=oss_video,