Skip to content

Commit bb5337a

Browse files
committed
add handle when downloading video failed
1 parent 9d74117 commit bb5337a

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ The onedrive needs a login for the first time, after that the token will be save
148148
- [x] rclone for local
149149
- [x] rclone for docker
150150
- [ ] rclone for github action
151+
- [ ] download with cookie
151152
- [ ] add retry history failed videos
152153
- [ ] config from gist
153154
- [ ] backup summary

bili_backup/downloader/bilix.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
22
Date: 2023-10-23 18:04:14
33
LastEditors: Kumo
4-
LastEditTime: 2024-06-21 22:22:32
4+
LastEditTime: 2024-06-22 17:17:27
55
Description:
66
'''
77

@@ -50,9 +50,12 @@ async def download_video_action(self, video_link, path
5050
def download_video(self, video_link:str, path:str) -> bool:
5151
if not os.path.exists(path):
5252
os.makedirs(path)
53-
54-
asyncio.run(self.download_video_action(video_link, path))
55-
return True
53+
try:
54+
asyncio.run(self.download_video_action(video_link, path))
55+
return True
56+
except Exception as e:
57+
logger.error(f"Fail to download {video_link}: {str(e)}")
58+
return False
5659

5760

5861
def download_videos(self, video_links:list, path:str) -> bool:

main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
22
Date: 2023-10-23 18:24:31
33
LastEditors: Kumo
4-
LastEditTime: 2024-06-22 17:06:56
4+
LastEditTime: 2024-06-22 17:17:35
55
Description:
66
'''
77
from bili_backup.cloudreve import Cloudreve
@@ -158,7 +158,8 @@ def main(strategy):
158158
logger.error(f"Failed to get video metadata for video [{video_meta.title}]: {str(e)}")
159159
all_eps_ok = False
160160
all_tasks_success = False
161-
continue
161+
# continue
162+
# 有时似乎返回视频信息失效,但实际并未失效
162163

163164
#### skip videos with many eps
164165
num_eps = len(video_info_fetched.pages)

0 commit comments

Comments
 (0)