Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
daite committed Jul 20, 2024
1 parent 954b7ae commit a26861a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
Binary file added angel
Binary file not shown.
41 changes: 28 additions & 13 deletions cmd/angel/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"fmt"
"log"
"os"

"github.com/daite/angel/common"
Expand All @@ -14,11 +13,6 @@ import (
var version = "0.7.0"

func main() {
cli.VersionFlag = &cli.BoolFlag{
Name: "print-version",
Aliases: []string{"V"},
Usage: "print only the version",
}
app := &cli.App{
Name: "angel",
Usage: "search torrent magnet!",
Expand All @@ -29,13 +23,29 @@ func main() {
Aliases: []string{"l"},
Usage: "choose torrent sites (kr or jp)",
},
// Removed the `version` flag from here
},
Action: func(c *cli.Context) error {
keyword := "동상이몽2"
if c.NArg() > 0 {
keyword = c.Args().Get(0)
// Handle the -v flag to print the version
if c.Bool("version") {
fmt.Printf("%s version %s\n", c.App.Name, c.App.Version)
return nil
}

// Print usage information if no arguments are provided
if c.Args().Len() == 0 && !c.IsSet("lang") {
cli.ShowAppHelp(c)
return nil
}
if c.String("lang") == "kr" {

// Print usage information if the -l flag is provided
if c.IsSet("lang") {
cli.ShowAppHelp(c)
return nil
}

// Proceed with regular processing if a language is specified
if lang := c.String("lang"); lang == "kr" {
s := []common.Scraping{
&ktorrent.TorrentMobile{},
&ktorrent.TorrentView{},
Expand All @@ -49,7 +59,7 @@ func main() {
}
s = common.GetAvailableSites(s)
fmt.Printf("[*] Angel found %d available site(s) ...\n", len(s))
data := common.CollectData(s, keyword)
data := common.CollectData(s, "")
common.PrintData(data)
} else {
s := []common.ScrapingEx{
Expand All @@ -58,14 +68,19 @@ func main() {
}
s = common.GetAvailableSitesEx(s)
fmt.Printf("[*] Angel found %d available site(s) ...\n", len(s))
data := common.CollectDataEx(s, keyword)
data := common.CollectDataEx(s, "")
common.PrintDataEx(data)
}
return nil
},
// Use the default error handling for CLI, which avoids the redefined error
}

// Run the app
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
// Log errors
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
4 changes: 3 additions & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func CheckNetWorkFromURL(url string) bool {

// GetAvailableSites function gets available torrent sites
func GetAvailableSites(oldItems []Scraping) []Scraping {
UpdateTorrentURL()
fmt.Println("[*] Angel is checking available torrent sites ...")
newItems := make([]Scraping, 0)
items := []string{
Expand Down Expand Up @@ -226,6 +227,7 @@ func GetAvailableSites(oldItems []Scraping) []Scraping {

// GetAvailableSitesEx function gets available torrent sites
func GetAvailableSitesEx(oldItems []ScrapingEx) []ScrapingEx {
UpdateTorrentURL()
fmt.Println("[*] Angel is checking available torrent sites ...")
newItems := make([]ScrapingEx, 0)
items := []string{"nyaa", "sukebe"}
Expand Down Expand Up @@ -339,7 +341,7 @@ func generateBar(percentage int) string {
return bar
}

func init() {
func UpdateTorrentURL() {
total := len(TorrentURL)
successes := 0
failures := 0
Expand Down

0 comments on commit a26861a

Please sign in to comment.