new: feat: add bludv support

This commit is contained in:
2023-10-01 20:27:44 +00:00
parent ae124f4858
commit 67bf0cbf3e
5 changed files with 261 additions and 24 deletions

View File

@@ -18,10 +18,10 @@ import (
goscrape "github.com/felipemarinho97/torrent-indexer/scrape"
)
const (
URL = "https://comando.la/"
queryFilter = "?s="
)
var comando = IndexerMeta{
URL: "https://comando.la/",
SearchURL: "?s=",
}
var replacer = strings.NewReplacer(
"janeiro", "01",
@@ -38,21 +38,6 @@ var replacer = strings.NewReplacer(
"dezembro", "12",
)
type IndexedTorrent struct {
Title string `json:"title"`
OriginalTitle string `json:"original_title"`
Details string `json:"details"`
Year string `json:"year"`
Audio []schema.Audio `json:"audio"`
MagnetLink string `json:"magnet_link"`
Date time.Time `json:"date"`
InfoHash string `json:"info_hash"`
Trackers []string `json:"trackers"`
Size string `json:"size"`
LeechCount int `json:"leech_count"`
SeedCount int `json:"seed_count"`
}
func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
// supported query params: q, season, episode
@@ -60,9 +45,9 @@ func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request)
// URL encode query param
q = url.QueryEscape(q)
url := URL
url := comando.URL
if q != "" {
url = fmt.Sprintf("%s%s%s", URL, queryFilter, q)
url = fmt.Sprintf("%s%s%s", url, comando.SearchURL, q)
}
fmt.Println("URL:>", url)
@@ -90,7 +75,7 @@ func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request)
var itChan = make(chan []IndexedTorrent)
var errChan = make(chan error)
var indexedTorrents []IndexedTorrent
indexedTorrents := []IndexedTorrent{}
for _, link := range links {
go func(link string) {
torrents, err := getTorrents(ctx, i, link)
@@ -112,6 +97,9 @@ func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request)
}
w.Header().Set("Content-Type", "application/json")
if len(indexedTorrents) == 0 {
w.WriteHeader(http.StatusNotFound)
}
json.NewEncoder(w).Encode(indexedTorrents)
}
@@ -191,7 +179,7 @@ func getTorrents(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent
infoHash := magnet.InfoHash.String()
trackers := magnet.Trackers
magnetAudio := []schema.Audio{}
if strings.Contains(strings.ToLower(releaseTitle), "dual") {
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