@@ -10,7 +10,7 @@ import (
1010
1111func bilibiliScrapContent (document * goquery.Document ) string {
1212 contents := ""
13- document .Find ("span.desc-info-text" ).Each (func (i int , s * goquery.Selection ) {
13+ 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 )
1616 contents += content
@@ -36,8 +36,20 @@ func bilibiliScrapContent(document *goquery.Document) string {
3636}
3737
3838func (t * Template ) BilibiliExtractorMetaInfo (url string , document * goquery.Document ) (string , string , int64 , string , string , string ) {
39- bvid := ""
39+ author := ""
40+ document .Find ("div.fixed-author-header__author__name,div.opus-module-author__name" ).Each (func (i int , s * goquery.Selection ) {
41+ author = strings .TrimSpace (s .Text ())
42+ })
43+ var publishedAt int64 = 0
44+ document .Find ("div.opus-module-author__pub__text" ).Each (func (i int , s * goquery.Selection ) {
45+ publishTimes := s .Text ()
46+ layout := "2006年01月02日 15:04"
47+ publishTimes = strings .TrimPrefix (publishTimes , "编辑于 " )
48+ publishedAt , _ = ParseLocationTimestamp (publishTimes , layout , ShanghaiTZ )
49+ })
4050 content := bilibiliScrapContent (document )
51+
52+ bvid := ""
4153 document .Find ("meta[itemprop=url]" ).Each (func (i int , s * goquery.Selection ) {
4254 if content , exists := s .Attr ("content" ); exists {
4355 videoPattern := `video/(\w+)`
@@ -51,13 +63,14 @@ func (t *Template) BilibiliExtractorMetaInfo(url string, document *goquery.Docum
5163 if bvid != "" {
5264 embeddingUrl := "https://www.bilibili.com/blackboard/html5mobileplayer.html?bvid=" + bvid + "&high_quality=1&autoplay=0"
5365 contents := "<iframe width='910' height='668' src='" + embeddingUrl + "' border='0' scrolling='no' border='0 frameborder='no' framespacing='0' allowfullscreen='true' referrerpolicy='no-referrer'></iframe>"
54- return content , "" , 0 , contents , url , "video"
66+ return content , author , publishedAt , contents , url , VideoFileType
5567 }
56- /*document.Find("meta[property='og:url']").Each(func(i int, s *goquery.Selection) {
57- if content, exists := s.Attr("content"); exists {
58- downloadUrl = content
59- downloadType = "video"
60- }
61- })*/
62- return content , "" , 0 , "" , "" , ""
68+ if strings .Contains (url , "bilibili.com/festival/" ) {
69+ return content , author , publishedAt , "" , url , VideoFileType
70+ }
71+ if strings .Contains (url , "audio/au" ) {
72+ return content , author , publishedAt , "" , url , AudioFileType
73+ }
74+
75+ return content , author , publishedAt , "" , "" , ""
6376}
0 commit comments