Skip to content

Commit

Permalink
Added readme, removed debug statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Krishanu Konar committed Oct 24, 2022
1 parent 3d771c4 commit a37aaeb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,32 @@ You will also need to create an app account on https://dev.twitter.com/apps to g
Following these steps and a successful app creation, you will recieve 3 tokens for your app, namely `API_KEY`, `API_KEY_SECRET` and `BEARER_TOKEN`.
### Usage

1. Edit the `API_Tokens.py` file and add these tokens you recieved in the previous step and save.
2. Run the script (`python twitter_image_downloader.py`).
3. Enter the user's twitter handle `(@twitter_handle)` you want to download images from, followed by max. number of tweets you want to search for.
4. The images are downloaded inside a folder named `twitter_images`, in the folder named `<user_handle>`.

* Edit the `API_Tokens.py` file and add these tokens you recieved in the previous step and save.

#### Using CLI
* Run using `twitter_image_downloader.py [-h] [-H HANDLE] [-n [MAX_TWEETS]] [-t [{images,videos,gifs,all} ...]]`

Examples:
```
python twitter_image_downloader.py --handle arsenal
python twitter_image_downloader.py --handle arsenal --max-tweets 10 --type images,gifs
```
#### Using Interactive UI
1. Run the script (`python twitter_image_downloader.py`).
2. Enter the user's twitter handle `(@<twitter_handle>)` you want to download images from, followed by max. number of tweets you want to search for.
3. The images are downloaded inside a folder named `twitter_images`, in the folder named `<user_handle>`.

Example:
```
$ python twitter_image_downloader.py
Twitter Image Downloader:
========================
Enter the twitter handle of the Account to download media from: arsenal
Enter Max. number of tweets to search (default: 1000): 10
Enter type of media (images/gifs/videos/all) (default: images) gifs images
Fetching tweets.....
...
```
3 changes: 1 addition & 2 deletions twitter_image_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def main():
max_tweets = args.max_tweets or 100
media_formats = args.type or ["images"]

print (handle, max_tweets, media_formats)
all_tweets = getTweetsFromUser(api, handle, max_tweets)
media_URLs = getTweetMediaURL(all_tweets, media_formats)

Expand Down Expand Up @@ -130,7 +129,7 @@ def downloadFiles(media_url, handle):
Downloads the fetched media URLs.
'''

print ('\nDownloading Images.....')
print ('\nDownloading Media.....')

try:
os.mkdir('twitter_images')
Expand Down

0 comments on commit a37aaeb

Please sign in to comment.