func (m *MirrorScraper) PickMirror(query string) (*Mirror, error) {
	mirrors, err := m.GetMirrors()
	if err != nil {
		return nil, err
	}
	mirror, _, err := m.getTorrents(mirrors, query, true)
	return mirror, err
}
PickMirror fetches all available Pirate Bay mirrors and returns the first one that responds to HTTP get for the given query.
package torrents
import (
	"errors"
	"flag"
	"log"
	"os"
	"regexp"
	"strconv"
	"strings"
	"time"
	"goirate/utils"
	"github.com/PuerkitoBio/goquery"
)
const defaultProxySourceURL string = "https://proxybay.github.io/"
type Mirror struct {
	URL     string `json:"url"`
	Country string `json:"country"`
	Status  bool   `json:"status"`
}
func FallbackMirror() Mirror {
	return Mirror{
		URL:     "https://thepiratebay.org",
		Country: "US",
	}
}
type MirrorScraper struct {
	proxySourceURL string
	mirrorFilters  MirrorFilters
}
type MirrorFilters struct {
	Preferred string   `toml:"preferred"`
	Whitelist []string `toml:"whitelist"`
	Blacklist []string `toml:"blacklist"`
}
func NewMirrorScraper(proxySourceURL string, mirrorFilters MirrorFilters) *MirrorScraper {
	return &MirrorScraper{
		proxySourceURL: proxySourceURL,
		mirrorFilters:  mirrorFilters,
	}
}
func (m *MirrorScraper) SetProxySourceURL(url string) {
	m.proxySourceURL = url
}
func (m *MirrorScraper) GetProxySourceURL() string {
	if m.proxySourceURL == "" {
		return defaultProxySourceURL
	}
	return m.proxySourceURL
}
func (m *MirrorScraper) GetMirrors() ([]Mirror, error) {
	doc, err := utils.HTTPGet(m.GetProxySourceURL())
	if err != nil {
		return nil, err
	}
	return m.parseMirrors(doc), nil
}
func (m *MirrorScraper) GetTorrents(query string) ([]Torrent, error) {
	mirrors, err := m.GetMirrors()
	if err != nil {
		return nil, err
	}
	_, torrents, err := m.getTorrents(mirrors, query, true)
	return torrents, err
}