Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.2.53 #138

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 19 additions & 3 deletions extractors/kvsplayer/kvsplayer.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package kvsplayer

import (
"cmp"
"errors"
"fmt"
"math"
"regexp"
"slices"
"strconv"
"strings"

Expand All @@ -19,7 +21,7 @@ import (
*/

var reHasKVSPlayer = regexp.MustCompile(`<script [^>]*?src="https://.+?/kt_player\.js\?v=(?P<ver>(?P<maj_ver>\d+)(\.\d+)+)".*?>`)
var reFlashVars = regexp.MustCompile(`var\s+flashvars\s*=\s*\{[^}]*?\}`)
var reFlashVars = regexp.MustCompile(`var\s+(?:flashvars|[\w]{11})\s*=[\s\S]*?};`)
var reFlashVarsValues = regexp.MustCompile(`(\w+): ['"](.*?)['"],`)
var reTitle = regexp.MustCompile(`<link href="https?://[^"]+/(.+?)/?" rel="canonical"\s*/?>`)

Expand Down Expand Up @@ -56,7 +58,7 @@ func ExtractFromHTML(htmlString *string) ([]*static.Data, error) {
}

switch matchedKVSPlayer[0][2] {
case "4", "5", "9", "11":
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 @@ -202,7 +204,21 @@ func getLicenseToken(license string) string {
}

func parseFlashVars(htmlString *string) (map[string]string, error) {
htmlFlashvars := reFlashVars.FindString(*htmlString)
matchedHtmlFlashvars := reFlashVars.FindAllString(*htmlString, -1)
slices.SortFunc(matchedHtmlFlashvars, func(a, b string) int {
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
9 changes: 0 additions & 9 deletions extractors/universal/universal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ func TestExtract(t *testing.T) {
Size: 384586,
},
},
{
Name: "awwni",
Args: test.Args{
URL: "http://cdn.awwni.me/16c8v.jpg",
Title: "16c8v",
Quality: "",
Size: 102169,
},
},
{
Name: "with bloat after ext",
Args: test.Args{
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