Skip to content

Commit

Permalink
Merge pull request #1374 from SaifulI57/master
Browse files Browse the repository at this point in the history
fix tiktok title
  • Loading branch information
iawia002 committed Jul 22, 2024
2 parents 0883b0f + 93da918 commit dc70d1b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions extractors/tiktok/tiktok.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,28 @@ func (e *extractor) Extract(url string, option extractors.Options) ([]*extractor

titleMatcherRegExp := regexp.MustCompile(`<title[^>]*>([^<]+)</title>`)

titleMatcherRegExpOpt := regexp.MustCompile(`"desc":"([^"]*)"`)

titleMatcher := titleMatcherRegExp.FindStringSubmatch(html)

titleMatcherOpt := titleMatcherRegExpOpt.FindStringSubmatch(html)

if len(titleMatcher) == 0 {
return nil, errors.WithStack(extractors.ErrURLParseFailed)
}

title := titleMatcher[1]

if title == "TikTok - Make Your Day" {
if len(titleMatcherOpt[1]) > 64 {
cutoff := titleMatcherOpt[1][:64]
lastSpace := strings.LastIndex(cutoff, " ")
title = titleMatcherOpt[1][:lastSpace]
} else {
title = titleMatcherOpt[1]
}
}

titleArr := strings.Split(title, "|")

if len(titleArr) == 1 {
Expand Down

0 comments on commit dc70d1b

Please sign in to comment.