tweetlr 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -3
- data/bin/tweetlr +1 -1
- data/lib/tweetlr.rb +22 -2
- metadata +4 -4
data/Rakefile
CHANGED
@@ -7,15 +7,14 @@ require 'rake/testtask'
|
|
7
7
|
|
8
8
|
spec = Gem::Specification.new do |s|
|
9
9
|
s.name = 'tweetlr'
|
10
|
-
s.version = '0.0.
|
10
|
+
s.version = '0.0.6'
|
11
11
|
s.has_rdoc = true
|
12
12
|
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
13
|
-
s.summary =
|
13
|
+
s.summary = %{tweetlr crawls twitter for a given term, extracts photos out of the collected tweets' short urls and posts the images to tumblr.}
|
14
14
|
s.description = s.summary
|
15
15
|
s.author = 'Sven Kraeuter'
|
16
16
|
s.email = 'mail@svenkraeuter.com'
|
17
17
|
s.homepage = "http://github.com/5v3n/#{s.name}"
|
18
|
-
# s.executables = ['your_executable_here']
|
19
18
|
s.files = %w(LICENSE README.md Rakefile) + Dir.glob("{bin,lib}/**/*")
|
20
19
|
s.require_path = "lib"
|
21
20
|
s.executables = ['tweetlr']
|
data/bin/tweetlr
CHANGED
@@ -8,7 +8,7 @@ require_relative '../lib/tweetlr.rb'
|
|
8
8
|
|
9
9
|
begin
|
10
10
|
config_file = File.join( Dir.pwd, 'config', 'tweetlr.yml')
|
11
|
-
@log_file = File.join( Dir.pwd, '
|
11
|
+
@log_file = File.join( Dir.pwd, 'tweetlrd.log')
|
12
12
|
CONFIG = YAML.load_file(config_file)
|
13
13
|
TERM = CONFIG['search_term']
|
14
14
|
USER = CONFIG['tumblr_username']
|
data/lib/tweetlr.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
require 'logger'
|
3
3
|
require 'yaml'
|
4
|
+
require 'curb'
|
4
5
|
|
5
6
|
|
6
7
|
class Tweetlr
|
7
8
|
|
8
9
|
GENERATOR = %{tweetlr - http://github.com/5v3n/tweetlr}
|
9
|
-
|
10
|
+
LOCATION_START_INDICATOR = 'Location: '
|
11
|
+
LOCATION_STOP_INDICATOR = "\r\n"
|
12
|
+
|
10
13
|
def initialize(email, password, cookie=nil, since_id=nil, term=nil, config_file) #TODO use a hash or sth more elegant here...
|
11
14
|
@log = Logger.new(File.join( Dir.pwd, 'tweetlr.log'))
|
12
15
|
config = YAML.load_file(config_file)
|
@@ -81,6 +84,7 @@ class Tweetlr
|
|
81
84
|
url = image_url_picplz link if link.index 'picplz'
|
82
85
|
url = image_url_twitpic link if link.index 'twitpic'
|
83
86
|
url = image_url_yfrog link if link.index 'yfrog'
|
87
|
+
url = image_url_imgly link if link.index 'img.ly'
|
84
88
|
end
|
85
89
|
url
|
86
90
|
end
|
@@ -104,13 +108,29 @@ class Tweetlr
|
|
104
108
|
end
|
105
109
|
#find the image's url for a twitpic link
|
106
110
|
def image_url_twitpic(link_url)
|
107
|
-
"http://twitpic.com/show/full
|
111
|
+
image_url_redirect link_url, "http://twitpic.com/show/full/"
|
108
112
|
end
|
109
113
|
#find the image'S url for a yfrog link
|
110
114
|
def image_url_yfrog(link_url)
|
111
115
|
response = HTTParty.get("http://www.yfrog.com/api/oembed?url=#{link_url}")
|
112
116
|
response.parsed_response['url']
|
113
117
|
end
|
118
|
+
#find the image's url for a img.ly link
|
119
|
+
def image_url_imgly(link_url)
|
120
|
+
image_url_redirect link_url, "http://img.ly/show/full/", "\r\n"
|
121
|
+
end
|
122
|
+
|
123
|
+
# extract image url from services like twitpic & img.ly that do not offer oembed interfaces
|
124
|
+
def image_url_redirect(link_url, service_endpoint, stop_indicator = LOCATION_STOP_INDICATOR)
|
125
|
+
resp = Curl::Easy.http_get("#{service_endpoint}#{extract_id link_url}") { |res| res.follow_location = true }
|
126
|
+
if(resp.header_str.index(LOCATION_START_INDICATOR) && resp.header_str.index(stop_indicator))
|
127
|
+
start = resp.header_str.index(LOCATION_START_INDICATOR) + LOCATION_START_INDICATOR.size
|
128
|
+
stop = resp.header_str.index(stop_indicator, start)
|
129
|
+
resp.header_str[start...stop]
|
130
|
+
else
|
131
|
+
nil
|
132
|
+
end
|
133
|
+
end
|
114
134
|
|
115
135
|
#extract the pic id from a given <code>link</code>
|
116
136
|
def extract_id(link)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tweetlr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sven Kraeuter
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-03 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: daemons
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id003
|
48
|
-
description:
|
48
|
+
description: tweetlr crawls twitter for a given term, extracts photos out of the collected tweets' short urls and posts the images to tumblr.
|
49
49
|
email: mail@svenkraeuter.com
|
50
50
|
executables:
|
51
51
|
- tweetlr
|
@@ -86,6 +86,6 @@ rubyforge_project:
|
|
86
86
|
rubygems_version: 1.7.2
|
87
87
|
signing_key:
|
88
88
|
specification_version: 3
|
89
|
-
summary:
|
89
|
+
summary: tweetlr crawls twitter for a given term, extracts photos out of the collected tweets' short urls and posts the images to tumblr.
|
90
90
|
test_files: []
|
91
91
|
|