Merge pull request #1 from felipemarinho97/feat/imbd-support
Feat/imbd support
This commit is contained in:
20
api/bludv.go
20
api/bludv.go
@@ -80,10 +80,10 @@ func (i *Indexer) HandlerBluDVIndexer(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if len(indexedTorrents) == 0 {
|
json.NewEncoder(w).Encode(Response{
|
||||||
w.WriteHeader(http.StatusNotFound)
|
Results: indexedTorrents,
|
||||||
}
|
Count: len(indexedTorrents),
|
||||||
json.NewEncoder(w).Encode(indexedTorrents)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTorrentsBluDV(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent, error) {
|
func getTorrentsBluDV(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent, error) {
|
||||||
@@ -146,6 +146,17 @@ func getTorrentsBluDV(ctx context.Context, i *Indexer, link string) ([]IndexedTo
|
|||||||
size = append(size, findSizesFromText(text)...)
|
size = append(size, findSizesFromText(text)...)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// find any link from imdb
|
||||||
|
imdbLink := ""
|
||||||
|
article.Find("div.content a").Each(func(i int, s *goquery.Selection) {
|
||||||
|
link, _ := s.Attr("href")
|
||||||
|
re := regexp.MustCompile(`https://www.imdb.com/title/(tt\d+)`)
|
||||||
|
matches := re.FindStringSubmatch(link)
|
||||||
|
if len(matches) > 0 {
|
||||||
|
imdbLink = matches[0]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
size = stableUniq(size)
|
size = stableUniq(size)
|
||||||
|
|
||||||
var chanIndexedTorrent = make(chan IndexedTorrent)
|
var chanIndexedTorrent = make(chan IndexedTorrent)
|
||||||
@@ -193,6 +204,7 @@ func getTorrentsBluDV(ctx context.Context, i *Indexer, link string) ([]IndexedTo
|
|||||||
OriginalTitle: title,
|
OriginalTitle: title,
|
||||||
Details: link,
|
Details: link,
|
||||||
Year: year,
|
Year: year,
|
||||||
|
IMDB: imdbLink,
|
||||||
Audio: magnetAudio,
|
Audio: magnetAudio,
|
||||||
MagnetLink: magnetLink,
|
MagnetLink: magnetLink,
|
||||||
Date: date,
|
Date: date,
|
||||||
|
|||||||
@@ -97,10 +97,10 @@ func (i *Indexer) HandlerComandoIndexer(w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if len(indexedTorrents) == 0 {
|
json.NewEncoder(w).Encode(Response{
|
||||||
w.WriteHeader(http.StatusNotFound)
|
Results: indexedTorrents,
|
||||||
}
|
Count: len(indexedTorrents),
|
||||||
json.NewEncoder(w).Encode(indexedTorrents)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTorrents(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent, error) {
|
func getTorrents(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent, error) {
|
||||||
@@ -163,6 +163,17 @@ func getTorrents(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent
|
|||||||
size = append(size, findSizesFromText(text)...)
|
size = append(size, findSizesFromText(text)...)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// find any link from imdb
|
||||||
|
imdbLink := ""
|
||||||
|
article.Find("div.content a").Each(func(i int, s *goquery.Selection) {
|
||||||
|
link, _ := s.Attr("href")
|
||||||
|
re := regexp.MustCompile(`https://www.imdb.com/title/(tt\d+)`)
|
||||||
|
matches := re.FindStringSubmatch(link)
|
||||||
|
if len(matches) > 0 {
|
||||||
|
imdbLink = matches[0]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
size = stableUniq(size)
|
size = stableUniq(size)
|
||||||
|
|
||||||
var chanIndexedTorrent = make(chan IndexedTorrent)
|
var chanIndexedTorrent = make(chan IndexedTorrent)
|
||||||
@@ -210,6 +221,7 @@ func getTorrents(ctx context.Context, i *Indexer, link string) ([]IndexedTorrent
|
|||||||
OriginalTitle: title,
|
OriginalTitle: title,
|
||||||
Details: link,
|
Details: link,
|
||||||
Year: year,
|
Year: year,
|
||||||
|
IMDB: imdbLink,
|
||||||
Audio: magnetAudio,
|
Audio: magnetAudio,
|
||||||
MagnetLink: magnetLink,
|
MagnetLink: magnetLink,
|
||||||
Date: date,
|
Date: date,
|
||||||
|
|||||||
@@ -18,11 +18,17 @@ type IndexerMeta struct {
|
|||||||
SearchURL string
|
SearchURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Response struct {
|
||||||
|
Results []IndexedTorrent `json:"results"`
|
||||||
|
Count int `json:"count"`
|
||||||
|
}
|
||||||
|
|
||||||
type IndexedTorrent struct {
|
type IndexedTorrent struct {
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
OriginalTitle string `json:"original_title"`
|
OriginalTitle string `json:"original_title"`
|
||||||
Details string `json:"details"`
|
Details string `json:"details"`
|
||||||
Year string `json:"year"`
|
Year string `json:"year"`
|
||||||
|
IMDB string `json:"imdb"`
|
||||||
Audio []schema.Audio `json:"audio"`
|
Audio []schema.Audio `json:"audio"`
|
||||||
MagnetLink string `json:"magnet_link"`
|
MagnetLink string `json:"magnet_link"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
|
|||||||
Reference in New Issue
Block a user