-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修复 #26(抖音app分享的西瓜视频链接无法解析问题) 和 西瓜视频解析问题
- Loading branch information
1 parent
dbde53c
commit 32eaccc
Showing
3 changed files
with
76 additions
and
22 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,34 @@ | ||
package parser | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func Test_douYin_parseIdFromPath(t *testing.T) { | ||
type args struct { | ||
path string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
{"抖音视频", args{"/share/video/7329354490828623130/"}, "7329354490828623130", false}, | ||
{"西瓜视频", args{"/douyin/share/video/7144194760184594977"}, "7144194760184594977", false}, | ||
{"异常视频", args{""}, "", true}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
d := douYin{} | ||
got, err := d.parseVideoIdFromPath(tt.args.path) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("parseVideoIdFromPath() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("parseVideoIdFromPath() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
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