From a37aaebfd7d0878b8c98289d5b71741e16a68b20 Mon Sep 17 00:00:00 2001 From: Krishanu Konar Date: Mon, 24 Oct 2022 16:36:37 +0530 Subject: [PATCH] Added readme, removed debug statement --- README.md | 34 +++++++++++++++++++++++++++++----- twitter_image_downloader.py | 3 +-- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d8c75d6..4a700ae 100644 --- a/README.md +++ b/README.md @@ -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 ``. - +* 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 `(@)` 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 ``. + +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..... +... +``` diff --git a/twitter_image_downloader.py b/twitter_image_downloader.py index b683578..c4b9876 100644 --- a/twitter_image_downloader.py +++ b/twitter_image_downloader.py @@ -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) @@ -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')