@@ -11,27 +11,27 @@ import (
11
11
)
12
12
13
13
// scrape1337x returns the scraped results in Result type
14
- func (s * Scraper ) scrape1337x (context * QueryContext ) (results []Result , err error ) {
14
+ func (s * Scraper ) scrape1337x (context * QueryContext ) ([]Result , error ) {
15
15
16
16
var links []string
17
- var movielist []movie.Movie
18
- results = make ( []Result , 0 )
17
+ var movieList []movie.Movie
18
+ var results []Result
19
19
20
20
url := fmt .Sprintf ("https://1337x.to/search/%s/1/" , context .Query )
21
21
22
22
s .collector .OnHTML ("tr" , func (e * colly.HTMLElement ) {
23
23
24
24
doc := e .DOM
25
- anchortags := doc .Find ("a" ).Siblings ()
25
+ anchorTags := doc .Find ("a" ).Siblings ()
26
26
27
- if attr , exists := anchortags .Attr ("href" ); exists {
27
+ if attr , exists := anchorTags .Attr ("href" ); exists {
28
28
if strings .Contains (attr , "/torrent/" ) && ! strings .HasPrefix (attr , "http://" ) {
29
29
link := "https://1337x.to" + attr
30
30
links = append (links , link )
31
31
}
32
32
}
33
33
newmovie := movieFromString (doc )
34
- movielist = append (movielist , newmovie )
34
+ movieList = append (movieList , newmovie )
35
35
36
36
})
37
37
s .collector .OnHTML ("div.col-9 div.box-info" , func (h * colly.HTMLElement ) {
@@ -42,9 +42,9 @@ func (s *Scraper) scrape1337x(context *QueryContext) (results []Result, err erro
42
42
metadata .Find ("a" ).Each (func (i int , s * goquery.Selection ) {
43
43
if magnet , exists := s .Attr ("href" ); exists {
44
44
if strings .Contains (magnet , "magnet" ) {
45
- for i , movie := range movielist {
46
- if compareNamesfromdifferentPages (strings .TrimSpace (movie .Name ), strings .TrimSpace (movieName )) {
47
- movielist [i ].Magnet = magnet
45
+ for i , movie := range movieList {
46
+ if compareNamesFromDiffPages (strings .TrimSpace (movie .Name ), strings .TrimSpace (movieName )) {
47
+ movieList [i ].Magnet = magnet
48
48
}
49
49
}
50
50
}
@@ -56,10 +56,10 @@ func (s *Scraper) scrape1337x(context *QueryContext) (results []Result, err erro
56
56
for _ , link := range links {
57
57
s .collector .Visit (link )
58
58
}
59
- for _ , movie := range movielist [1 :] {
59
+ for _ , movie := range movieList [1 :] {
60
60
results = append (results , movie )
61
61
}
62
- return
62
+ return results , nil
63
63
}
64
64
65
65
// movieFromString returns a type Movie
@@ -73,8 +73,8 @@ func movieFromString(document *goquery.Selection) movie.Movie {
73
73
}
74
74
}
75
75
76
- // string comparison
77
- func compareNamesfromdifferentPages (a string , b string ) bool {
76
+ // compareNamesFromDiffPages compares the movie name on different pages
77
+ func compareNamesFromDiffPages (a string , b string ) bool {
78
78
79
79
if len (a ) == 0 || len (b ) == 0 {
80
80
return false
0 commit comments