purdie 0.0.10 → 0.0.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7c06826645ecad1b7d8a52a703ea4b654a67fd6
4
- data.tar.gz: 9a254bbbd7487741fbc7c13adae35e5730f6574c
3
+ metadata.gz: e4e6e972e93cf8cdd2ec9d9eeef1b617445d7a20
4
+ data.tar.gz: 44a7bb6b0d4030f7a27a03fe85f827df4b1d4942
5
5
  SHA512:
6
- metadata.gz: 8ba2d9e0d257920bf1e3df1aa62bea58d1b55b36a032f79378e0a48dfc7c3e899a4e4957822990d83b88cf73f998e403dd6e25d62fff31950e65d0ef519a535c
7
- data.tar.gz: 7ee9dfe27711152f798b11e91b7babeedfd70ddae964ef6f9fba63e0454d51f27ff08d6a06618cb240a3a1bd1c2aaa590248a2245b19e360fe6a39fb9aeb0cd7
6
+ metadata.gz: bbc8b0189d139240c47f2916cbdced45818c7b7c9480e2c4e22bbf45876953eea012bf040b06276585c4a6b507c6437dc08560b49c789e281aaa0efee9b5bf00
7
+ data.tar.gz: 096c577dad0b09883efbfded82434faac5f6034066e98e1a221d6b94d10fa2bd229f1764ee89be8e8709f360d0a61107f6c63a4bd1dc1eb0c4510de84069363b
data/README.md CHANGED
@@ -45,7 +45,7 @@ You need to create a *_sources* directory in your Jekyll project, containing fil
45
45
 
46
46
  (you can alternatively specify a source file on the command line with the `-f` flag).
47
47
 
48
- You also need a *.env* file with API keys in it:
48
+ You also need a *.env* file with the relevant credentials in it:
49
49
 
50
50
  FLICKR_API_KEY: this_a_key
51
51
  FLICKR_SECRET: this_a_secret
@@ -55,7 +55,7 @@ You also need a *.env* file with API keys in it:
55
55
 
56
56
  VIMEO_BEARER_TOKEN: this_is_bearer_token
57
57
 
58
- (get those keys from [Flickr](https://www.flickr.com/services/apps/create/apply), [SoundCloud](http://soundcloud.com/you/apps/new) and [Vimeo](https://developer.vimeo.com/apps/new))
58
+ (get those things from [Flickr](https://www.flickr.com/services/apps/create/apply), [SoundCloud](http://soundcloud.com/you/apps/new) and [Vimeo](https://developer.vimeo.com/apps/new))
59
59
 
60
60
  And then you can run
61
61
 
@@ -34,13 +34,6 @@ module Purdie
34
34
 
35
35
  @size = specific_config['size'] if specific_config['size']
36
36
  end
37
-
38
-
39
- # Can I do something like
40
- # @config['services'][Purdie.basename self].each do |c|
41
- # @#{c} = c
42
- # end
43
- # ?
44
37
  end
45
38
 
46
39
  def ingest url
@@ -1,6 +1,5 @@
1
1
  require 'purdie'
2
-
3
- Dotenv.load
2
+ require 'flickraw-cached'
4
3
 
5
4
  FlickRaw.api_key = ENV['FLICKR_API_KEY']
6
5
  FlickRaw.shared_secret = ENV['FLICKR_SECRET']
@@ -1,6 +1,5 @@
1
1
  require 'purdie'
2
-
3
- Dotenv.load
2
+ require 'soundcloud'
4
3
 
5
4
  module Purdie
6
5
  module Services
@@ -24,15 +23,15 @@ module Purdie
24
23
  results
25
24
  end
26
25
 
27
- def self.matcher
28
- 'soundcloud.com'
29
- end
30
-
31
26
  def self.resolve_set url
32
27
  client = ::SoundCloud.new client_id: ENV['SOUNDCLOUD_CLIENT_ID']
33
28
  client.get('/resolve', url: url).tracks.
34
29
  map { |track| track['permalink_url'] }
35
30
  end
31
+
32
+ def self.matcher
33
+ 'soundcloud.com'
34
+ end
36
35
  end
37
36
  end
38
37
  end
@@ -5,21 +5,10 @@ module Purdie
5
5
  class Vimeo
6
6
  include Purdie::Ingester
7
7
 
8
- def configure
9
- @host = 'https://api.vimeo.com'
10
- super
11
- end
12
-
13
8
  def get url
14
9
  @id = Purdie.get_id url
15
-
16
- target = "#{@host}/videos/#{@id}"
17
- headers = {
18
- 'Authorization' => "bearer #{ENV['VIMEO_BEARER_TOKEN']}",
19
- 'Accept' => 'application/json'
20
- }
21
- response = HTTParty.get target, headers: headers
22
-
10
+ target = "#{Vimeo.host}/videos/#{@id}"
11
+ response = HTTParty.get target, headers: Vimeo.headers
23
12
  JSON.parse response.body
24
13
  end
25
14
 
@@ -34,10 +23,27 @@ module Purdie
34
23
 
35
24
  results
36
25
  end
37
-
26
+
27
+ def self.headers
28
+ {
29
+ 'Authorization' => "bearer #{ENV['VIMEO_BEARER_TOKEN']}",
30
+ 'Accept' => 'application/json'
31
+ }
32
+ end
33
+
34
+ def self.resolve_set url
35
+ target = "#{Vimeo.host}/albums/#{Purdie.get_id url}/videos/"
36
+ set = JSON.parse (HTTParty.get target, headers: Vimeo.headers).body
37
+ set['data'].map { |video| video['link'] }
38
+ end
39
+
38
40
  def self.matcher
39
41
  'vimeo.com'
40
42
  end
43
+
44
+ def self.host
45
+ 'https://api.vimeo.com'
46
+ end
41
47
  end
42
48
  end
43
49
  end
@@ -1,5 +1,4 @@
1
1
  require 'purdie'
2
- require 'cgi'
3
2
  require 'google/api_client'
4
3
 
5
4
  module Purdie
@@ -1,3 +1,3 @@
1
1
  module Purdie
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/purdie.rb CHANGED
@@ -3,8 +3,7 @@ require 'yaml'
3
3
  require 'deep_merge'
4
4
  require 'httparty'
5
5
  require 'dotenv'
6
- require 'soundcloud'
7
- require 'flickraw-cached'
6
+ require 'cgi'
8
7
  require 'active_support/inflector'
9
8
 
10
9
  require 'purdie/version'
@@ -18,3 +17,5 @@ require 'purdie/services/soundcloud'
18
17
  require 'purdie/services/flickr'
19
18
  require 'purdie/services/vimeo'
20
19
  require 'purdie/services/youtube'
20
+
21
+ Dotenv.load
@@ -22,6 +22,19 @@ license_url: http://creativecommons.org/licenses/by-nc-sa/3.0/
22
22
  "
23
23
  )
24
24
  end
25
+
26
+ context 'resolve an album' do
27
+ it 'resolves an album from a URL' do
28
+ # We're going to call this a set for consistency
29
+ set = Vimeo.resolve_set 'https://vimeo.com/album/3296736'
30
+ expect(set.count).to eq 3
31
+ expect(set).to eq [
32
+ 'https://vimeo.com/rawfunkmaharishi/safetyonboard',
33
+ 'https://vimeo.com/rawfunkmaharishi/trappedinhawaii',
34
+ 'https://vimeo.com/rawfunkmaharishi/discotheque-metamorphosis'
35
+ ]
36
+ end
37
+ end
25
38
  end
26
39
  end
27
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purdie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - pikesley
@@ -311,7 +311,6 @@ files:
311
311
  - _data/flickr.yaml
312
312
  - _data/soundcloud.yaml
313
313
  - bin/purdie
314
- - cruft.rb
315
314
  - features/bad-url.feature
316
315
  - features/comments.feature
317
316
  - features/flickr-album.feature
@@ -356,7 +355,6 @@ files:
356
355
  - lib/purdie/services/youtube.rb
357
356
  - lib/purdie/source_list.rb
358
357
  - lib/purdie/version.rb
359
- - list
360
358
  - purdie.gemspec
361
359
  - spec/config_spec.rb
362
360
  - spec/helpers_spec.rb
@@ -387,7 +385,6 @@ files:
387
385
  - spec/vcr/Purdie_SourceList/resolve_sets/resolves_a_Flickr_set.yml
388
386
  - spec/vcr/Purdie_SourceList/resolve_sets/resolves_a_SoundCloud_set.yml
389
387
  - spec/vcr/Purdie_SourceList/resolves_a_Flickr_set.yml
390
- - wtf.log
391
388
  homepage: ''
392
389
  licenses:
393
390
  - MIT
data/cruft.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'active_support/inflector'
2
-
3
- class Thing
4
- def hello
5
- puts "I am a #{self.class.name}"
6
- end
7
- end
8
-
9
- t = "Thing".constantize.new
10
- t.hello
data/list DELETED
@@ -1 +0,0 @@
1
- https://soundcloud.com/rawfunkmaharishi/bernard
data/wtf.log DELETED
@@ -1 +0,0 @@
1
- 16252009191