highlights

package
v0.0.0-...-bcdd4fe Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:     "highlights",
	Short:   "Get highlights of a user",
	Example: "goinsta user highlights robpike",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			fmt.Println("Missing arguments. See example.")
			return
		}
		cmd = cmd.Root()

		output, err := cmd.Flags().GetString("output")
		if err != nil || output == "" {
			output = "./" + args[0] + "/highlights/"
		}
		inst := utils.New()

		user, err := inst.Profiles.ByName(args[0])
		if err != nil {
			id, _ := strconv.ParseInt(args[0], 10, 64)
			user, err = inst.Profiles.ByID(id)
			if err != nil {
				fmt.Printf("Invalid username or id: %s\n", args[0])
				os.Exit(1)
			}
		}

		hlgts, err := user.Highlights()
		if err != nil {
			fmt.Printf("error getting highlights: %s\n", err)
			os.Exit(1)
		}

		fmt.Println("Downloading highlights of", user.Username)
		for _, h := range hlgts {
			pgb := pb.StartNew(len(h.Items))
			for _, item := range h.Items {
				_, _, err := item.Download(output, "")
				if err != nil {
					fmt.Println(err)
				}
				pgb.Add(1)
			}
			pgb.Finish()
		}
	},
}

RootCmd is used as a command line interaction with Instagram get user highlight methods.

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