Feat/Rede torrents (#34)

* new: feat: add brand new redetorrent.com indexer

* chg: refactor: create common package

* chg: fix: comandohds formatting

* chg: fix: dual audio detection

* chg: fix: parsing issues

* chg: refactor: remove duplicated code

* chg: refactor: move test funcs to common file
This commit is contained in:
2025-07-22 14:57:05 -03:00
committed by GitHub
parent 0b21e3b1e7
commit 782f9d6b3f
13 changed files with 762 additions and 327 deletions

View File

@@ -6,10 +6,10 @@ import (
"fmt"
"net/http"
"net/url"
"regexp"
"slices"
"strings"
"time"
"regexp"
"github.com/PuerkitoBio/goquery"
"github.com/hbollon/go-edlib"
@@ -146,7 +146,7 @@ func getTorrentsComandoHDs(ctx context.Context, i *Indexer, link string) ([]sche
article := doc.Find("article")
title := title_re.ReplaceAllString(article.Find(".main_title > h1").Text(), "")
textContent := article.Find("div.content")
date := getPublishedDateTDF(doc)
date := getPublishedDateFromMeta(doc)
magnets := textContent.Find("a[href^=\"magnet\"]")
var magnetLinks []string
magnets.Each(func(i int, s *goquery.Selection) {
@@ -205,23 +205,15 @@ func getTorrentsComandoHDs(ctx context.Context, i *Indexer, link string) ([]sche
if err != nil {
fmt.Println(err)
}
releaseTitle := magnet.DisplayName
releaseTitle := strings.TrimSpace(magnet.DisplayName)
infoHash := magnet.InfoHash.String()
trackers := magnet.Trackers
magnetAudio := []schema.Audio{}
if strings.Contains(strings.ToLower(releaseTitle), "dual") || strings.Contains(strings.ToLower(releaseTitle), "dublado") {
magnetAudio = append(magnetAudio, audio...)
} else if len(audio) > 1 {
// remove portuguese audio, and append to magnetAudio
for _, a := range audio {
if a != schema.AudioPortuguese {
magnetAudio = append(magnetAudio, a)
}
}
} else {
magnetAudio = append(magnetAudio, audio...)
for i, tracker := range trackers {
trackers[i] = strings.TrimSpace(tracker)
}
magnetAudio := getAudioFromTitle(releaseTitle, audio)
peer, seed, err := goscrape.GetLeechsAndSeeds(ctx, i.redis, i.metrics, infoHash, trackers)
if err != nil {
fmt.Println(err)