Skip to content

Commit

Permalink
Merge pull request #65 from nauzawa/master
Browse files Browse the repository at this point in the history
Add M option to download only media tweets
  • Loading branch information
mmpx12 authored Oct 5, 2024
2 parents 9f32fef + ff95f1c commit 3e8c449
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Usage:
-r, --retweet Download retweet too
-z, --url Print media url without download it
-R, --retweet-only Donwload only retweet
-M, --mediatweet-only Donwload only media tweet
-s, --size SIZE Choose format between small|normal|large
(default large)
-U, --update Download missing tweet only
Expand Down
14 changes: 12 additions & 2 deletions twmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ var (
proxy string
update bool
onlyrtw bool
onlymtw bool
vidz bool
imgs bool
urlOnly bool
version = "1.13.3"
version = "1.13.4"
scraper *twitterscraper.Scraper
client *http.Client
size = "orig"
Expand Down Expand Up @@ -413,6 +414,7 @@ func main() {
op.On("-r", "--retweet", "Download retweet too", &retweet)
op.On("-z", "--url", "Print media url without download it", &urlOnly)
op.On("-R", "--retweet-only", "Download only retweet", &onlyrtw)
op.On("-M", "--mediatweet-only", "Download only media tweet", &onlymtw)
op.On("-s", "--size SIZE", "Choose size between small|normal|large (default large)", &size)
op.On("-U", "--update", "Download missing tweet only", &update)
op.On("-o", "--output DIR", "Output directory", &output)
Expand Down Expand Up @@ -519,7 +521,15 @@ func main() {
}
nbrs, _ := strconv.Atoi(nbr)
wg := sync.WaitGroup{}
for tweet := range scraper.GetTweets(context.Background(), usr, nbrs) {

var tweets <-chan *twitterscraper.TweetResult
if onlymtw {
tweets = scraper.GetMediaTweets(context.Background(), usr, nbrs)
} else {
tweets = scraper.GetTweets(context.Background(), usr, nbrs)
}

for tweet := range tweets {
if tweet.Error != nil {
fmt.Println(tweet.Error)
os.Exit(1)
Expand Down

0 comments on commit 3e8c449

Please sign in to comment.