check tweets for sensitive content
This commit is contained in:
parent
e6ddf32a93
commit
cd161d56db
3 changed files with 41 additions and 28 deletions
2
api.go
2
api.go
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bearerToken string = "AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA"
|
const bearerToken string = "AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw"
|
||||||
|
|
||||||
// RequestAPI get JSON from frontend API and decodes it
|
// RequestAPI get JSON from frontend API and decodes it
|
||||||
func (s *Scraper) RequestAPI(req *http.Request, target interface{}) error {
|
func (s *Scraper) RequestAPI(req *http.Request, target interface{}) error {
|
||||||
|
|
|
||||||
20
timeline.go
20
timeline.go
|
|
@ -30,10 +30,15 @@ type timeline struct {
|
||||||
} `json:"entities"`
|
} `json:"entities"`
|
||||||
ExtendedEntities struct {
|
ExtendedEntities struct {
|
||||||
Media []struct {
|
Media []struct {
|
||||||
IDStr string `json:"id_str"`
|
IDStr string `json:"id_str"`
|
||||||
MediaURLHttps string `json:"media_url_https"`
|
MediaURLHttps string `json:"media_url_https"`
|
||||||
Type string `json:"type"`
|
ExtSensitiveMediaWarning struct {
|
||||||
VideoInfo struct {
|
AdultContent bool `json:"adult_content"`
|
||||||
|
GraphicViolence bool `json:"graphic_violence"`
|
||||||
|
Other bool `json:"other"`
|
||||||
|
} `json:"ext_sensitive_media_warning"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
VideoInfo struct {
|
||||||
Variants []struct {
|
Variants []struct {
|
||||||
Bitrate int `json:"bitrate,omitempty"`
|
Bitrate int `json:"bitrate,omitempty"`
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
|
@ -211,9 +216,16 @@ func (timeline *timeline) parseTweet(id string) *Tweet {
|
||||||
maxBitrate = variant.Bitrate
|
maxBitrate = variant.Bitrate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tw.Videos = append(tw.Videos, video)
|
tw.Videos = append(tw.Videos, video)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !tw.SensitiveContent {
|
||||||
|
sensitive := media.ExtSensitiveMediaWarning
|
||||||
|
tw.SensitiveContent = sensitive.AdultContent || sensitive.GraphicViolence || sensitive.Other
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, url := range tweet.Entities.URLs {
|
for _, url := range tweet.Entities.URLs {
|
||||||
tw.URLs = append(tw.URLs, url.ExpandedURL)
|
tw.URLs = append(tw.URLs, url.ExpandedURL)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
47
types.go
47
types.go
|
|
@ -12,29 +12,30 @@ type (
|
||||||
|
|
||||||
// Tweet type.
|
// Tweet type.
|
||||||
Tweet struct {
|
Tweet struct {
|
||||||
Hashtags []string
|
Hashtags []string
|
||||||
HTML string
|
HTML string
|
||||||
ID string
|
ID string
|
||||||
InReplyToStatus *Tweet
|
InReplyToStatus *Tweet
|
||||||
IsQuoted bool
|
IsQuoted bool
|
||||||
IsPin bool
|
IsPin bool
|
||||||
IsReply bool
|
IsReply bool
|
||||||
IsRetweet bool
|
IsRetweet bool
|
||||||
Likes int
|
Likes int
|
||||||
PermanentURL string
|
PermanentURL string
|
||||||
Photos []string
|
Photos []string
|
||||||
Place *Place
|
Place *Place
|
||||||
QuotedStatus *Tweet
|
QuotedStatus *Tweet
|
||||||
Replies int
|
Replies int
|
||||||
Retweets int
|
Retweets int
|
||||||
RetweetedStatus *Tweet
|
RetweetedStatus *Tweet
|
||||||
Text string
|
Text string
|
||||||
TimeParsed time.Time
|
TimeParsed time.Time
|
||||||
Timestamp int64
|
Timestamp int64
|
||||||
URLs []string
|
URLs []string
|
||||||
UserID string
|
UserID string
|
||||||
Username string
|
Username string
|
||||||
Videos []Video
|
Videos []Video
|
||||||
|
SensitiveContent bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProfileResult of scrapping.
|
// ProfileResult of scrapping.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue