Skip to content

Commit f571bf3

Browse files
authored
Merge pull request #48 from beclab/feat/refactor
bilibili youtube rule
2 parents 72a0553 + e9b3ccb commit f571bf3

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

processor/rules.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ var contentTemplatePredefinedRules = map[string]string{
141141
"yahoo.com": "YahooExtractorMetaInfo",
142142
"ycombinator.com": "YcombinatorExtractorMetaInfo",
143143
"youtube.com": "YoutubeExtractorMetaInfo",
144+
"youtu.be": "YoutubeShortExtractorMetaInfo",
144145
"zhihu.com": "ZhihuExtractorMetaInfo",
145146
}
146147

templates/bilibili.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ func bilibiliScrapContent(document *goquery.Document) string {
1313
document.Find("span.desc-info-text,div.opus-module-content").Each(func(i int, s *goquery.Selection) {
1414
var content string
1515
content, _ = goquery.OuterHtml(s)
16+
content = strings.Replace(content, "\n", "<br>", -1)
1617
contents += content
1718
})
1819
if contents != "" {
@@ -21,6 +22,7 @@ func bilibiliScrapContent(document *goquery.Document) string {
2122
document.Find("p[class*='mediainfo_content_placeholder']").Each(func(i int, s *goquery.Selection) {
2223
var content string
2324
content, _ = goquery.OuterHtml(s)
25+
content = strings.Replace(content, "\n", "<br>", -1)
2426
contents += content
2527
})
2628
add_img := ""
@@ -65,7 +67,7 @@ func (t *Template) BilibiliExtractorMetaInfo(url string, document *goquery.Docum
6567
contents := "<iframe width='910' height='668' src='" + embeddingUrl + "' border='0' scrolling='no' border='0 frameborder='no' framespacing='0' allowfullscreen='true' referrerpolicy='no-referrer'></iframe>"
6668
return content, author, publishedAt, contents, url, VideoFileType
6769
}
68-
if strings.Contains(url, "bilibili.com/festival/") {
70+
if strings.Contains(url, "bilibili.com/video/") || strings.Contains(url, "bilibili.com/festival/") {
6971
return content, author, publishedAt, "", url, VideoFileType
7072
}
7173
if strings.Contains(url, "audio/au") {

templates/youtube.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ func (t *Template) YoutubeExtractorMetaInfo(url string, document *goquery.Docume
2121
}
2222
return "", "", 0, "", "", ""
2323
}
24+
25+
func (t *Template) YoutubeShortExtractorMetaInfo(url string, document *goquery.Document) (string, string, int64, string, string, string) {
26+
return "", "", 0, "", url, VideoFileType
27+
}

0 commit comments

Comments
 (0)