Skip to content

Commit

Permalink
add ptvicomo site
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Dec 7, 2023
1 parent 3393e7a commit 5957a73
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
15 changes: 11 additions & 4 deletions cmd/cookiecloud/importsites/importsites.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
profile = ""
siteProxy = ""
siteUa = ""
siteJa3 = ""
)

var command = &cobra.Command{
Expand All @@ -40,6 +41,7 @@ func init() {
command.Flags().StringVarP(&profile, "profile", "", "", "Comma-separated string, Set the used cookiecloud profile name(s). If not set, All cookiecloud profiles in config will be used")
command.Flags().StringVarP(&siteProxy, "site-proxy", "", "", "Set the proxy for imported sites")
command.Flags().StringVarP(&siteUa, "site-ua", "", "", "Set the user-agent for imported sites")
command.Flags().StringVarP(&siteJa3, "site-ja3", "", "", "Set the client TLS ja3 fingerprint for imported sites")
cookiecloud.Command.AddCommand(command)
}

Expand Down Expand Up @@ -94,17 +96,22 @@ func importsites(cmd *cobra.Command, args []string) error {
continue
}
newsiteconfig := &config.SiteConfigStruct{Type: tplname, Cookie: cookie,
Proxy: siteProxy, UserAgent: siteUa}
Proxy: siteProxy, UserAgent: siteUa, Ja3: siteJa3}
siteInstance, err := site.CreateSiteInternal(tplname, newsiteconfig, config.Get())
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (create instance error: %v",
tplname, cookiecloudData.Label, err)
continue
}
sitestatus, err := siteInstance.GetStatus()
if err != nil || !sitestatus.IsOk() {
log.Debugf("New Site %s from cookiecloud %s is invalid (status error=%v, valid=%t)",
tplname, cookiecloudData.Label, err, sitestatus.IsOk())
if err != nil {
log.Debugf("New Site %s from cookiecloud %s is invalid (status error=%v)",
tplname, cookiecloudData.Label, err)
continue
}
if !sitestatus.IsOk() {
log.Debugf("New Site %s from cookiecloud %s is invalid (invalid status)",
tplname, cookiecloudData.Label)
continue
}
log.Infof("✓✓New site %s from cookiecloud %s is valid (username: %s)",
Expand Down
11 changes: 8 additions & 3 deletions cmd/cookiecloud/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,14 @@ func sync(cmd *cobra.Command, args []string) error {
continue
}
sitestatus, err := siteInstance.GetStatus()
if err != nil || !sitestatus.IsOk() {
log.Debugf("Site %s new cookie from cookiecloud %s is invalid (status error=%v, valid=%t)",
sitename, cookiecloudData.Label, err, sitestatus.IsOk())
if err != nil {
log.Debugf("Site %s new cookie from cookiecloud %s is invalid (status error=%v)",
sitename, cookiecloudData.Label, err)
continue
}
if !sitestatus.IsOk() {
log.Debugf("Site %s new cookie from cookiecloud %s is invalid (invalid status)",
sitename, cookiecloudData.Label)
continue
}
log.Infof("✓✓site %s new cookie from cookiecloud %s is OK (username: %s)",
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type SiteConfigStruct struct {
HttpHeaders *map[string]string `yaml:"httpHeaders"`
NoDefaultHttpHeaders bool `yaml:"noDefaultHttpHeaders"`
Ja3 string `yaml:"ja3"`
Ja3ForceAttemptHTTP2 bool `yaml:"ja3ForceAttemptHTTP2"`
Proxy string `yaml:"proxy"`
Insecure bool `yaml:"insecure"` // 访问站点时跳过TLS证书安全校验
TorrentUploadSpeedLimit string `yaml:"torrentUploadSpeedLimit"`
Expand Down
4 changes: 3 additions & 1 deletion site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ func CreateSiteHttpClient(siteConfig *config.SiteConfigStruct, config *config.Co
if err != nil {
return nil, fmt.Errorf("failed to create site http transport ja3: %v", err)
}
transport.ForceAttemptHTTP2 = true
if siteConfig.Ja3ForceAttemptHTTP2 {
transport.ForceAttemptHTTP2 = true
}
} else {
transport = &http.Transport{}
}
Expand Down
7 changes: 7 additions & 0 deletions site/tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ var (
SelectorTorrentDiscountEndTime: `.free + span`,
Comment: "PTT",
},
"ptvicomo": {
Type: "nexusphp",
Url: "https://ptvicomo.net/",
TorrentsExtraUrls: []string{"special.php"},
// 该网站可能需要配置 ja3 才能正常访问
Comment: "象站",
},
"rousi": {
Type: "nexusphp",
Url: "https://rousi.zip/",
Expand Down

0 comments on commit 5957a73

Please sign in to comment.