|
@@ -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,
|