Skip to content

Commit 55dad87

Browse files
[extractor:nhplayer] update extraction of new player.php format
1 parent 90d49da commit 55dad87

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

extractors/nhgroup/nhgroup_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ func TestExtract(t *testing.T) {
163163
Size: 558305856,
164164
},
165165
},
166+
{
167+
Name: "[New] Single Episode uncensoredhentai.xxx",
168+
Args: test.Args{
169+
URL: "https://uncensoredhentai.xxx/watch/joshi-luck-episode-5/",
170+
Title: "Joshi Luck! Episode 5",
171+
Quality: "",
172+
Size: 423727631,
173+
},
174+
},
166175
}
167176
for _, tt := range tests {
168177
t.Run(tt.Name, func(t *testing.T) {

extractors/nhplayer/nhplayer.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

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

1919
type extractor struct{}
@@ -61,12 +61,19 @@ func extractData(URL string) (*static.Data, error) {
6161
return htstreaming.ExtractData(videoURL)
6262
}
6363

64-
playerURL := rePlayerURL.FindStringSubmatch(htmlString)
65-
if len(playerURL) < 2 {
64+
// non htstreaming video
65+
66+
matchedPlayerURL := rePlayerURL.FindString(htmlString)
67+
if len(matchedPlayerURL) < 2 {
6668
return nil, static.ErrDataSourceParseFailed
6769
}
6870

69-
b64Path, err := base64.StdEncoding.DecodeString(playerURL[1])
71+
playerURL, err := url.Parse(matchedPlayerURL)
72+
if err != nil {
73+
return nil, err
74+
}
75+
76+
b64Path, err := base64.StdEncoding.DecodeString(playerURL.Query().Get("u"))
7077
if err != nil {
7178
return nil, err
7279
}
@@ -82,6 +89,23 @@ func extractData(URL string) (*static.Data, error) {
8289

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

92+
captions := []*static.Caption{}
93+
subtitleQuery := playerURL.Query().Get("s")
94+
if subtitleQuery != "" {
95+
b64Path, err := base64.StdEncoding.DecodeString(subtitleQuery)
96+
if err != nil {
97+
return nil, err
98+
}
99+
subtitleURL := string(b64Path)
100+
captions = append(captions, &static.Caption{
101+
URL: static.URL{
102+
URL: subtitleURL,
103+
Ext: utils.GetFileExt(subtitleURL),
104+
},
105+
Language: "English",
106+
})
107+
}
108+
85109
return &static.Data{
86110
Site: baseURL.Host,
87111
Title: title,
@@ -98,6 +122,7 @@ func extractData(URL string) (*static.Data, error) {
98122
Size: size,
99123
},
100124
},
101-
URL: URL,
125+
Captions: captions,
126+
URL: URL,
102127
}, nil
103128
}

0 commit comments

Comments
 (0)