Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b21e3b1e7 | |||
| 27ab075da1 |
24
api/bludv.go
24
api/bludv.go
@@ -152,6 +152,30 @@ func getTorrentsBluDV(ctx context.Context, i *Indexer, link string) ([]schema.In
|
||||
magnetLinks = append(magnetLinks, magnetLink)
|
||||
})
|
||||
|
||||
adwareLinks := textContent.Find("a[href^=\"https://www.seuvideo.xyz\"]")
|
||||
adwareLinks.Each(func(_ int, s *goquery.Selection) {
|
||||
href, _ := s.Attr("href")
|
||||
// extract querysting "id" from url
|
||||
parsedUrl, err := url.Parse(href)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
magnetLink := parsedUrl.Query().Get("id")
|
||||
magnetLinkDecoded, err := utils.DecodeAdLink(magnetLink)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to decode ad link \"%s\": %v\n", href, err)
|
||||
return
|
||||
}
|
||||
|
||||
// if decoded magnet link is indeed a magnet link, append it
|
||||
if strings.HasPrefix(magnetLinkDecoded, "magnet:") {
|
||||
magnetLinks = append(magnetLinks, magnetLinkDecoded)
|
||||
} else {
|
||||
fmt.Printf("WARN: link \"%s\" decoding resulted in non-magnet link: %s\n", href, magnetLinkDecoded)
|
||||
}
|
||||
})
|
||||
|
||||
var audio []schema.Audio
|
||||
var year string
|
||||
var size []string
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/felipemarinho97/torrent-indexer/cache"
|
||||
"github.com/felipemarinho97/torrent-indexer/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -77,8 +78,8 @@ func (i *Requster) GetDocument(ctx context.Context, url string) (io.ReadCloser,
|
||||
fmt.Printf("request served from plain client: %s\n", url)
|
||||
}
|
||||
|
||||
// save response to cache if it's not a challange and body is not empty
|
||||
if !hasChallange(bodyByte) && len(bodyByte) > 0 {
|
||||
// save response to cache if it's not a challange, body is not empty and is valid HTML
|
||||
if !hasChallange(bodyByte) && len(bodyByte) > 0 && utils.IsValidHTML(string(bodyByte)) {
|
||||
err = i.c.SetWithExpiration(ctx, key, bodyByte, i.shortLivedCacheExpiration)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to save response to cache: %v\n", err)
|
||||
|
||||
28
utils/decoder.go
Normal file
28
utils/decoder.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"html"
|
||||
)
|
||||
|
||||
func DecodeAdLink(encodedStr string) (string, error) {
|
||||
reversed := reverseString(encodedStr)
|
||||
|
||||
decodedBytes, err := base64.StdEncoding.DecodeString(reversed)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
htmlUnescaped := html.UnescapeString(string(decodedBytes))
|
||||
|
||||
return htmlUnescaped, nil
|
||||
}
|
||||
|
||||
// Helper function to reverse a string
|
||||
func reverseString(s string) string {
|
||||
runes := []rune(s)
|
||||
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
|
||||
runes[i], runes[j] = runes[j], runes[i]
|
||||
}
|
||||
return string(runes)
|
||||
}
|
||||
Reference in New Issue
Block a user