Overview
- You can collect media file (sorry, now image files only except for gif and mp4)
- The source account is yourself (the media file is collected from your home timeline)
Required
-
wget
command
Installation
$ gem install collect_twitter_media
Usage
1. require gem
require 'collect_twitter_media'
2. set your Twitter API token
- set the Twitter API token
CollectTwitterMedia.consumer_key('YOUR_CONSUMER_KEY')
CollectTwitterMedia.consumer_secret('YOUR_CONSUMER_SECRET')
CollectTwitterMedia.access_token('YOUR_ACCESS_TOKEN')
CollectTwitterMedia.access_token_secret('YOUR_ACCESS_TOKEN_SECRET')
3. ๐exec save
method๐
- the first argv is the directory name to collect
CollectTwitterMedia.save('media_collection')
4. ๐you have collected the media files and the csv file!๐
- in the directory you specified, the media files have collected
- the format of filename has 3 parts
@twitter_screen_name
tweet_id
media_id
- the example of filename
@dhh_934687159870177697_dPi3GGKVoAERExB.jpg
@tenderlove_924694994511770368_IPi5IX-UEAAoL4v.jpg
- the format of filename has 3 parts
- in the directory you specified, the csv file has created
- the columns of this csv file
tweet_id
screen_name
original_filename
save_filename
uri
created_at
- the filename of this csv file has 2 parts
image_from_twitter
%Y%m%d_%H%M%S
- the example of filename
image_from_twitter_20171126_171717.csv
image_from_twitter_20171224_210000.csv
- the columns of this csv file
Screenshot
Options
-
the
save
method can take 4 argvs- the first: the directory name to collect [required]
- the second: the collect count of tweet per loop (default: 200) [optional]
- the third: the loop count to collect media (default: 1) [optional]
- Be careful about
API Rate limits
- Be careful about
- the fourth: the starting tweet id to collect media (String, default: the latest) [optional]
-
example
CollectTwitterMedia.save('media_collection', 100, 4, '12345678901234')
Note
- Please, please be careful about
API Rate limits
TODO
- collect from any users timeline
- collect by keyword search result
- collect not only image but also gif and mp4
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/corselia/collect-twitter-media.
License
The gem is available as open source under the terms of the MIT License.
History
2017-12-02
- Version 1.1.3 -Oops... I changed the repository URI on GitHub... (I forgot)
2017-12-02
- Version 1.1.2
- Oops! I don't know the naming convention of Ruby gems. So I revert my changes at Version
1.1.1
- Oops! I don't know the naming convention of Ruby gems. So I revert my changes at Version
2017-12-02
- Version 1.1.1
- modify minor typo and etc in
README.md
- change repository name from
collect_twitter_media
tocollect-twitter-media
- modify minor typo and etc in
2017-11-26
- Version 1.1.0
- add
created_at
column to the output CSV file
- add
2017-11-26
- Version 1.0.0
- first release