upload

package
v0.0.0-...-2c443e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UploadCmd = &cobra.Command{
	Use:     "upload",
	Aliases: []string{"u"},
	Short:   `Upload file to pikpak server`,
	Run: func(cmd *cobra.Command, args []string) {
		pikpak.Concurrent = uploadConcurrency
		p := pikpak.NewPikPak(conf.Config.Username, conf.Config.Password)
		err := p.Login()
		if err != nil {
			logrus.Error(err)
		}
		err = p.AuthCaptchaToken("POST:/drive/v1/files")
		if err != nil {
			logrus.Error(err)
		}

		go func() {
			ticker := time.NewTicker(time.Second * 7200 * 3 / 4)
			defer ticker.Stop()
			for range ticker.C {
				err := p.RefreshToken()
				if err != nil {
					logrus.Warn(err)
					continue
				}
			}
		}()
		for _, v := range args {
			stat, err := os.Stat(v)
			if err != nil {
				logrus.Errorf("Get file %s stat failed: %s", v, err)
				continue
			}
			if stat.IsDir() {
				handleUploadFolder(&p, v)
			} else {
				handleUploadFile(&p, v)
			}
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL