Skip to content

Commit

Permalink
Clean up scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon committed Oct 31, 2023
1 parent ac4a798 commit 4de2e75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion apps/client/src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func MakeConfig() *Config {
config := &Config{
OutputPath: "/data",
ApiPort: DefaultString(os.Getenv("API_PORT"), "80"),
MaxDownloadAge: time.Duration(DefaultInt(os.Getenv("MAX_DOWNLOAD_AGE"), 7)),
MaxDownloadAge: time.Duration(DefaultInt(os.Getenv("MAX_DOWNLOAD_AGE"), 21)),
}

return config
Expand Down
20 changes: 7 additions & 13 deletions apps/client/src/scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,18 @@ type Torrent struct {
}

type Scraper struct {
sources []Source
}

func MakeScraper() *Scraper {
scraper := &Scraper{
sources: []Source{},
}
scraper := &Scraper{}

return scraper
}

func (s *Scraper) RegisterSources() {
s.sources = []Source{}
s.RegisterSource(Make1337xSource())
}

func (s *Scraper) RegisterSource(source Source) {
s.sources = append(s.sources, source)
func (s *Scraper) GetSources() {
return[]Source{
Make1337xSource()
}
}

func (s *Scraper) Sort(torrents []Torrent) []Torrent {
Expand All @@ -56,10 +50,10 @@ func (s *Scraper) Sort(torrents []Torrent) []Torrent {
}

func (s *Scraper) Query(query string) ([]Torrent, error) {
s.RegisterSources()
sources := GetSources
var torrents []Torrent

for _, source := range s.sources {
for _, source := range sources {
c := colly.NewCollector(
colly.MaxDepth(2),
colly.Async(),
Expand Down

0 comments on commit 4de2e75

Please sign in to comment.