Skip to content

Commit

Permalink
🚸 removed the url flag to make it more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Farrag committed Sep 19, 2023
1 parent d74e257 commit 22fcfcd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ igo [command]
- `--json/-j`: Export the users that don't follow you back in JSON format.
- `--exclude-verfied/-e`: Exclude verified users from the list.

##### Flags for `download` command

- `--url`: The url of the post, reel, IGTV you want to download.

### 🙌 Achnowledgements

This project wouldn't be possible without the existance of this amazing project:
Expand Down
15 changes: 10 additions & 5 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,15 @@ Helps you do some tasks faster and easier like downloading posts, stories, IGTV,
Short: "Download post,iptv or reel by entering the url.",
Long: `Download post,iptv or reel by entering the url.`,
Run: func(cmd *cobra.Command, args []string) {
urlFlag := cmd.Flag("url").Value.String()
parts.Download(insta, urlFlag)
if len(args) == 0 {
fmt.Println(utils.Red("You have to enter a url!"))
fmt.Println("igo download url")
} else if len(args) == 1 {
parts.Download(insta, args[0])
} else {
fmt.Println(utils.Red("You have to enter a url!"))
fmt.Println("igo download url")
}
},
}

Expand All @@ -241,13 +248,11 @@ Helps you do some tasks faster and easier like downloading posts, stories, IGTV,
var jsonFlag bool
var latestFlag bool
var notverifiedFlag bool
var urlFlag string

rootCmd.PersistentFlags().StringVarP(&username, "username", "u", "", "Username of the user you want to perform tasks on.")
notfollowingbackCmd.Flags().BoolVarP(&jsonFlag, "json", "j", false, "Export the users that don't follow you back in JSON format.")
notfollowingbackCmd.Flags().BoolVarP(&notverifiedFlag, "exclude-verified", "e", false, "Exclude verified users from the list.")
downloadpostsCmd.Flags().BoolVarP(&latestFlag, "latest", "l", false, "Download latest post only")
downloadCmd.Flags().StringVarP(&urlFlag, "url", "", "", "Url of the post,igtv or reel you want to download.")

rootCmd.AddCommand(followCmd)
rootCmd.AddCommand(unfollowCmd)
Expand Down Expand Up @@ -276,7 +281,7 @@ Helps you do some tasks faster and easier like downloading posts, stories, IGTV,
rootCmd.Root().Example = ` igo follow -u username
igo unfollow -u username
igo everything -u username
igo nfb`
igo nfb --exlude-verified`

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
Expand Down
9 changes: 5 additions & 4 deletions parts/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import (
func Download(insta *goinsta.Instagram, url string) {
fmt.Println(utils.Yellow("Downloading..."))

if url == "" {
fmt.Println(utils.Red("You have to enter a url!"))
fmt.Println("igo download --url url")

// check if url is valid
if !strings.Contains(url, "instagram.com/") {
fmt.Println(utils.Red("Invalid URL!"))
fmt.Println("igo download https://www.instagram.com/...")
return
}

code := ExtractCode(url)

if len(code) > 12 {
Expand Down

0 comments on commit 22fcfcd

Please sign in to comment.