pandata 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pandata.rb +1 -1
- data/lib/pandata/downloader.rb +12 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5684ea1131bb37e801e876ee9254aab0c4345181
|
4
|
+
data.tar.gz: 389e6e95566908e33af0594b8b23665992eb5656
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09151cd32fc590f8b5845a420beb755e0e838de347c2646ff6587246f02c8e62cf05d8e0d653cd7a3adb3b16c54d1181a8446eb96a48a6e35e4320ed275b3603
|
7
|
+
data.tar.gz: 4f8e3e68fe6a648d8defee3ff39623e9260b9267cd5411f5cbf34583b3a6aba8a3c598db86b0e54cdddae86af047f371f1b55d8c6db6a0f51ffe178ec506f019
|
data/lib/pandata.rb
CHANGED
data/lib/pandata/downloader.rb
CHANGED
@@ -10,20 +10,23 @@ module Pandata
|
|
10
10
|
# A GitHub Gist that contains an updated cookie allowing access to 'login-only' visible data.
|
11
11
|
CONFIG_URL = 'https://gist.github.com/ustasb/596f1ee96d03463fde77/raw/pandata_config.json'
|
12
12
|
|
13
|
-
# The cached config hash.
|
14
|
-
@@config = nil
|
15
|
-
|
16
13
|
# Downloads and reads a page from a URL.
|
17
14
|
# @param url [String]
|
18
15
|
# @return [String] contents of page
|
19
16
|
def self.read_page(url)
|
20
|
-
download(url,
|
17
|
+
download(url, session['cookie']).read
|
21
18
|
end
|
22
19
|
|
23
20
|
# Returns a pat token needed for mobile requests.
|
24
21
|
# @return [String]
|
25
22
|
def self.get_pat
|
26
|
-
|
23
|
+
session['pat']
|
24
|
+
end
|
25
|
+
|
26
|
+
# Manually sets the cached session.
|
27
|
+
# @return [Hash]
|
28
|
+
def self.set_session(session)
|
29
|
+
@@session = session
|
27
30
|
end
|
28
31
|
|
29
32
|
private
|
@@ -42,18 +45,18 @@ module Pandata
|
|
42
45
|
raise PandataError
|
43
46
|
end
|
44
47
|
|
45
|
-
def self.
|
46
|
-
@@
|
48
|
+
def self.session
|
49
|
+
@@session ||= get_random_session
|
47
50
|
end
|
48
51
|
|
49
|
-
def self.
|
52
|
+
def self.get_random_session
|
50
53
|
config = JSON.parse download(CONFIG_URL).read
|
51
54
|
|
52
55
|
if Gem::Version.new(Pandata::Version::STRING) <= Gem::Version.new(config['required_update_for'])
|
53
56
|
raise PandataError, 'Pandora.com has changed something and you need to update Pandata!'
|
54
57
|
end
|
55
58
|
|
56
|
-
config
|
59
|
+
config['sessions'].sample
|
57
60
|
end
|
58
61
|
|
59
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pandata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Ustas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|