diff --git a/cmd/root.go b/cmd/root.go index 9006e8b..7a6d48b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,14 +12,11 @@ import ( // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "genread-api", - Short: "A brief description of your application", - Long: `A longer description that spans multiple lines and likely contains -examples and usage of using your application. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, + Use: "clibgen", + Short: "library gensis command line / terminal client", + Long: ` +clibgen is a CLI application to search and download epubs, pdfs, from library genesis. +Useful if you are lazy to open up a browser to download e-books/resources.'`, // Uncomment the following line if your bare application // has an action associated with it: // Run: func(cmd *cobra.Command, args []string) { }, diff --git a/cmd/search.go b/cmd/search.go index 175cefd..d1be924 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -12,13 +12,10 @@ import ( // searchCmd represents the search command var searchCmd = &cobra.Command{ Use: "search", - Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: - -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, + Short: "library gensis command line / terminal client", + Long: ` +clibgen is a CLI application to search and download epubs, pdfs, from library genesis. +Useful if you are lazy to open up a browser to download e-books/resources.'`, Run: func(cmd *cobra.Command, args []string) { books, err := api.SearchBookByTitle(args[0], 5) if err != nil { diff --git a/pkg/api/book.go b/pkg/api/book.go index 5ae008a..1136a88 100644 --- a/pkg/api/book.go +++ b/pkg/api/book.go @@ -10,5 +10,3 @@ type Book struct { Extension string `json:"extension"` Mirrors []string `json:"mirrors"` } - -type BookService interface{} diff --git a/pkg/api/libgen.go b/pkg/api/libgen.go index 4b784cc..1cc7f36 100644 --- a/pkg/api/libgen.go +++ b/pkg/api/libgen.go @@ -78,7 +78,7 @@ func getLinkFromDocument(document *goquery.Document) (string, bool) { } func getDirectDownloadLink(link string) string { - log.Println("Downloading book ", link) + log.Println("Downloading book from: ", link) resp, err := http.Get(link) @@ -110,7 +110,6 @@ func getDirectDownloadLink(link string) string { return "" } -// TODO: Introduce proper types with pagination func SearchBookByTitle(query string, limit int) ([]Book, error) { var e error queryString := fmt.Sprintf("https://libgen.is/search.php?req=%s&res=25&view=simple&phrase=1&column=def", url.QueryEscape(query))