Skip to content

Commit 4f20f7a

Browse files
committed
chore: incoming 1810 changelog entry
1 parent 3211f6f commit 4f20f7a

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### PR [#1810](https://github.com/danielmiessler/Fabric/pull/1810) by [tonymet](https://github.com/tonymet): improve subtitle lang, retry, debugging & error handling
2+
3+
- Improve subtitle lang, retry, debugging & error handling

internal/log/log.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ func Debug(l Level, format string, a ...interface{}) {
6161
}
6262
}
6363

64-
// Debug(Trace) convenience function
65-
func DTrace(a ...interface{}) {
66-
Debug(Trace, "%s\n", a...)
67-
}
68-
6964
// Log writes a message unconditionally to stderr.
7065
// This is for important messages that should always be shown regardless of debug level.
7166
func Log(format string, a ...interface{}) {

internal/tools/youtube/youtube.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,18 @@ func detectError(ytOutput io.Reader) error {
151151
scanner := bufio.NewScanner(ytOutput)
152152
for scanner.Scan() {
153153
curLine := scanner.Text()
154-
debuglog.DTrace(curLine)
155-
if strings.Contains(curLine, "429") || strings.Contains(curLine, "Too Many Requests") {
156-
return fmt.Errorf("YouTube rate limit exceeded. Try again later or use different yt-dlp arguments like '--sleep-requests 1' to slow down requests.")
154+
debuglog.Debug(debuglog.Trace, "%s\n", curLine)
155+
errorMessages := map[string]string{
156+
"429": "YouTube rate limit exceeded. Try again later or use different yt-dlp arguments like '--sleep-requests 1' to slow down requests.",
157+
"Too Many Requests": "YouTube rate limit exceeded. Try again later or use different yt-dlp arguments like '--sleep-requests 1' to slow down requests.",
158+
"Sign in to confirm you're not a bot": "YouTube requires authentication (bot detection). Use --yt-dlp-args='--cookies-from-browser BROWSER' where BROWSER is chrome, firefox, brave, etc.",
159+
"Use --cookies-from-browser": "YouTube requires authentication (bot detection). Use --yt-dlp-args='--cookies-from-browser BROWSER' where BROWSER is chrome, firefox, brave, etc.",
157160
}
158-
if strings.Contains(curLine, "Sign in to confirm you're not a bot") || strings.Contains(curLine, "Use --cookies-from-browser") {
159-
return fmt.Errorf("YouTube requires authentication (bot detection). Use --yt-dlp-args='--cookies-from-browser BROWSER' where BROWSER is chrome, firefox, brave, etc.")
160-
}
161-
if strings.Contains(curLine, "There are no subtitles for the requested languages") {
162-
return fmt.Errorf("There are no subtitles for the requested languages")
163-
}
164-
if strings.Contains(curLine, "Downloading subtitles:") {
165-
return nil
161+
162+
for key, message := range errorMessages {
163+
if strings.Contains(curLine, key) {
164+
return fmt.Errorf("%s", message)
165+
}
166166
}
167167
}
168168
if err := scanner.Err(); err != nil {

0 commit comments

Comments
 (0)