forked from iawia002/lux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package extractors | ||
|
||
import ( | ||
"github.com/iawia002/annie/downloader" | ||
"github.com/iawia002/annie/parser" | ||
"github.com/iawia002/annie/request" | ||
"github.com/iawia002/annie/utils" | ||
) | ||
|
||
// Miaopai download function | ||
func Miaopai(url string) downloader.VideoData { | ||
html := request.Get(url, url) | ||
doc := parser.GetDoc(html) | ||
title := parser.Title(doc) | ||
|
||
realURL := utils.MatchOneOf(html, `"videoSrc":"(.+?)"`)[1] | ||
size := request.Size(realURL, url) | ||
urlData := downloader.URLData{ | ||
URL: realURL, | ||
Size: size, | ||
Ext: "mp4", | ||
} | ||
format := map[string]downloader.FormatData{ | ||
"default": { | ||
URLs: []downloader.URLData{urlData}, | ||
Size: size, | ||
}, | ||
} | ||
extractedData := downloader.VideoData{ | ||
Site: "秒拍 miaopai.com", | ||
Title: title, | ||
Type: "video", | ||
Formats: format, | ||
} | ||
extractedData.Download(url) | ||
return extractedData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package extractors | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/iawia002/annie/config" | ||
"github.com/iawia002/annie/test" | ||
) | ||
|
||
func TestMiaopai(t *testing.T) { | ||
config.InfoOnly = true | ||
tests := []struct { | ||
name string | ||
args test.Args | ||
}{ | ||
{ | ||
name: "normal test", | ||
args: test.Args{ | ||
URL: "https://www.miaopai.com/show/nPWJvdR4z2Bg1Sz3PJpNYffjpDgEiuv4msALgw__.htm", | ||
Title: "情人节特辑:一个来自绝地求生的爱情故事,送给已经离开的你-绝地求生大逃杀的秒拍", | ||
Size: 12135847, | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
data := Miaopai(tt.args.URL) | ||
test.Check(t, tt.args, data) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters