TwitterImageParser gem returns the original image source url from the shortened image post url of twitter image sharing services, such as twitpic, twipple and many other.
Installation
Add this line to your application's Gemfile:
gem 'twitter_image_parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install twitter_image_parser
Usage
require 'twitter_image_parser'
twipple_uri = URI.parse('http://p.twipple.jp/GIb1F')
#=> #<URI::HTTP:0x007f8a913a0c00 URL:http://p.twipple.jp/GIb1F>
twipple_uri.img_url
#=> "http://p.twpl.jp/show/orig/GIb1F"
# return nil if the uri is not valid
dummy_uri = URI.parse('http://example.com')
#=> #<URI::HTTP:0x007f8a913a0c00 URL:http://example.com>
dummy_uri.img_url
#=> nil
Contributing
- Fork it ( https://github.com/[my-github-username]/twitter_image_parser/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request