qgyd2021 commited on
Commit
3ed9b75
·
1 Parent(s): 24f4fed
toolbox/douyin/video/download.py CHANGED
@@ -89,6 +89,9 @@ class VideoDownload(DouyinClient):
89
  raise AssertionError(f"request failed, status_code: {response.status_code}, text: {response.text}")
90
  js = response.json()
91
  aweme_list = js["aweme_list"]
 
 
 
92
 
93
  result = list()
94
  for aweme in aweme_list:
@@ -146,7 +149,7 @@ class VideoDownload(DouyinClient):
146
  "duration": duration,
147
  }
148
  result.append(row)
149
- return result
150
 
151
  async def get_video_list_by_min_date(self, sec_user_id: str, min_date: str = "2025-06-10 00:00:00"):
152
  #UTC时间
@@ -154,12 +157,11 @@ class VideoDownload(DouyinClient):
154
 
155
  result = list()
156
 
157
- stop_flag = False
158
  max_cursor = 0
159
  for i in range(1000):
160
- if stop_flag:
 
161
  break
162
- rows = await self.get_video_list_by_user_id(sec_user_id=sec_user_id, max_cursor=max_cursor, count=18)
163
  this_min_date_ = [
164
  datetime.fromtimestamp(
165
  row["create_time"],
@@ -180,10 +182,6 @@ class VideoDownload(DouyinClient):
180
  tags = row["tags"]
181
  duration = row["duration"]
182
 
183
- max_cursor_ = int(create_time * 1000)
184
- if max_cursor == 0 or max_cursor_ < max_cursor:
185
- max_cursor = max_cursor_
186
-
187
  create_time_ = datetime.fromtimestamp(create_time)
188
 
189
  if create_time_ > min_date_:
 
89
  raise AssertionError(f"request failed, status_code: {response.status_code}, text: {response.text}")
90
  js = response.json()
91
  aweme_list = js["aweme_list"]
92
+ max_cursor = js["max_cursor"]
93
+ min_cursor = js["min_cursor"]
94
+ has_more = js["has_more"]
95
 
96
  result = list()
97
  for aweme in aweme_list:
 
149
  "duration": duration,
150
  }
151
  result.append(row)
152
+ return result, max_cursor
153
 
154
  async def get_video_list_by_min_date(self, sec_user_id: str, min_date: str = "2025-06-10 00:00:00"):
155
  #UTC时间
 
157
 
158
  result = list()
159
 
 
160
  max_cursor = 0
161
  for i in range(1000):
162
+ rows, max_cursor = await self.get_video_list_by_user_id(sec_user_id=sec_user_id, max_cursor=max_cursor, count=18)
163
+ if len(rows) == 0:
164
  break
 
165
  this_min_date_ = [
166
  datetime.fromtimestamp(
167
  row["create_time"],
 
182
  tags = row["tags"]
183
  duration = row["duration"]
184
 
 
 
 
 
185
  create_time_ = datetime.fromtimestamp(create_time)
186
 
187
  if create_time_ > min_date_:
toolbox/porter/tasks/video_format_convert_task.py CHANGED
@@ -65,13 +65,13 @@ class VideoFormatConvertTask(BaseTask):
65
 
66
  new_video_info = copy.deepcopy(video_info)
67
  for k, v in video_info.items():
68
- create_time = v["create_time"]
69
  filename = v["filename"]
70
  # url_list = v["url_list"]
71
  # video_id = v["video_id"]
72
- title = v["title"]
73
- desc = v["desc"]
74
- tags = v["tags"]
75
 
76
  format_convert_output_file = v.get("format_convert_output_file")
77
  if format_convert_output_file is None:
 
65
 
66
  new_video_info = copy.deepcopy(video_info)
67
  for k, v in video_info.items():
68
+ # create_time = v["create_time_str"]
69
  filename = v["filename"]
70
  # url_list = v["url_list"]
71
  # video_id = v["video_id"]
72
+ # title = v["title"]
73
+ # desc = v["desc"]
74
+ # tags = v["tags"]
75
 
76
  format_convert_output_file = v.get("format_convert_output_file")
77
  if format_convert_output_file is None:
toolbox/porter/tasks/video_to_bilibili_task.py CHANGED
@@ -143,12 +143,17 @@ class VideoToBilibiliTask(BaseTask):
143
  logger.info(f"{self.flag}上传视频时找不到文件:{filename}")
144
  continue
145
  logger.info(f"{self.flag}上传视频:{filename}")
146
- video_id = await asyncio.to_thread(
147
- # self.bilibili_video_manager.upload_video_draft_and_publish,
148
- self.bilibili_video_manager.upload_video_and_publish,
149
- filename=filename,
150
- metadata=metadata,
151
- )
 
 
 
 
 
152
  if self.remove_after_upload:
153
  logger.info(f"{self.flag}删除本地文件:{filename}")
154
  os.remove(filename)
 
143
  logger.info(f"{self.flag}上传视频时找不到文件:{filename}")
144
  continue
145
  logger.info(f"{self.flag}上传视频:{filename}")
146
+ try:
147
+ video_id = await asyncio.to_thread(
148
+ # self.bilibili_video_manager.upload_video_draft_and_publish,
149
+ self.bilibili_video_manager.upload_video_and_publish,
150
+ filename=filename,
151
+ metadata=metadata,
152
+ )
153
+ except Exception as error:
154
+ logger.info(f"{self.flag}上传视频失败; filename: {filename}, error type: {type(error)}, error text: {str(error)}")
155
+ await asyncio.sleep(self.check_interval * 100)
156
+ continue
157
  if self.remove_after_upload:
158
  logger.info(f"{self.flag}删除本地文件:{filename}")
159
  os.remove(filename)
toolbox/porter/tasks/video_to_youtube_task.py CHANGED
@@ -116,7 +116,7 @@ class VideoToYoutubeTask(BaseTask):
116
  tags = v["tags"]
117
 
118
  title_and_tags = title
119
- for tag in tags:
120
  if len(title_and_tags) > 80:
121
  title_and_tags = title_and_tags[:80]
122
  break
@@ -152,11 +152,16 @@ class VideoToYoutubeTask(BaseTask):
152
  continue
153
 
154
  logger.info(f"{self.flag}上传视频:{filename}")
155
- video_id = await asyncio.to_thread(
156
- youtube_video_manager.upload_video,
157
- filename=filename,
158
- metadata=video_metadata,
159
- )
 
 
 
 
 
160
  if self.playlist_id is not None:
161
  logger.info(f"{self.flag}将视频添加至播放列表:{self.playlist_title},{self.playlist_id}")
162
  await asyncio.to_thread(
 
116
  tags = v["tags"]
117
 
118
  title_and_tags = title
119
+ for tag in list(set(tags)):
120
  if len(title_and_tags) > 80:
121
  title_and_tags = title_and_tags[:80]
122
  break
 
152
  continue
153
 
154
  logger.info(f"{self.flag}上传视频:{filename}")
155
+ try:
156
+ video_id = await asyncio.to_thread(
157
+ youtube_video_manager.upload_video,
158
+ filename=filename,
159
+ metadata=video_metadata,
160
+ )
161
+ except Exception as error:
162
+ logger.info(f"{self.flag}上传视频失败; filename: {filename}, error type: {type(error)}, error text: {str(error)}")
163
+ await asyncio.sleep(self.check_interval * 100)
164
+ continue
165
  if self.playlist_id is not None:
166
  logger.info(f"{self.flag}将视频添加至播放列表:{self.playlist_title},{self.playlist_id}")
167
  await asyncio.to_thread(