twail 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.markdown +62 -9
- data/lib/twail.rb +22 -0
- data/lib/twail_debug.rb +67 -0
- data/screenshot.png +0 -0
- data/twail.gemspec +1 -1
- metadata +5 -2
data/.gitignore
ADDED
data/README.markdown
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
# twail
|
2
2
|
|
3
3
|
`twail` is inspired by the venerable Unix `tail` program. `twail` lets
|
4
|
-
you tail your Twitter timelines.
|
4
|
+
you tail your Twitter timelines, or run a twitter search.
|
5
5
|
|
6
|
-
|
6
|
+
![screenshot](https://github.com/danchoi/twail/raw/master/screenshot.png)
|
7
|
+
|
8
|
+
## Installation
|
7
9
|
|
8
10
|
gem install twail
|
9
11
|
|
10
|
-
|
12
|
+
## Setup
|
11
13
|
|
12
14
|
Before using twail, you must first get a Twitter API key and authorize
|
13
15
|
the `twurl` command (note that this is a different command from `twail`)
|
@@ -17,12 +19,17 @@ to access your Twitter account. Type
|
|
17
19
|
|
18
20
|
for instructions.
|
19
21
|
|
20
|
-
|
21
|
-
# Usage
|
22
|
+
## Usage
|
22
23
|
|
23
24
|
twail [timeline]
|
24
25
|
|
25
|
-
|
26
|
+
or
|
27
|
+
|
28
|
+
twail s [search args]
|
29
|
+
|
30
|
+
## Tailing your timelines
|
31
|
+
|
32
|
+
The timeline output looks like this:
|
26
33
|
|
27
34
|
$ twail home
|
28
35
|
Logging home timeline at 2011-04-21 11:21:36 -0400
|
@@ -77,9 +84,8 @@ You can use these abbreviations:
|
|
77
84
|
|
78
85
|
p h f u m by to of
|
79
86
|
|
80
|
-
|
81
|
-
|
82
|
-
in the specified timeline. You can redirect the output however you
|
87
|
+
In timeline mode, `twail` works like `tail -f`. It will print tweets out as
|
88
|
+
they appear in the specified timeline. You can redirect the output however you
|
83
89
|
want. One pipeline I like to use is
|
84
90
|
|
85
91
|
twail home | tee -a twitter.home.log
|
@@ -87,6 +93,53 @@ want. One pipeline I like to use is
|
|
87
93
|
Lots of other pipelines are possible. Knock yourself out. To stop
|
88
94
|
`twail`, press `CTRL-C`.
|
89
95
|
|
96
|
+
|
97
|
+
## Search for tweets
|
98
|
+
|
99
|
+
You can run a Twitter search with `twail s [search args]`.
|
100
|
+
|
101
|
+
Search arguments are simply the words you want to submit as your Twitter search
|
102
|
+
query.
|
103
|
+
|
104
|
+
`twail` will print each of search results as it fetches them and keep going
|
105
|
+
backward in time until the results are exhausted.
|
106
|
+
|
107
|
+
The output of `twail` in search mode looks like this:
|
108
|
+
|
109
|
+
$ twail s vitunes itunes
|
110
|
+
2011-08-02 20:38:03 | garry_stewart | Via @otaku_jstewart: http://bit.ly/rgfaKw <-- ViTunes: Controlling iTunes from vi/vim
|
111
|
+
2011-08-02 20:16:29 | xshay | RT @notahat: If you feel that you don't have enough nerd cred, try driving iTunes from Vim: http://t.co/hFkolMZ
|
112
|
+
2011-08-02 20:00:08 | rubygems | vitunes (0.4.6): http://is.gd/1JmVwn Control iTunes with Vim
|
113
|
+
2011-08-02 19:54:08 | priyaaank | iTune from vi! Every vi lover's dream. :) http://danielchoi.com/software/vitunes.html
|
114
|
+
2011-08-02 19:50:02 | k_ui | Vim で動く iTunes クローンらしい > ViTunes http://bit.ly/o9FGap
|
115
|
+
2011-08-02 19:47:50 | hongymagic | RT @jadzor: ViTunes. Yeah, that's right. http://t.co/ZZkIk2T
|
116
|
+
2011-08-02 19:34:33 | lindsayevans | RT @jadzor: ViTunes. Yeah, that's right. http://t.co/ZZkIk2T
|
117
|
+
2011-08-02 19:31:22 | jadzor | ViTunes. Yeah, that's right. http://t.co/ZZkIk2T
|
118
|
+
2011-08-02 19:25:13 | david2777 | Hahaha ViTunes http://t.co/xaGEOli
|
119
|
+
2011-08-02 19:11:51 | notahat | If you feel that you don't have enough nerd cred, try driving iTunes from Vim: http://t.co/hFkolMZ
|
120
|
+
2011-08-02 18:58:38 | rnewman | RT @boingr: controlling iTunes in vim with http://danielchoi.com/software/vitunes.html
|
121
|
+
2011-08-02 18:56:30 | benbelly | For you @edgauthier RT @newsycombinator ViTunes http://j.mp/lSDlBt
|
122
|
+
2011-08-02 18:50:18 | pelayo1974 | Applesfera - ViTunes, controla iTunes desde el Terminal http://www.applesfera.com/curiosidades/vitunes-controla-itunes-desde-el-terminal
|
123
|
+
2011-08-02 18:43:28 | frigo | RT @msutherl: omg awesome, ViTunes: control iTunes from Vim: http://t.co/iheGoIA
|
124
|
+
2011-08-02 18:39:10 | SinnerBOFH | #BOFHers #vim RT @tatai: Igual empiezo a usar iTunes entonces ;) RT @elorz007: @tatai Interfaz de iTunes para vi http://bit.ly/ope5Q7
|
125
|
+
2011-08-02 18:19:00 | bgarber | RT @otaviocc: VIM + iTunes = ViTunes http://j.mp/lSDlBt
|
126
|
+
2011-08-02 18:17:51 | geyson | RT @otaviocc: VIM + iTunes = ViTunes http://j.mp/lSDlBt
|
127
|
+
2011-08-02 18:04:30 | apoena | "@otaviocc: VIM + iTunes = ViTunes http://t.co/CBkWJ6t" isso é oldschool.vou testar hoje.hehe
|
128
|
+
2011-08-02 17:47:13 | otaviocc | VIM + iTunes = ViTunes http://j.mp/lSDlBt
|
129
|
+
2011-08-02 17:44:35 | spdalton | @danchoi vitunes is amazing. Thank you!
|
130
|
+
2011-08-02 17:41:21 | felipebrnd | +1 membro! @taverneiro Wow! RT @newsycombinator ViTunes http://t.co/zeqqMx0
|
131
|
+
2011-08-02 17:39:59 | 3kwa | @knotty can you control iTunes from XCode? http://bit.ly/kdRLNG :D
|
132
|
+
2011-08-02 17:38:54 | spdalton | This is why I use Vim. (via http://t.co/sbqWJ8c) http://t.co/WgH6DGT
|
133
|
+
2011-08-02 17:29:43 | ggarron | vitunes http://t.co/dqC1sdq #mac
|
134
|
+
etc.
|
135
|
+
|
136
|
+
|
137
|
+
## About
|
138
|
+
|
139
|
+
If you like `twail` and you're a Vim user, try [twim][twim].
|
140
|
+
|
141
|
+
[twim]:https://github.com/danchoi/twim
|
142
|
+
|
90
143
|
`twail` was created by Daniel Choi. It's really just a convenience
|
91
144
|
wrapper around the awesome [twurl][twurl] program.
|
92
145
|
|
data/lib/twail.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'json'
|
4
4
|
require 'yaml'
|
5
5
|
require 'twurl'
|
6
|
+
require 'time'
|
6
7
|
|
7
8
|
TIMELINES = %w( public home friends user)
|
8
9
|
SPECIAL = %w(mentions retweeted_by_me retweeted_to_me retweets_of_me)
|
@@ -52,6 +53,26 @@ class String
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
|
57
|
+
# search is different
|
58
|
+
if ARGV.first =~ /^s/ # search
|
59
|
+
|
60
|
+
query = "?q=#{ARGV[1..-1].join(' ')}"
|
61
|
+
|
62
|
+
while query
|
63
|
+
url = "http://search.twitter.com/search.json#{query}"
|
64
|
+
json = `curl -s '#{url}'`
|
65
|
+
res = JSON.parse(json)
|
66
|
+
res['results'].each do |x|
|
67
|
+
time = Time.parse(x['created_at']).localtime
|
68
|
+
puts "%s | %s | %s" % [time.to_s.gsub(/\s\S+$/,''), x['from_user'].rjust(18), x['text'].gsub(/\n/, ' ')]
|
69
|
+
end
|
70
|
+
query = res['next_page']
|
71
|
+
end
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
# timeline tail
|
55
76
|
timeline = if ARGV.first
|
56
77
|
(TIMELINES + SPECIAL).detect {|t|
|
57
78
|
t =~ /^#{ARGV.first}/ || ((t =~ /_/) && (t.split('_')[1] =~ /^#{ARGV.first}/))
|
@@ -70,6 +91,7 @@ url = case timeline
|
|
70
91
|
"/1/statuses/#{timeline}_timeline.json"
|
71
92
|
end
|
72
93
|
|
94
|
+
|
73
95
|
trap("INT") {
|
74
96
|
xs = ['Goodbye.', 'Farewell.', 'Have a nice day.',
|
75
97
|
'Now go enjoy the weather!', 'Live long and prosper.',
|
data/lib/twail_debug.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
require 'json'
|
4
|
+
require 'yaml'
|
5
|
+
require 'twurl'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
TIMELINES = %w( public home friends user)
|
9
|
+
SPECIAL = %w(mentions retweeted_by_me retweeted_to_me retweets_of_me)
|
10
|
+
|
11
|
+
class String
|
12
|
+
def wrap(len=65)
|
13
|
+
gsub(/\n/, " ").gsub(/.{1,#{len}}(?:\s|\Z)/){$&+"\n"}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
timeline = if ARGV.first
|
18
|
+
(TIMELINES + SPECIAL).detect {|t|
|
19
|
+
t =~ /^#{ARGV.first}/ || ((t =~ /_/) && (t.split('_')[1] =~ /^#{ARGV.first}/))
|
20
|
+
}
|
21
|
+
else
|
22
|
+
'home'
|
23
|
+
end
|
24
|
+
puts "Logging #{timeline} timeline at #{Time.now}"
|
25
|
+
url = case timeline
|
26
|
+
when 'retweets_of_me'
|
27
|
+
# This doesn't seem to do anything different; figure out later
|
28
|
+
"/1/statuses/#{timeline}.json?include_entities=true"
|
29
|
+
when *SPECIAL
|
30
|
+
"/1/statuses/#{timeline}.json"
|
31
|
+
else
|
32
|
+
"/1/statuses/#{timeline}_timeline.json"
|
33
|
+
end
|
34
|
+
|
35
|
+
trap("INT") {
|
36
|
+
xs = ['Goodbye.', 'Farewell.', 'Have a nice day.',
|
37
|
+
'Now go enjoy the weather!', 'Live long and prosper.',
|
38
|
+
'May the force be with you.']
|
39
|
+
$stderr.puts xs[rand(xs.size)]
|
40
|
+
exit
|
41
|
+
}
|
42
|
+
|
43
|
+
seen = []
|
44
|
+
network = true
|
45
|
+
|
46
|
+
raw = begin
|
47
|
+
Twurl::CLI.output = StringIO.new
|
48
|
+
Twurl::CLI.run([url])
|
49
|
+
if network == false
|
50
|
+
network = true
|
51
|
+
$stderr.print(" The network is back up!\n")
|
52
|
+
end
|
53
|
+
Twurl::CLI.output.read
|
54
|
+
Twurl::CLI.output.rewind
|
55
|
+
Twurl::CLI.output.read
|
56
|
+
rescue SocketError
|
57
|
+
if network
|
58
|
+
$stderr.print("The network seems to be down.")
|
59
|
+
else
|
60
|
+
$stderr.print('.')
|
61
|
+
end
|
62
|
+
network = false
|
63
|
+
end
|
64
|
+
res = JSON.parse(raw).reverse
|
65
|
+
pp res
|
66
|
+
|
67
|
+
|
data/screenshot.png
ADDED
Binary file
|
data/twail.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: twail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Choi
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-08-02 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -34,12 +34,15 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
|
36
36
|
files:
|
37
|
+
- .gitignore
|
37
38
|
- MIT-LICENSE.txt
|
38
39
|
- README.markdown
|
39
40
|
- Rakefile
|
40
41
|
- bin/twail
|
41
42
|
- lib/twail.rb
|
43
|
+
- lib/twail_debug.rb
|
42
44
|
- notes.txt
|
45
|
+
- screenshot.png
|
43
46
|
- twail.gemspec
|
44
47
|
has_rdoc: true
|
45
48
|
homepage: https://github.com/danchoi/twail
|