playstore_downloader 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/playstore_downloader.rb +184 -0
- data/lib/playstore_downloader/apk.rb +14 -0
- data/lib/playstore_downloader/credentials.rb +10 -0
- data/lib/playstore_downloader/version.rb +3 -0
- data/playstore_downloader.gemspec +28 -0
- metadata +117 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5bb2509207015f46c39c0ccf7a89400d757b5ab8
|
4
|
+
data.tar.gz: 4531965a813f983eb787a19460a08f0f7038b268
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 17676d9a0b3bdcdff46047a8d9817e8e89176f7d37c0762d6563eebcbf2291537861b3dd855ab3fa2ea992f1cc6c8f3ba0bdb5251c3a30448a2a96e6ab0b117f
|
7
|
+
data.tar.gz: d025e1b078a58fbe3d07aae438215254763383a8c4aaf7f6189dd1082ff4c066b467bbc8799d258ca16e2551e17356fe7a3dee3d85f2d91f9a8ed449cd1a2f2a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Andrea Valenza
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# PlaystoreDownloader
|
2
|
+
|
3
|
+
Google Play Store lets you download an APK directly on your device, but sometimes you need to directly download the APK file on your PC (or other device). This gem lets you do just that, by using your credentials and tricking the Store into releasing the raw files to your device.
|
4
|
+
NOTE: it only works with free Apps.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'playstore_downloader'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install playstore_downloader
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
PlaystoreDownloader::setup "abc@email.it", "password", "device_id"
|
26
|
+
PlaystoreDownloader::download "com.package.id"
|
27
|
+
```
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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](https://rubygems.org).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AvalZ/playstore\_downloader.
|
38
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "playstore_downloader"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require "net/http"
|
3
|
+
|
4
|
+
require 'playstore_parser'
|
5
|
+
|
6
|
+
require "playstore_downloader/version"
|
7
|
+
require "playstore_downloader/credentials"
|
8
|
+
require "playstore_downloader/apk"
|
9
|
+
|
10
|
+
|
11
|
+
module PlaystoreDownloader
|
12
|
+
|
13
|
+
@@auth_token ||= nil
|
14
|
+
AUTH_URI = 'https://android.clients.google.com/auth'
|
15
|
+
BASE_URI = 'https://android.clients.google.com/fdfe'
|
16
|
+
|
17
|
+
module_function
|
18
|
+
|
19
|
+
def setup(email, password, device_id)
|
20
|
+
@@credentials = Credentials.new email, password, device_id
|
21
|
+
end
|
22
|
+
|
23
|
+
def auth
|
24
|
+
uri = URI(AUTH_URI)
|
25
|
+
|
26
|
+
req = Net::HTTP::Post.new(uri)
|
27
|
+
|
28
|
+
req.set_form_data(
|
29
|
+
Email: @@credentials.email,
|
30
|
+
Passwd: @@credentials.password,
|
31
|
+
service: 'androidmarket',
|
32
|
+
accountType: 'HOSTED_OR_GOOGLE',
|
33
|
+
has_permission: 1,
|
34
|
+
source: 'android',
|
35
|
+
androidId: @@credentials.device_id,
|
36
|
+
app: 'com.android.vending',
|
37
|
+
device_country: 'it',
|
38
|
+
operatorCountry: 'it',
|
39
|
+
lang: 'it',
|
40
|
+
sdk_version: 16
|
41
|
+
)
|
42
|
+
|
43
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
44
|
+
http.use_ssl = true
|
45
|
+
|
46
|
+
res = http.request req
|
47
|
+
|
48
|
+
@@auth_token = res.body[/(?<=Auth=).*/]
|
49
|
+
end
|
50
|
+
|
51
|
+
def details(apk)
|
52
|
+
auth if @@auth_token.nil?
|
53
|
+
|
54
|
+
uri = URI(BASE_URI + "/details?doc=#{apk.package_id}")
|
55
|
+
# TODO: get as argument
|
56
|
+
user_agent = 'Android-Finsky/3.7.13 (api=3,versionCode=8013013,sdk=16,device=crespo,hardware=herring,product=soju)'
|
57
|
+
|
58
|
+
headers = {
|
59
|
+
'Accept' => 'application/xml',
|
60
|
+
'Accept-Language' => 'en_US',
|
61
|
+
'Authorization' => "GoogleLogin auth=#{@@auth_token}",
|
62
|
+
'X-DFE-Device-Id' => @@credentials.device_id,
|
63
|
+
'X-DFE-Client-Id' => 'am-android-google',
|
64
|
+
'User-Agent' => user_agent,
|
65
|
+
'X-DFE-SmallestScreenWidthDp' => '320',
|
66
|
+
'X-DFE-Filter-Level' => '3',
|
67
|
+
'Accept-Encoding' => '',
|
68
|
+
'Host' => 'android.clients.google.com'
|
69
|
+
}
|
70
|
+
|
71
|
+
req = Net::HTTP::Get.new(uri.to_s)
|
72
|
+
|
73
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
74
|
+
|
75
|
+
|
76
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
77
|
+
http.use_ssl = true
|
78
|
+
|
79
|
+
headers.each do |key, value|
|
80
|
+
req[key] = value
|
81
|
+
end
|
82
|
+
|
83
|
+
http.request req
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
rw = PlaystoreParser.parse(res.body)
|
89
|
+
|
90
|
+
doc = rw.payload.detailsResponse.docV2
|
91
|
+
|
92
|
+
apk.version_code = doc.details.appDetails.versionCode
|
93
|
+
apk.offer_type = doc.offer[0].offerType
|
94
|
+
|
95
|
+
return apk
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def purchase(apk)
|
101
|
+
auth if @@auth_token.nil?
|
102
|
+
|
103
|
+
details(apk) unless apk.complete?
|
104
|
+
|
105
|
+
uri = URI(BASE_URI + '/purchase')
|
106
|
+
|
107
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
108
|
+
http.use_ssl = true
|
109
|
+
|
110
|
+
headers = {
|
111
|
+
'Accept' => 'application/xml',
|
112
|
+
'Accept-Language' => 'en_US',
|
113
|
+
'Authorization' => "GoogleLogin auth=#{@@auth_token}",
|
114
|
+
'X-DFE-Enabled-Experiments' => 'cl:billing.select_add_instrument_by_default',
|
115
|
+
'X-DFE-Unsupported-Experiments' => 'nocache:billing.use_charging_poller,market_emails,buyer_currency,prod_baseline,checkin.set_asset_paid_app_field,shekel_test,content_ratings,buyer_currency_in_app,nocache:encrypted_apk,recent_changes',
|
116
|
+
'X-DFE-Device-Id' => @@credentials.device_id,
|
117
|
+
'X-DFE-Client-Id' => 'am-android-google',
|
118
|
+
'User-Agent' => 'Android-Finsky/3.7.13 (api=3,versionCode=8013013,sdk=16,device=crespo,hardware=herring,product=soju)',
|
119
|
+
'X-DFE-SmallestScreenWidthDp' => '320',
|
120
|
+
'X-DFE-Filter-Level' => '3',
|
121
|
+
'Accept-Encoding' => '',
|
122
|
+
'Host' => 'android.clients.google.com',
|
123
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
124
|
+
}
|
125
|
+
|
126
|
+
req = Net::HTTP::Post.new(BASE_URI + '/purchase')
|
127
|
+
|
128
|
+
req.set_form_data(
|
129
|
+
ot: apk.offer_type,
|
130
|
+
doc: apk.package_id,
|
131
|
+
vc: apk.version_code
|
132
|
+
)
|
133
|
+
|
134
|
+
headers.each do |key, value|
|
135
|
+
req.add_field key, value
|
136
|
+
end
|
137
|
+
|
138
|
+
res = http.request req
|
139
|
+
|
140
|
+
rw = PlaystoreParser.parse(res.body)
|
141
|
+
|
142
|
+
delivery_data = rw.payload.buyResponse.purchaseStatusResponse.appDeliveryData
|
143
|
+
|
144
|
+
auth_cookie = delivery_data.downloadAuthCookie[0]
|
145
|
+
|
146
|
+
download_data = {
|
147
|
+
dl_url: delivery_data.downloadUrl,
|
148
|
+
dl_auth_cookie: auth_cookie.name + "=" + auth_cookie.value
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
def download_apk(dl_data)
|
155
|
+
uri = URI(dl_data[:dl_url])
|
156
|
+
auth_cookie = dl_data[:dl_auth_cookie]
|
157
|
+
Net::HTTP.start(uri.hostname, use_ssl: uri.scheme == 'https') do |http|
|
158
|
+
req = Net::HTTP::Get.new uri
|
159
|
+
req['User-Agent'] = 'AndroidDownloadManager Paros/3.2.13'
|
160
|
+
req['Cookie'] = auth_cookie
|
161
|
+
|
162
|
+
res = http.request req
|
163
|
+
|
164
|
+
case res
|
165
|
+
when Net::HTTPSuccess
|
166
|
+
return res
|
167
|
+
when Net::HTTPRedirection
|
168
|
+
return download_apk({dl_url: res['Location'], dl_auth_cookie: auth_cookie})
|
169
|
+
else
|
170
|
+
res.error!
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def download(package_id)
|
177
|
+
apk = Apk.new(package_id, nil, nil)
|
178
|
+
dl_data = purchase apk
|
179
|
+
res = download_apk dl_data
|
180
|
+
|
181
|
+
return res.body
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Apk
|
2
|
+
attr_accessor :offer_type, :package_id, :version_code
|
3
|
+
|
4
|
+
def initialize(package_id, version_code, offer_type=0)
|
5
|
+
@package_id = package_id
|
6
|
+
@version_code = version_code
|
7
|
+
@offer_type = offer_type
|
8
|
+
end
|
9
|
+
|
10
|
+
def complete?
|
11
|
+
!@package_id.nil? && !@version_code.nil? && !@offer_type.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'playstore_downloader/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "playstore_downloader"
|
8
|
+
spec.version = PlaystoreDownloader::VERSION
|
9
|
+
spec.authors = ["avalz"]
|
10
|
+
spec.email = ["avalenza89@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Download Free APKs directly from the Google Play Store}
|
13
|
+
spec.description = %q{Google Play Store lets you download an APK directly on your device, but sometimes you need to directly download the APK file on your PC (or other device). This gem lets you do just that, by using your credentials and tricking the Store into releasing the raw files to your device.}
|
14
|
+
spec.homepage = "https://github.com/AvalZ/playstore_downloader"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'playstore_parser', '~> 1.0'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: playstore_downloader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- avalz
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: playstore_parser
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
description: Google Play Store lets you download an APK directly on your device, but
|
70
|
+
sometimes you need to directly download the APK file on your PC (or other device).
|
71
|
+
This gem lets you do just that, by using your credentials and tricking the Store
|
72
|
+
into releasing the raw files to your device.
|
73
|
+
email:
|
74
|
+
- avalenza89@gmail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".gitignore"
|
80
|
+
- ".rspec"
|
81
|
+
- ".travis.yml"
|
82
|
+
- Gemfile
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/playstore_downloader.rb
|
89
|
+
- lib/playstore_downloader/apk.rb
|
90
|
+
- lib/playstore_downloader/credentials.rb
|
91
|
+
- lib/playstore_downloader/version.rb
|
92
|
+
- playstore_downloader.gemspec
|
93
|
+
homepage: https://github.com/AvalZ/playstore_downloader
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.5.1
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Download Free APKs directly from the Google Play Store
|
117
|
+
test_files: []
|