Documentation
¶
Overview ¶
Package scraper provides a modular interface for torrent search providers. It defines the Scraper interface and common types. Users can implement custom scrapers for their preferred sources or use the GenericScraper which works with any site that provides magnet links.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestSearch ¶
TestSearch performs a test search to verify the site works
Types ¶
type DummyScraper ¶
type DummyScraper struct {
// contains filtered or unexported fields
}
DummyScraper is a no-op scraper that returns empty results. It serves as the default scraper when no sources are configured, ensuring the TUI remains functional without any external dependencies.
func NewDummyScraper ¶
func NewDummyScraper() *DummyScraper
NewDummyScraper creates a dummy scraper that returns no results.
type ExampleScraper ¶
type ExampleScraper struct {
// contains filtered or unexported fields
}
ExampleScraper demonstrates how to implement the Scraper interface. This is a reference implementation for developers who want to create their own scraper for a specific site.
To create a custom scraper:
- Implement the Scraper interface (Name, Search, GetFiles)
- Parse HTML responses to extract torrent information
- Return properly populated Torrent structs
Example usage:
scraper := NewExampleScraper() results, err := scraper.Search(ctx, "query")
func NewExampleScraper ¶
func NewExampleScraper() *ExampleScraper
NewExampleScraper creates an example scraper instance. In a real implementation, you would pass configuration here such as the base URL, authentication credentials, etc.
func (*ExampleScraper) GetFiles ¶
func (s *ExampleScraper) GetFiles(ctx context.Context, t *Torrent) error
GetFiles fetches the file list for a torrent. This is called when viewing torrent details in the TUI. A real implementation would:
- Navigate to the torrent's detail page (using InfoURL)
- Parse the page to find file listings
- Populate the Files slice on the Torrent struct
- Optionally fetch the magnet link if not already present
func (*ExampleScraper) Name ¶
func (s *ExampleScraper) Name() string
Name returns the scraper's display name. This appears in the TUI's source list and search results.
func (*ExampleScraper) Search ¶
Search queries the source for torrents matching the query. This example returns empty results. A real implementation would:
- Construct a search URL with the query
- Make an HTTP request
- Parse the HTML response
- Extract torrent metadata (name, size, seeders, etc.)
- Return a slice of Torrent structs
type GenericScraper ¶
type GenericScraper struct {
// contains filtered or unexported fields
}
GenericScraper attempts to scrape any torrent site using heuristics
func NewGenericScraper ¶
func NewGenericScraper(name, baseURL string) *GenericScraper
NewGenericScraper creates a scraper for an arbitrary torrent site
type MultiScraper ¶
type MultiScraper struct {
// contains filtered or unexported fields
}
MultiScraper aggregates results from multiple sources
func NewMultiScraper ¶
func NewMultiScraper(scrapers ...Scraper) *MultiScraper
NewMultiScraper creates a scraper that queries multiple sources
type Scraper ¶
type Scraper interface {
// Name returns the source name
Name() string
// Search queries for torrents
Search(ctx context.Context, query string) ([]Torrent, error)
// GetFiles fetches file list for a torrent (if supported)
GetFiles(ctx context.Context, t *Torrent) error
}
Scraper interface for torrent search providers