grailbird_updater 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +64 -39
- data/lib/grailbird_updater.rb +19 -14
- data/lib/grailbird_updater/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -8,14 +8,72 @@ Turns out the contents in the archive are partial/trimmed API responses from
|
|
8
8
|
the Twitter API, so it is actually possible to drop a whole API response in
|
9
9
|
there, do some sorting and update the archive.
|
10
10
|
|
11
|
-
This currently does not work with a private/protected Twitter account, see
|
12
|
-
[this issue](https://github.com/DeMarko/grailbird_updater/issues/6)
|
13
11
|
|
14
|
-
##
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Install it yourself as:
|
15
|
+
|
16
|
+
$ gem install grailbird_updater
|
17
|
+
|
18
|
+
Or add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
gem 'grailbird_updater'
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```
|
29
|
+
grailbird_updater /path/to/twitter/archive
|
30
|
+
```
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
39
|
+
|
40
|
+
## FAQ
|
41
|
+
|
42
|
+
* _I have a protected Twitter account, can I still use this updater with my Twitter archive?_
|
43
|
+
|
44
|
+
Actually, yes! However, you will need to create your own "application" on
|
45
|
+
Twitter and then use your own consumer key/secret pair to let the application
|
46
|
+
use the oauth tokens for a user and then follow the authorization steps for
|
47
|
+
a given protected user.
|
48
|
+
|
49
|
+
Once you have auth'd the application for a protected user, you do not have to do
|
50
|
+
it again, the consumer key/secret and oauth token/secret are stored in a YAML file
|
51
|
+
at the root of your tweet archive.
|
52
|
+
|
53
|
+
__IMPORTANT__ Do NOT commit or post your own consumer key/secret or your oauth
|
54
|
+
token/secret anywhere.
|
55
|
+
|
56
|
+
Note: you will only need to create a single application on Twitter even if you
|
57
|
+
are using this to update multiple protected account. You can reuse the consumer
|
58
|
+
key/secret and just authorize each account individually.
|
59
|
+
|
60
|
+
Please see [this wiki article](https://github.com/DeMarko/grailbird_updater/wiki/Authorizing-grailbird_updater-to-work-with-Protected-Twitter-accounts) for step-by-step instructions.
|
61
|
+
|
62
|
+
* _How do I know if I have a Twitter archive?_
|
63
|
+
|
64
|
+
Hopefully, you downloaded it from Twitter once the feature was made available
|
65
|
+
to you and have their web application which can consume it.
|
66
|
+
|
67
|
+
This gem only modifies what's in the `data` directory for a given archive,
|
68
|
+
the rest of the files are provided by Twitter.
|
69
|
+
|
70
|
+
To check if you can download a copy of your Twitter archive, go to your
|
71
|
+
[Account Settings](https://twitter.com/settings/account) and scroll all
|
72
|
+
the way to the bottom. If the feature is enabled for you, you should see
|
73
|
+
a section labeled "Your Twitter Archive".
|
74
|
+
|
75
|
+
The file structure looks somewhat like this (as of 19.12.12):
|
15
76
|
|
16
|
-
Hopefully, you downloaded it from Twitter once the feature was made available
|
17
|
-
to you and have their web application which can consume it. The file structure
|
18
|
-
looks somewhat like this (as of 19.12.12):
|
19
77
|
|
20
78
|
```
|
21
79
|
tweets
|
@@ -52,36 +110,3 @@ tweets
|
|
52
110
|
└─ ... // provided by Twitter
|
53
111
|
```
|
54
112
|
|
55
|
-
This gem only modifies what's in the data directory for a given archive,
|
56
|
-
the rest of the files are provided by Twitter. To check if you can download
|
57
|
-
a copy of your Twitter archive, go to your [Account Settings](https://twitter.com/settings/account)
|
58
|
-
and scroll all the way to the bottom. If the feature is enabled for you, you should
|
59
|
-
see a section labeled "Your Twitter Archive".
|
60
|
-
|
61
|
-
## Installation
|
62
|
-
|
63
|
-
Add this line to your application's Gemfile:
|
64
|
-
|
65
|
-
gem 'grailbird_updater'
|
66
|
-
|
67
|
-
And then execute:
|
68
|
-
|
69
|
-
$ bundle
|
70
|
-
|
71
|
-
Or install it yourself as:
|
72
|
-
|
73
|
-
$ gem install grailbird_updater
|
74
|
-
|
75
|
-
## Usage
|
76
|
-
|
77
|
-
```
|
78
|
-
grailbird_updater /path/to/twitter/archive
|
79
|
-
```
|
80
|
-
|
81
|
-
## Contributing
|
82
|
-
|
83
|
-
1. Fork it
|
84
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
-
5. Create new Pull Request
|
data/lib/grailbird_updater.rb
CHANGED
@@ -98,19 +98,24 @@ class GrailbirdUpdater
|
|
98
98
|
:include_entities => true}
|
99
99
|
twitter_uri.query = URI.encode_www_form(params)
|
100
100
|
|
101
|
-
vputs "
|
101
|
+
vputs "\nMaking request to #{twitter_uri}"
|
102
102
|
response = Net::HTTP.get_response(twitter_uri)
|
103
103
|
|
104
104
|
if response.is_a?(Net::HTTPUnauthorized)
|
105
105
|
access_token = do_oauth_dance(screen_name)
|
106
106
|
response = access_token.request(:get, twitter_uri.to_s)
|
107
|
+
if response.is_a?(Net::HTTPUnauthorized)
|
108
|
+
puts "\nSomething went wrong trying to authorize grailbird_updater with the account: " + "@#{screen_name}".blue
|
109
|
+
puts "Please delete #{@base_dir}/#{screen_name}_keys.yaml and follow the authorize steps again."
|
110
|
+
exit
|
111
|
+
end
|
107
112
|
end
|
108
113
|
|
109
114
|
return response.body
|
110
115
|
end
|
111
116
|
|
112
117
|
def do_oauth_dance(screen_name)
|
113
|
-
puts "
|
118
|
+
puts "\nIt seems " + "@#{screen_name}".blue + " has a protected account."
|
114
119
|
key_file_path = "#{@base_dir}/#{screen_name}_keys.yaml"
|
115
120
|
if File.exists?(key_file_path)
|
116
121
|
keys = YAML.load_file(key_file_path)
|
@@ -120,23 +125,23 @@ class GrailbirdUpdater
|
|
120
125
|
token_secret = keys['secret']
|
121
126
|
else
|
122
127
|
puts <<-EOS
|
123
|
-
|
128
|
+
To be able to retrieve your protected tweets, you will need a consumer key/secret
|
124
129
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
Please follow these steps to authorize grailbird_updater to download tweets:
|
131
|
+
1. Go to https://dev.twitter.com/apps/new
|
132
|
+
2. Give it a name (I recommend #{screen_name}_grailbird), description and URL
|
133
|
+
3. Create application
|
134
|
+
4. Go to your application page, you should see a "Consumer key" and a "Consumer secret"
|
130
135
|
|
131
|
-
|
136
|
+
Note: you will only need to create this application once!
|
132
137
|
|
133
|
-
|
138
|
+
So you don't have to enter these again, we'll save a copy of your keys in a file called #{screen_name}_keys.yaml
|
134
139
|
|
135
|
-
|
136
|
-
|
140
|
+
#{"IMPORTANT".red.blink} Do NOT store the folder of your tweets on a public server.
|
141
|
+
If someone gets access to #{screen_name}_keys.yaml they can access your entire account!
|
137
142
|
EOS
|
138
143
|
|
139
|
-
puts "
|
144
|
+
puts "\nEnter your 'Consumer key'"
|
140
145
|
consumer_key = STDIN.gets.chomp
|
141
146
|
puts "Enter your 'Consumer secret'"
|
142
147
|
consumer_secret = STDIN.gets.chomp
|
@@ -149,7 +154,7 @@ class GrailbirdUpdater
|
|
149
154
|
:authorize_path => '/oauth/authorize' }
|
150
155
|
)
|
151
156
|
request_token = consumer.get_request_token
|
152
|
-
puts "
|
157
|
+
puts "\nGo to this URL: #{request_token.authorize_url()}"
|
153
158
|
puts "Authorize the application and you will receive a PIN"
|
154
159
|
puts "Enter the PIN here:"
|
155
160
|
pin = STDIN.gets.chomp
|