From 2608df9727be9cb1c8982231951b246bb289123e Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Tue, 5 Jul 2016 16:18:14 +0200 Subject: [PATCH] parsers/youtube: Add NSFW marker for age-restricted videos. --- main.tpl | 7 +++++++ parsers/youtube/parser.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/main.tpl b/main.tpl index c35a088..d0ac053 100644 --- a/main.tpl +++ b/main.tpl @@ -25,6 +25,13 @@ ยป + {{- if index . "AgeRestriction" }} + {{ color 4 -}} + {{ bold -}} + [{{- index . "AgeRestriction" }}] + {{- reset }} + {{- end }} + {{ if index . "IsProfile" }} {{- if index . "Title" }} {{ bold -}} diff --git a/parsers/youtube/parser.go b/parsers/youtube/parser.go index 5c8de48..79c0f3a 100644 --- a/parsers/youtube/parser.go +++ b/parsers/youtube/parser.go @@ -168,6 +168,12 @@ func (p *Parser) Parse(u *url.URL, referer *url.URL) (result parsers.ParseResult } else { log.Print(err) } + + if item.ContentDetails.ContentRating != nil { + if item.ContentDetails.ContentRating.YtRating == "ytAgeRestricted" { + r["AgeRestriction"] = "NSFW" + } + } } if item.Statistics != nil { r["Views"] = item.Statistics.ViewCount