Skip to content

Commit 6d88116

Browse files
committed
few modifications for code consistency
1 parent b208695 commit 6d88116

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

22
## Description
3-
A clear and concise description of what is the problem/issue in the website.
3+
Use of a single collector to scrape 1337x target
44

55
## Screenshots
66
Put any screenshot(s) here.
77

88
## Do you want to work on this issue?
9-
write yes or no
9+
yes
1010

1111
## How are you planning to resolve on this issue?
12-
Provide some information about the changes you'll be doing to resolve the issue.
12+
Introducing few code changes
1313

1414
## Are you raising this issue under hacktoberfest? (Remove this section if you are not a hacktoberfest participant)
1515
Yes, I'm raising this issue under hacktoberfest.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## Related Issue
2+
- Info about Issue or bug
3+
4+
Closes: #[49]
5+
6+
### Are you creating this PR under Hacktoberfest
7+
Yes, I'm opening this PR under hacktoberfest.
8+
9+
### Describe the changes you've made
10+
few code changes are done
11+
12+
### Checklist:
13+
<!--
14+
Example how to mark a checkbox:-
15+
- [x] My code follows the code style of this project.
16+
-->
17+
- [x] My code follows the style guidelines of this project.
18+
- [x] I have performed a self-review of my own code.
19+
- [x] I have commented my code, particularly in hard-to-understand areas.
20+
21+
### Screenshots
22+
Put any screenshot(s) of the project here.

PULL_REQUEST_TEMPLATE.md

-22
This file was deleted.

scraper/target1337x.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ import (
1111
)
1212

1313
// 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) {
1515

1616
var links []string
17-
var movielist []movie.Movie
18-
results = make([]Result, 0)
17+
var movieList []movie.Movie
18+
var results []Result
1919

2020
url := fmt.Sprintf("https://1337x.to/search/%s/1/", context.Query)
2121

2222
s.collector.OnHTML("tr", func(e *colly.HTMLElement) {
2323

2424
doc := e.DOM
25-
anchortags := doc.Find("a").Siblings()
25+
anchorTags := doc.Find("a").Siblings()
2626

27-
if attr, exists := anchortags.Attr("href"); exists {
27+
if attr, exists := anchorTags.Attr("href"); exists {
2828
if strings.Contains(attr, "/torrent/") && !strings.HasPrefix(attr, "http://") {
2929
link := "https://1337x.to" + attr
3030
links = append(links, link)
3131
}
3232
}
3333
newmovie := movieFromString(doc)
34-
movielist = append(movielist, newmovie)
34+
movieList = append(movieList, newmovie)
3535

3636
})
3737
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
4242
metadata.Find("a").Each(func(i int, s *goquery.Selection) {
4343
if magnet, exists := s.Attr("href"); exists {
4444
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
4848
}
4949
}
5050
}
@@ -56,10 +56,10 @@ func (s *Scraper) scrape1337x(context *QueryContext) (results []Result, err erro
5656
for _, link := range links {
5757
s.collector.Visit(link)
5858
}
59-
for _, movie := range movielist[1:] {
59+
for _, movie := range movieList[1:] {
6060
results = append(results, movie)
6161
}
62-
return
62+
return results, nil
6363
}
6464

6565
// movieFromString returns a type Movie
@@ -73,8 +73,8 @@ func movieFromString(document *goquery.Selection) movie.Movie {
7373
}
7474
}
7575

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 {
7878

7979
if len(a) == 0 || len(b) == 0 {
8080
return false

0 commit comments

Comments
 (0)