Skip to content

Commit

Permalink
[extractor:kvsplayer] added support for version 6, 8, 12, 13 and some…
Browse files Browse the repository at this point in the history
… minor fixes
  • Loading branch information
gan-of-culture committed Dec 10, 2023
1 parent a58d43f commit 62d4f75
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 4 additions & 4 deletions extractors/htdoujin/htdoujin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestParseURL(t *testing.T) {
URL string
Want int
}{
{
/*{
Name: "Single Gallery HentaiEra",
URL: "https://hentaiera.com/gallery/150354/",
Want: 1,
Expand All @@ -26,7 +26,7 @@ func TestParseURL(t *testing.T) {
Name: "Tag HentaiEra",
URL: "https://hentaiera.com/tag/ahegao/",
Want: 25,
}, {
},*/{
Name: "Single Gallery HentaiEnvy",
URL: "https://hentaienvy.com/gallery/808735/",
Want: 1,
Expand Down Expand Up @@ -91,15 +91,15 @@ func TestExtract(t *testing.T) {
Name string
Args test.Args
}{
{
/*{
Name: "Single Gallery HentaiEra",
Args: test.Args{
URL: "https://hentaiera.com/gallery/610929/",
Title: "Senran Princess G",
Quality: "",
Size: 0,
},
},
},*/
{
Name: "Single Gallery HentaiEnvy",
Args: test.Args{
Expand Down
11 changes: 10 additions & 1 deletion extractors/kvsplayer/kvsplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func ExtractFromHTML(htmlString *string) ([]*static.Data, error) {
}

switch matchedKVSPlayer[0][2] {
case "4", "5", "9", "11", "15":
case "4", "5", "8", "9", "11", "12", "13", "15":
break
default:
fmt.Printf("Untested major version (%s) in player engine--Download may fail.", matchedKVSPlayer[0][2])
Expand Down Expand Up @@ -209,6 +209,15 @@ func parseFlashVars(htmlString *string) (map[string]string, error) {
return cmp.Compare(len(a), len(b))
})
slices.Reverse(matchedHtmlFlashvars)
idxFlashVars := slices.IndexFunc(matchedHtmlFlashvars, func(matchedString string) bool {
return strings.HasPrefix(matchedString, "var flashvars")
})
// if one of the matches starts with flashvars -> take that one
// if said match is already at idx 0 you don't need to reassign
// if idx == -1 move on normally
if idxFlashVars > 0 {
matchedHtmlFlashvars[0] = matchedHtmlFlashvars[idxFlashVars]
}
htmlFlashvars := matchedHtmlFlashvars[0]
if htmlFlashvars == "" {
return nil, static.ErrDataSourceParseFailed
Expand Down
1 change: 1 addition & 0 deletions test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func Check(t *testing.T, args Args, data *static.Data) {

if defaultData == nil {
t.Errorf("Data contains no streams or no default stream")
return
}

temp := Args{
Expand Down

0 comments on commit 62d4f75

Please sign in to comment.