Skip to content

Commit

Permalink
[extractor:kvsplayer] added support for version 15
Browse files Browse the repository at this point in the history
  • Loading branch information
gan-of-culture committed Dec 2, 2023
1 parent c8320f9 commit 0d8eb1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 10 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", "9", "11", "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,12 @@ 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)
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

0 comments on commit 0d8eb1e

Please sign in to comment.