Skip to content

Commit

Permalink
[extractor:nhplayer] update extraction of new player.php format
Browse files Browse the repository at this point in the history
  • Loading branch information
gan-of-culture committed Jun 25, 2023
1 parent 90d49da commit 55dad87
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
9 changes: 9 additions & 0 deletions extractors/nhgroup/nhgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ func TestExtract(t *testing.T) {
Size: 558305856,
},
},
{
Name: "[New] Single Episode uncensoredhentai.xxx",
Args: test.Args{
URL: "https://uncensoredhentai.xxx/watch/joshi-luck-episode-5/",
Title: "Joshi Luck! Episode 5",
Quality: "",
Size: 423727631,
},
},
}
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
Expand Down
35 changes: 30 additions & 5 deletions extractors/nhplayer/nhplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

var reNHPlayerURL = regexp.MustCompile(`https://nhplayer\.com/v/[^/"]+`)
var rePlayerURL = regexp.MustCompile(`/player.php\?u=([^"&]+)`)
var rePlayerURL = regexp.MustCompile(`/player.php\?[^"]+`)
var reHTStreamingVideoURL = regexp.MustCompile(`https://htstreaming.com/video/([^"]*)`)

type extractor struct{}
Expand Down Expand Up @@ -61,12 +61,19 @@ func extractData(URL string) (*static.Data, error) {
return htstreaming.ExtractData(videoURL)
}

playerURL := rePlayerURL.FindStringSubmatch(htmlString)
if len(playerURL) < 2 {
// non htstreaming video

matchedPlayerURL := rePlayerURL.FindString(htmlString)
if len(matchedPlayerURL) < 2 {
return nil, static.ErrDataSourceParseFailed
}

b64Path, err := base64.StdEncoding.DecodeString(playerURL[1])
playerURL, err := url.Parse(matchedPlayerURL)
if err != nil {
return nil, err
}

b64Path, err := base64.StdEncoding.DecodeString(playerURL.Query().Get("u"))
if err != nil {
return nil, err
}
Expand All @@ -82,6 +89,23 @@ func extractData(URL string) (*static.Data, error) {

size, _ := request.Size(videoURL, URL)

captions := []*static.Caption{}
subtitleQuery := playerURL.Query().Get("s")
if subtitleQuery != "" {
b64Path, err := base64.StdEncoding.DecodeString(subtitleQuery)
if err != nil {
return nil, err
}
subtitleURL := string(b64Path)
captions = append(captions, &static.Caption{
URL: static.URL{
URL: subtitleURL,
Ext: utils.GetFileExt(subtitleURL),
},
Language: "English",
})
}

return &static.Data{
Site: baseURL.Host,
Title: title,
Expand All @@ -98,6 +122,7 @@ func extractData(URL string) (*static.Data, error) {
Size: size,
},
},
URL: URL,
Captions: captions,
URL: URL,
}, nil
}

0 comments on commit 55dad87

Please sign in to comment.