adollahamini1998 commited on
Commit
ed02ccb
·
1 Parent(s): 058724c

Fix error catching failures

Browse files
fix_stuck_failed_entries_downloader.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ One-off fix for downloader.py progress files affected by the
3
+ _CapturingLogger traceback bug.
4
+
5
+ Some videos ended up status="failed" with attempts >= max_video_attempts,
6
+ where last_error is actually just a raw traceback (e.g. starts with
7
+ ' File "...') instead of the real yt-dlp message. That happened because,
8
+ with verbose=True, yt-dlp's logger.error() was called twice per failure and
9
+ the traceback call overwrote the real error message before it could be
10
+ classified -- so these videos may really be permanently unavailable
11
+ (private/removed/etc.) but got stuck labeled "failed" instead, and
12
+ should_retry_video() will never look at them again.
13
+
14
+ This resets `attempts` to 0 for exactly those entries so the *next* run
15
+ (with the fix applied) gives them one more attempt and classifies them
16
+ correctly. It does NOT touch anything already "uploaded" or "unavailable",
17
+ or "failed" entries whose last_error looks like a normal (non-traceback)
18
+ message -- those were classified correctly the first time.
19
+
20
+ Usage:
21
+ python fix_stuck_failed_entries_downloader.py progress/download_progress_6_0.json
22
+ """
23
+ import json
24
+ import sys
25
+
26
+
27
+ def looks_like_traceback(msg):
28
+ if not msg:
29
+ return False
30
+ stripped = msg.lstrip()
31
+ return stripped.startswith('File "') or stripped.startswith('Traceback')
32
+
33
+
34
+ def main(path):
35
+ with open(path, encoding='utf-8') as f:
36
+ data = json.load(f)
37
+
38
+ completed = data.get('completed', {})
39
+ reset_count = 0
40
+ total_videos = 0
41
+
42
+ for spk, speaker_state in completed.items():
43
+ videos = speaker_state.get('videos', {}) if isinstance(speaker_state, dict) else {}
44
+ for video_id, state in videos.items():
45
+ total_videos += 1
46
+ if state.get('status') != 'failed':
47
+ continue
48
+ if not looks_like_traceback(state.get('last_error')):
49
+ continue
50
+ state['attempts'] = 0
51
+ state['last_error'] = None
52
+ reset_count += 1
53
+
54
+ print(f'Reset {reset_count} stuck "failed" video entries out of {total_videos} total.')
55
+
56
+ backup_path = path + '.bak'
57
+ with open(path, encoding='utf-8') as f:
58
+ original = f.read()
59
+ with open(backup_path, 'w', encoding='utf-8') as f:
60
+ f.write(original)
61
+ print(f'Backed up original to {backup_path}')
62
+
63
+ with open(path, 'w', encoding='utf-8') as f:
64
+ json.dump(data, f, indent=2)
65
+ print(f'Wrote updated progress to {path}')
66
+
67
+
68
+ if __name__ == '__main__':
69
+ if len(sys.argv) != 2:
70
+ print('Usage: python fix_stuck_failed_entries_downloader.py <path-to-progress-file>')
71
+ sys.exit(1)
72
+ main(sys.argv[1])
progress/download_progress_6_0.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e52a86bc7f702e99692b173f4e30475a703127142ba61a55b90188a98b717c5c
3
- size 98846915
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1fae1c129c80896f405419832d6a401b14a72fcb10d9c0f006e49f5a8c10aaf6
3
+ size 81430556
progress/download_progress_6_1.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7a664927b583f8574056b53447b24f322f6245f527d0dd737f91db15b3f3c277
3
- size 96903963
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cd297a741b6d06ae9330016503bae6ea2e3bfd1eb3b973aab01859bca68ed4b
3
+ size 80606794
progress/download_progress_6_2.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:559150eb826646805aee6658adcdccccebf1086e269bd6501c4222338b878b99
3
- size 97649261
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a0e3e89630d0982357faf1c3f5ffa60837b4359b1a8479e0e323fcb57ace3b7
3
+ size 80958875
progress/download_progress_6_3.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:81dceb94e67f3d210c8f22542ea6c2a9efc45b67d69ea5faf8de897a0bf7b206
3
- size 98348512
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7d53bd6ff598d29a5df7b4a19632ce6815e71bcc54dcff436072a5e35bbeb3e1
3
+ size 81171985
progress/download_progress_6_4.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:209dafc19f15f983a59278d4d3709444a32bcbd31eafff6b4d4ce37284968af6
3
- size 99830856
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26c1ba1f0bf61eae92abded14773cf7590c38cc1e1df23d734a725bbd0c2a8b8
3
+ size 81501353
progress/download_progress_6_5.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:110adb16bdab0b6800f71659a67fd6e59a8acf83f864c19626e85842c15a9800
3
- size 98389010
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20fe8b5865ac05792eb6a07df6f11f571fdb2a78441cbe05e036378227aae6da
3
+ size 81245127