diff --git a/extractors/tiktok/tiktok.go b/extractors/tiktok/tiktok.go index 496bab450..6576a3900 100644 --- a/extractors/tiktok/tiktok.go +++ b/extractors/tiktok/tiktok.go @@ -43,14 +43,28 @@ func (e *extractor) Extract(url string, option extractors.Options) ([]*extractor titleMatcherRegExp := regexp.MustCompile(`]*>([^<]+)`) + 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 {