Skip to content

Commit

Permalink
youtube: detect login required video
Browse files Browse the repository at this point in the history
  • Loading branch information
ttys3 committed Dec 13, 2019
1 parent 3675c72 commit b975c0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions extractors/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ import (
)

var ErrURLParseFailed = errors.New("url parse failed")
var ErrLoginRequired = errors.New("login required")
4 changes: 4 additions & 0 deletions extractors/youtube/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func youtubeDownload(uri string) downloader.Data {
}
ytplayer := utils.MatchOneOf(html, `;ytplayer\.config\s*=\s*({.+?});`)
if ytplayer == nil || len(ytplayer) < 2 {
if strings.Contains(html, "LOGIN_REQUIRED") ||
strings.Contains(html, "Sign in to confirm your age") {
return downloader.EmptyData(uri, extractors.ErrLoginRequired)
}
return downloader.EmptyData(uri, extractors.ErrURLParseFailed)
}

Expand Down

0 comments on commit b975c0f

Please sign in to comment.