typo
[hotformathCLI/.git] / hotformathCLI.go
1 package main
2
3 import (
4         "context"
5         "fmt"
6         "os"
7
8         "github.com/rocketlaunchr/google-search"
9 )
10
11 func main() {
12     ctx := context.Background()
13     opts := googlesearch.SearchOptions{
14     Limit: 3,
15     CountryCode: "us",
16     LanguageCode: "en",
17     }
18
19
20
21     common:=" -inurl:(jsp|pl|php|html|aspx|htm|cf|shtml) -inurl:(index_of|listen77|mp3raid|mp3toss|mp3drug|index_of|wallywashis) intitle:\"index.of./\" "
22
23     VIDEO:=" (avi|mkv|mov|mp4|mpg|wmv)"
24     AUDIO:=" (ac3|flac|m4a|mp3|ogg|wav|wma)"
25     EBOOK:=" (CBZ|CBR|CHM|DOC|DOCX|EPUB|MOBI|ODT|PDF|RTF|txt)"
26     PICTURES:=" (bmp|gif|jpg|png|psd|tif|tiff)"
27     SOFTWARE:=" (apk|exe|iso|rar|tar|zip)"
28     COMPRESSED:=" (7z|bz2|gz|iso|rar|zip)"
29
30     // implement getModifier()
31
32     modifier:=""
33     switch os.Args[1] {
34         case "-v":
35             modifier = VIDEO
36         case "-a":
37             modifier = AUDIO
38         case "-e":
39             modifier = EBOOK
40         case "-p":
41             modifier = PICTURES
42         case "-s":
43             modifier = SOFTWARE
44         case "-c":
45             modifier = COMPRESSED
46         default:
47             fmt.Println("Usage: scrapper -[flag] \"[your search]\"")
48             fmt.Println("flags = [a]udio [c]ompressed [e]book [p]ictures [s]oftware [v]ideo")
49             os.Exit(0)
50     }
51
52     query := "intext:\"" + os.Args[2] + "\"" + common + modifier
53
54
55     returnLinks, err := googlesearch.Search(ctx, query, opts)
56     if err != nil {
57         fmt.Println("Something went wrong: ", err)
58     return
59     }
60     if len(returnLinks) == 0 {
61         fmt.Println("no results returned: ", returnLinks)
62     }
63
64     for _, result := range returnLinks {
65         fmt.Println("*", result.URL)
66
67     }
68 }