Skip to content

Commit

Permalink
update ua to chrome v116
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Sep 11, 2023
1 parent 1b897bf commit d704e64
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/batchdl/batchdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func init() {
command.Flags().BoolVarP(&freeOnly, "free", "", false, "Skip none-free torrent")
command.Flags().BoolVarP(&noPaid, "no-paid", "", false, "Skip paid (use bonus points) torrent")
command.Flags().BoolVarP(&largestFlag, "largest", "l", false, `Sort site torrents by size in desc order. Equivalent with "--sort size --order desc"`)
command.Flags().BoolVarP(&newestFlag, "newest", "n", false, `Download newest torrents of site. Equivalent with "--sort time --order desc --one-page --start-page 0"`)
command.Flags().BoolVarP(&newestFlag, "newest", "n", false, `Download newest torrents of site. Equivalent with "--sort time --order desc --one-page"`)
command.Flags().BoolVarP(&addRespectNoadd, "add-respect-noadd", "", false, "Used with '--action add'. Check and respect _noadd flag in client")
command.Flags().BoolVarP(&nohr, "no-hr", "", false, "Skip torrent that has any type of HnR (Hit and Run) restriction")
command.Flags().BoolVarP(&allowBreak, "break", "", false, "Break (stop finding more torrents) if all torrents of current page do not meet criterion")
Expand Down
6 changes: 3 additions & 3 deletions cmd/show/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If no flags or args are provided, it will display current active torrents.`,
}

var (
largest bool
largestFlag bool
showTrackers bool
showFiles bool
showInfoHashOnly bool
Expand All @@ -46,7 +46,7 @@ var (

func init() {
command.Flags().Int64VarP(&maxTorrents, "max-torrents", "", 0, "Show at most this number of torrents. Default (0) == unlimited")
command.Flags().BoolVarP(&largest, "largest", "l", false, "Show largest torrents first. Equavalent with '--sort size --order desc'")
command.Flags().BoolVarP(&largestFlag, "largest", "l", false, "Show largest torrents first. Equavalent with '--sort size --order desc'")
command.Flags().BoolVarP(&showAll, "all", "a", false, "Show all torrents. Equavalent with pass a '_all' arg")
command.Flags().BoolVarP(&showRaw, "raw", "", false, "Show torrent size in raw format")
command.Flags().BoolVarP(&showJson, "json", "", false, "Show output in json format")
Expand Down Expand Up @@ -76,7 +76,7 @@ func show(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to create client: %v", err)
}
desc := false
if largest {
if largestFlag {
sortFlag = "size"
desc = true
}
Expand Down
16 changes: 16 additions & 0 deletions cmd/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var (
showAll = false
showAllClients = false
showAllSites = false
largestFlag = false
newestFlag = false
)

var command = &cobra.Command{
Expand All @@ -46,11 +48,16 @@ func init() {
command.Flags().BoolVarP(&showAllSites, "sites", "s", false, "Show all sites")
command.Flags().BoolVarP(&showTorrents, "torrents", "t", false, "Show torrents (active torrents for client / latest torrents for site)")
command.Flags().BoolVarP(&showFull, "full", "f", false, "Show full info of each client or site")
command.Flags().BoolVarP(&largestFlag, "largest", "l", false, `Sort site torrents by size in desc order"`)
command.Flags().BoolVarP(&newestFlag, "newest", "n", false, `Sort site torrents by time in desc order (newest first)"`)
cmd.RootCmd.AddCommand(command)
}

func status(cmd *cobra.Command, args []string) error {
names := args
if largestFlag && newestFlag {
return fmt.Errorf("--largest and --newest flags are NOT compatible")
}
if showAll || showAllClients || showAllSites {
if len(args) > 0 {
return fmt.Errorf("--all, --clients, --sites flags cann't be used with site or client names")
Expand Down Expand Up @@ -194,6 +201,15 @@ func status(cmd *cobra.Command, args []string) error {
}
if response.SiteTorrents != nil {
fmt.Printf("\n")
if largestFlag {
sort.Slice(response.SiteTorrents, func(i, j int) bool {
return response.SiteTorrents[i].Size > response.SiteTorrents[j].Size
})
} else if newestFlag {
sort.Slice(response.SiteTorrents, func(i, j int) bool {
return response.SiteTorrents[i].Time > response.SiteTorrents[j].Time
})
}
site.PrintTorrents(response.SiteTorrents, filter, now, false, dense)
if i != len(responses)-1 {
fmt.Printf("\n")
Expand Down
4 changes: 2 additions & 2 deletions util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ var (
"Accept-Language": "en-US,en;q=0.9",
"Cache-Control": "max-age=0",
"Connection": "keep-alive",
"sec-ch-ua": `"Not/A)Brand";v="99", "Google Chrome";v="115", "Chromium";v="115"`,
"sec-ch-ua": `"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"`,
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": `"Windows"`,
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
}
)

Expand Down

0 comments on commit d704e64

Please sign in to comment.