Skip to content

Commit

Permalink
修复[BUG](#290)
Browse files Browse the repository at this point in the history
检测任务信息的status状态,failed则跳过
  • Loading branch information
Samueli924 committed Nov 15, 2023
1 parent f36c02b commit 6c7cd9a
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,29 @@ def study_video(self, _course, _job, _job_info, _speed: float = 1):
_session.headers.update()
_info_url = f"https://mooc1.chaoxing.com/ananas/status/{_job['objectid']}?k={self.get_fid()}&flag=normal"
_video_info = _session.get(_info_url).json()
_dtoken = _video_info["dtoken"]
_duration = _video_info["duration"]
_crc = _video_info["crc"]
_key = _video_info["key"]
_isPassed = False
_isFinished = False
_playingTime = 0
logger.info(f"开始任务:{_job['name']}, 总时长: {_duration}秒")
while not _isPassed:
if _isFinished:
_playingTime = _duration
_isPassed = self.video_progress_log(_session, _course, _job, _job_info, _dtoken, _duration, 0)
if _isPassed:
break
_wait_time = get_random_seconds()
if _playingTime + _wait_time >= int(_duration):
_wait_time = int(_duration) - _playingTime
_isFinished = True
# 播放进度条
show_progress(_job['name'], _playingTime, _wait_time, _duration, _speed)
_playingTime += _wait_time
logger.info(f"\n任务完成:{_job['name']}")
if _video_info["status"] == "success":
_dtoken = _video_info["dtoken"]
_duration = _video_info["duration"]
_crc = _video_info["crc"]
_key = _video_info["key"]
_isPassed = False
_isFinished = False
_playingTime = 0
logger.info(f"开始任务:{_job['name']}, 总时长: {_duration}秒")
while not _isPassed:
if _isFinished:
_playingTime = _duration
_isPassed = self.video_progress_log(_session, _course, _job, _job_info, _dtoken, _duration, 0)
if _isPassed:
break
_wait_time = get_random_seconds()
if _playingTime + _wait_time >= int(_duration):
_wait_time = int(_duration) - _playingTime
_isFinished = True
# 播放进度条
show_progress(_job['name'], _playingTime, _wait_time, _duration, _speed)
_playingTime += _wait_time
logger.info(f"\n任务完成:{_job['name']}")

def study_document(self, _course, _job):
_session = init_session()
Expand Down

0 comments on commit 6c7cd9a

Please sign in to comment.