Repository is archived
No release in over 3 years
Low commit activity in last 3 years
you can collect the media files such as .jpg, .png ... from Twitter's timeline
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 13.0
~> 3.0

Runtime

 Project Readme

CircleCI codecov Coverage Status

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
  • 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

Screenshot

  • the directory which contains the media files and the csv file the_result_directory

  • the csv file the_csv_file

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
    • the fourth: the starting tweet id to collect media (String, default: the latest) [optional]
  • example

CollectTwitterMedia.save('media_collection', 100, 4, '12345678901234')

Note

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

2017-12-02

  • Version 1.1.1
    • modify minor typo and etc in README.md
    • change repository name from collect_twitter_media to collect-twitter-media

2017-11-26

  • Version 1.1.0
    • add created_at column to the output CSV file

2017-11-26

  • Version 1.0.0
    • first release