Skip to content

Commit

Permalink
fix realjam again (#1128)
Browse files Browse the repository at this point in the history
Co-authored-by: crwxaj <crwxaj>
  • Loading branch information
crwxaj authored Feb 20, 2023
1 parent 84cd88c commit 8ab99b1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/scrape/realjamvr.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ func RealJamVR(wg *sync.WaitGroup, updateSite bool, knownScenes []string, out ch
e.ForEachWithBreak(`a[href^='download/']`, func(id int, e *colly.HTMLElement) bool {
trailerurl := sc.HomepageURL + "/" + e.Attr("href")
// url does not point directly to a file, need to resolve redirects with http.Head
resp, _ := http.Head(trailerurl)
parts := strings.Split(resp.Request.URL.String(), "attachment%3Bfilename%3D")
if len(parts) > 1 {
fileMaskTmp := strings.Split(parts[1], "&")[0]
tmp := strings.Split(fileMaskTmp, "_")
if len(tmp) > 4 {
fileMask = strings.TrimSuffix(tmp[0], "-Trailer") + "-Full_$res_$fps_" + tmp[3] + "_" + tmp[4]
return false
resp, err := http.Head(trailerurl)
if err == nil {
parts := strings.Split(resp.Request.URL.String(), "attachment%3Bfilename%3D")
if len(parts) > 1 {
fileMaskTmp := strings.Split(parts[1], "&")[0]
tmp := strings.Split(fileMaskTmp, "_")
if len(tmp) > 4 {
fileMask = strings.TrimSuffix(tmp[0], "-Trailer") + "-Full_$res_$fps_" + tmp[3] + "_" + tmp[4]
return false
}
}
}
return true
Expand Down

0 comments on commit 8ab99b1

Please sign in to comment.