Skip to content

Commit

Permalink
tweak xseedadd cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Mar 3, 2024
1 parent d2a7118 commit 36312f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
18 changes: 15 additions & 3 deletions cmd/xseedadd/xseedadd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ var (
addCategory = ""
addTags = ""
defaultSite = ""
category = ""
tag = ""
filter = ""
)

func init() {
Expand All @@ -52,6 +55,9 @@ func init() {
command.Flags().StringVarP(&addCategory, "add-category", "", "",
"Manually set category of added xseed torrent. By Default it uses the original torrent's")
command.Flags().StringVarP(&addTags, "add-tags", "", "", "Set tags of added xseed torrent (comma-separated)")
command.Flags().StringVarP(&category, "category", "", "", "Only xseed torrents that belongs to this category")
command.Flags().StringVarP(&tag, "tag", "", "", "Only xseed torrents that has this tag")
command.Flags().StringVarP(&filter, "filter", "", "", "Only xseed torrents which name contains this")
cmd.RootCmd.AddCommand(command)
}

Expand All @@ -62,7 +68,7 @@ func xseedadd(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("failed to create client: %v", err)
}
clientTorrents, err := clientInstance.GetTorrents("", "", true)
clientTorrents, err := clientInstance.GetTorrents("seeding", category, true)
if err != nil {
return fmt.Errorf("failed to get client torrents: %v", err)
}
Expand All @@ -71,7 +77,7 @@ func xseedadd(cmd *cobra.Command, args []string) error {
fixedTags = util.SplitCsv(addTags)
}
clientTorrents = util.Filter(clientTorrents, func(t client.Torrent) bool {
return t.IsFullComplete() && t.State == "seeding"
return t.IsFullComplete() && !t.HasTag(config.NOXSEED_TAG) && (tag == "" || t.HasTag(tag))
})
sort.Slice(clientTorrents, func(i, j int) bool {
if clientTorrents[i].Size != clientTorrents[j].Size {
Expand All @@ -84,7 +90,13 @@ func xseedadd(cmd *cobra.Command, args []string) error {
if clientTorrents[j].Category == config.XSEED_TAG || clientTorrents[j].HasTag(config.XSEED_TAG) {
b = 1
}
return a < b
if a != b {
return a < b
}
if clientTorrents[i].Name != clientTorrents[j].Name {
return clientTorrents[i].Name < clientTorrents[j].Name
}
return clientTorrents[i].InfoHash < clientTorrents[j].InfoHash
})
errorCnt := int64(0)
for _, torrent := range torrents {
Expand Down
14 changes: 7 additions & 7 deletions site/tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@ var (
Url: "https://www.dragonhd.xyz/",
Comment: "龍之家",
},
"eastgame": {
Type: "nexusphp",
Aliases: []string{"tlfbits", "tlf"},
Url: "https://pt.eastgame.org/",
TorrentsExtraUrls: []string{"trls.php"},
Comment: "吐鲁番",
},
// need heavy work to support it
// "filelist": {
// Type: "nexusphp",
Expand Down Expand Up @@ -512,6 +505,13 @@ var (
Url: "https://et8.org/",
Comment: "精品论坛,他吹吹风",
},
"tlfbits": {
Type: "nexusphp",
Aliases: []string{"eastgame", "tlf"},
Url: "https://pt.eastgame.org/",
TorrentsExtraUrls: []string{"trls.php"},
Comment: "吐鲁番",
},
"totheglory": {
Type: "nexusphp",
Aliases: []string{"ttg"},
Expand Down

0 comments on commit 36312f6

Please sign in to comment.