Skip to content

Commit

Permalink
Merge pull request #575 from ttys3/master
Browse files Browse the repository at this point in the history
youtube: detect login required video
  • Loading branch information
iawia002 committed Dec 19, 2019
2 parents 3675c72 + b975c0f commit 4da6cdf
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 4da6cdf

Please sign in to comment.