purdie 0.0.6 → 0.0.7
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 +4 -4
- data/_config/defaults.yaml +3 -0
- data/features/bad-url.feature +23 -0
- data/features/support/fixtures/vcr/A_URL_we_don_t_understand/Handle_a_URL_we_don_t_recognise.yml +125 -0
- data/lib/purdie/bernard.rb +10 -10
- data/lib/purdie/ingester.rb +11 -1
- data/lib/purdie/services/flickr.rb +5 -10
- data/lib/purdie/services/soundcloud.rb +3 -8
- data/lib/purdie/services/vimeo.rb +3 -10
- data/lib/purdie/version.rb +1 -1
- data/lib/purdie.rb +4 -0
- data/spec/purdie_spec.rb +11 -0
- data/spec/services/flickr_spec.rb +24 -20
- data/spec/services/soundcloud_spec.rb +22 -17
- data/spec/services/vimeo_spec.rb +9 -7
- metadata +6 -3
- data/config/defaults.yaml +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 04f101bd6d74f547d4d0aacbaf845cf551100090
|
|
4
|
+
data.tar.gz: d511d5d70c4715770e5232f2ab488ac032c401c1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6316288b941a65db4aaec4e5d360cc67f9d3d95e457ffed7d5d8674046f0609a996537386ee835a80805c912e94e9e96e1e9641f72eac1a577c71cc08c433c87
|
|
7
|
+
data.tar.gz: 90808bb2a634f80ba612b2e45b1bf04d018909636ec310ba6c15786fe8ebdf212d3901b9e90c589aa8f1f9da6fa3a061fbaf67735feb074d4159dccbd27e64b6
|
data/_config/defaults.yaml
CHANGED
|
@@ -15,11 +15,14 @@ license-lookups:
|
|
|
15
15
|
services:
|
|
16
16
|
SoundCloud:
|
|
17
17
|
host: https://api.soundcloud.com
|
|
18
|
+
matcher: soundcloud.com
|
|
18
19
|
output-file: soundcloud.yaml
|
|
19
20
|
|
|
20
21
|
Flickr:
|
|
22
|
+
matcher: flickr.com
|
|
21
23
|
output-file: flickr.yaml
|
|
22
24
|
|
|
23
25
|
Vimeo:
|
|
24
26
|
host: https://api.vimeo.com
|
|
27
|
+
matcher: vimeo.com
|
|
25
28
|
output-file: vimeo.yaml
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@vcr
|
|
2
|
+
Feature: A URL we don't understand
|
|
3
|
+
|
|
4
|
+
Scenario: Handle a URL we don't recognise
|
|
5
|
+
Given a file named "_sources/flickr.csv" with:
|
|
6
|
+
"""
|
|
7
|
+
https://www.flickr.com/photos/rawfunkmaharishi/15631479625/
|
|
8
|
+
https://www.madeup.com/foo/bar/
|
|
9
|
+
"""
|
|
10
|
+
When I successfully run `purdie fetch`
|
|
11
|
+
Then a file named "_data/flickr.yaml" should exist
|
|
12
|
+
And the file "_data/flickr.yaml" should contain:
|
|
13
|
+
"""
|
|
14
|
+
- title: The Comedy, October 2014
|
|
15
|
+
date: '2014-10-22'
|
|
16
|
+
photo_page: https://www.flickr.com/photos/rawfunkmaharishi/15631479625/
|
|
17
|
+
photo_url: https://farm4.staticflickr.com/3933/15631479625_b6168ee903_m.jpg
|
|
18
|
+
license: Attribution-NonCommercial-ShareAlike
|
|
19
|
+
license_url: https://creativecommons.org/licenses/by-nc-sa/2.0/
|
|
20
|
+
photographer: kim
|
|
21
|
+
"""
|
|
22
|
+
And a file named "_data/soundcloud.yaml" should not exist
|
|
23
|
+
And a file named "_data/vimeo.yaml" should not exist
|
data/features/support/fixtures/vcr/A_URL_we_don_t_understand/Handle_a_URL_we_don_t_recognise.yml
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: post
|
|
5
|
+
uri: https://api.flickr.com/services/rest/
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: photo_id=15631479625&method=flickr.photos.getInfo&format=json&nojsoncallback=1
|
|
9
|
+
headers:
|
|
10
|
+
Accept-Encoding:
|
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
+
Accept:
|
|
13
|
+
- "*/*"
|
|
14
|
+
User-Agent:
|
|
15
|
+
- FlickRaw/0.9.8
|
|
16
|
+
Authorization:
|
|
17
|
+
- OAuth realm="https://api.flickr.com/services/rest/", oauth_consumer_key="<FLICKR_API_KEY>",
|
|
18
|
+
oauth_nonce="vfG7%2FPONCqyiQTbtNojJshXuPyM10DN9oV3%2BJ9D7MQE%3D", oauth_signature="<FLICKR_SECRET>%26",
|
|
19
|
+
oauth_signature_method="PLAINTEXT", oauth_timestamp="1425475096", oauth_token="",
|
|
20
|
+
oauth_version="1.0"
|
|
21
|
+
Content-Type:
|
|
22
|
+
- application/x-www-form-urlencoded
|
|
23
|
+
response:
|
|
24
|
+
status:
|
|
25
|
+
code: 200
|
|
26
|
+
message: OK
|
|
27
|
+
headers:
|
|
28
|
+
Date:
|
|
29
|
+
- Wed, 04 Mar 2015 13:18:17 GMT
|
|
30
|
+
Content-Type:
|
|
31
|
+
- application/json
|
|
32
|
+
Content-Length:
|
|
33
|
+
- '665'
|
|
34
|
+
P3p:
|
|
35
|
+
- policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
|
|
36
|
+
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
|
|
37
|
+
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
|
|
38
|
+
Cache-Control:
|
|
39
|
+
- private
|
|
40
|
+
X-Served-By:
|
|
41
|
+
- www39.flickr.bf1.yahoo.com
|
|
42
|
+
Vary:
|
|
43
|
+
- Accept-Encoding
|
|
44
|
+
Age:
|
|
45
|
+
- '1'
|
|
46
|
+
Via:
|
|
47
|
+
- http/1.1 fts103.flickr.bf1.yahoo.com (ApacheTrafficServer/4.0.2 [cMsSf ]),
|
|
48
|
+
http/1.1 r16.ycpi.dea.yahoo.net (ApacheTrafficServer [cMsSf ])
|
|
49
|
+
Server:
|
|
50
|
+
- ATS
|
|
51
|
+
Connection:
|
|
52
|
+
- keep-alive
|
|
53
|
+
body:
|
|
54
|
+
encoding: ASCII-8BIT
|
|
55
|
+
string: '{"photo":{"id":"15631479625","secret":"b6168ee903","server":"3933","farm":4,"dateuploaded":"1414326010","isfavorite":0,"license":"1","safety_level":"0","rotation":0,"originalsecret":"3191340cdb","originalformat":"jpg","owner":{"nsid":"128943844@N06","username":"rawfunkmaharishi","realname":"Raw
|
|
56
|
+
Funk Maharishi","location":"","iconserver":"3933","iconfarm":4,"path_alias":"rawfunkmaharishi"},"title":{"_content":"The
|
|
57
|
+
Comedy, October 2014"},"description":{"_content":""},"visibility":{"ispublic":1,"isfriend":0,"isfamily":0},"dates":{"posted":"1414326010","taken":"2014-10-22
|
|
58
|
+
15:54:24","takengranularity":"0","takenunknown":"0","lastupdate":"1416111853"},"views":"92","editability":{"cancomment":0,"canaddmeta":0},"publiceditability":{"cancomment":1,"canaddmeta":0},"usage":{"candownload":1,"canblog":0,"canprint":0,"canshare":1},"comments":{"_content":"0"},"notes":{"note":[]},"people":{"haspeople":0},"tags":{"tag":[{"id":"128898522-15631479625-1422028","author":"128943844@N06","authorname":"rawfunkmaharishi","raw":"the
|
|
59
|
+
comedy","_content":"thecomedy","machine_tag":0},{"id":"128898522-15631479625-17975","author":"128943844@N06","authorname":"rawfunkmaharishi","raw":"gigs","_content":"gigs","machine_tag":0},{"id":"128898522-15631479625-228989594","author":"128943844@N06","authorname":"rawfunkmaharishi","raw":"photographer:kim","_content":"photographerkim","machine_tag":0}]},"urls":{"url":[{"type":"photopage","_content":"https:\/\/www.flickr.com\/photos\/rawfunkmaharishi\/15631479625\/"}]},"media":"photo"},"stat":"ok"}'
|
|
60
|
+
http_version:
|
|
61
|
+
recorded_at: Wed, 04 Mar 2015 13:18:17 GMT
|
|
62
|
+
- request:
|
|
63
|
+
method: post
|
|
64
|
+
uri: https://api.flickr.com/services/rest/
|
|
65
|
+
body:
|
|
66
|
+
encoding: US-ASCII
|
|
67
|
+
string: method=flickr.photos.licenses.getInfo&format=json&nojsoncallback=1
|
|
68
|
+
headers:
|
|
69
|
+
Accept-Encoding:
|
|
70
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
71
|
+
Accept:
|
|
72
|
+
- "*/*"
|
|
73
|
+
User-Agent:
|
|
74
|
+
- FlickRaw/0.9.8
|
|
75
|
+
Authorization:
|
|
76
|
+
- OAuth realm="https://api.flickr.com/services/rest/", oauth_consumer_key="<FLICKR_API_KEY>",
|
|
77
|
+
oauth_nonce="%2BtDhocea9FQQSlRzXg6MygKmusNJNQzYOVBJU%2BqxYo0%3D", oauth_signature="<FLICKR_SECRET>%26",
|
|
78
|
+
oauth_signature_method="PLAINTEXT", oauth_timestamp="1425475097", oauth_token="",
|
|
79
|
+
oauth_version="1.0"
|
|
80
|
+
Content-Type:
|
|
81
|
+
- application/x-www-form-urlencoded
|
|
82
|
+
response:
|
|
83
|
+
status:
|
|
84
|
+
code: 200
|
|
85
|
+
message: OK
|
|
86
|
+
headers:
|
|
87
|
+
Date:
|
|
88
|
+
- Wed, 04 Mar 2015 13:18:17 GMT
|
|
89
|
+
Content-Type:
|
|
90
|
+
- application/json
|
|
91
|
+
Content-Length:
|
|
92
|
+
- '314'
|
|
93
|
+
P3p:
|
|
94
|
+
- policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
|
|
95
|
+
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY
|
|
96
|
+
ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
|
|
97
|
+
Cache-Control:
|
|
98
|
+
- private
|
|
99
|
+
X-Served-By:
|
|
100
|
+
- www289.flickr.bf1.yahoo.com
|
|
101
|
+
Vary:
|
|
102
|
+
- Accept-Encoding
|
|
103
|
+
Age:
|
|
104
|
+
- '0'
|
|
105
|
+
Via:
|
|
106
|
+
- http/1.1 fts123.flickr.bf1.yahoo.com (ApacheTrafficServer/4.0.2 [cMsSf ]),
|
|
107
|
+
http/1.1 r01.ycpi.dea.yahoo.net (ApacheTrafficServer [cMsSf ])
|
|
108
|
+
Server:
|
|
109
|
+
- ATS
|
|
110
|
+
Connection:
|
|
111
|
+
- keep-alive
|
|
112
|
+
body:
|
|
113
|
+
encoding: ASCII-8BIT
|
|
114
|
+
string: '{"licenses":{"license":[{"id":"0","name":"All Rights Reserved","url":""},{"id":"4","name":"Attribution
|
|
115
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by\/2.0\/"},{"id":"6","name":"Attribution-NoDerivs
|
|
116
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by-nd\/2.0\/"},{"id":"3","name":"Attribution-NonCommercial-NoDerivs
|
|
117
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by-nc-nd\/2.0\/"},{"id":"2","name":"Attribution-NonCommercial
|
|
118
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by-nc\/2.0\/"},{"id":"1","name":"Attribution-NonCommercial-ShareAlike
|
|
119
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by-nc-sa\/2.0\/"},{"id":"5","name":"Attribution-ShareAlike
|
|
120
|
+
License","url":"https:\/\/creativecommons.org\/licenses\/by-sa\/2.0\/"},{"id":"7","name":"No
|
|
121
|
+
known copyright restrictions","url":"https:\/\/www.flickr.com\/commons\/usage\/"},{"id":"8","name":"United
|
|
122
|
+
States Government Work","url":"http:\/\/www.usa.gov\/copyright.shtml"}]},"stat":"ok"}'
|
|
123
|
+
http_version:
|
|
124
|
+
recorded_at: Wed, 04 Mar 2015 13:18:17 GMT
|
|
125
|
+
recorded_with: VCR 2.9.3
|
data/lib/purdie/bernard.rb
CHANGED
|
@@ -15,24 +15,24 @@ module Purdie
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def fetch
|
|
18
|
-
services = {}
|
|
19
|
-
@config['services'].each do |s|
|
|
20
|
-
services[s[0].downcase.to_sym] = "Purdie::Services::#{s[0]}".constantize.new(@config)
|
|
21
|
-
end
|
|
18
|
+
services = @config['services'].keys.map { |s| "Purdie::Services::#{s}".constantize.new(@config)}
|
|
22
19
|
|
|
23
20
|
@sources.each do |source|
|
|
24
21
|
File.readlines(source).each do |line|
|
|
25
22
|
next if line[0] == '#'
|
|
26
23
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
begin
|
|
25
|
+
print "Processing #{line.strip}... "
|
|
26
|
+
services.select{ |s| line =~ /#{s.subconfig['matcher']}/ }[0].ingest line
|
|
27
|
+
rescue NoMethodError => nme
|
|
28
|
+
puts 'unrecognised URL' if nme.message == "undefined method `ingest' for nil:NilClass"
|
|
29
|
+
else
|
|
30
|
+
puts 'done'
|
|
31
|
+
end
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
services.
|
|
34
|
-
services[k].write
|
|
35
|
-
end
|
|
35
|
+
services.map { |service| service.write }
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
end
|
data/lib/purdie/ingester.rb
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
Dotenv.load
|
|
2
|
+
|
|
1
3
|
module Purdie
|
|
2
4
|
module Ingester
|
|
5
|
+
attr_reader :config, :subconfig
|
|
6
|
+
|
|
7
|
+
def initialize config
|
|
8
|
+
@config = config
|
|
9
|
+
@subconfig = @config['services'][Purdie.basename self]
|
|
10
|
+
@items = []
|
|
11
|
+
end
|
|
12
|
+
|
|
3
13
|
def ingest url
|
|
4
14
|
@items.push distill url
|
|
5
15
|
end
|
|
@@ -20,7 +30,7 @@ module Purdie
|
|
|
20
30
|
if self.has_items?
|
|
21
31
|
FileUtils.mkdir_p @config['output-dir']
|
|
22
32
|
|
|
23
|
-
File.open "#{@config['output-dir']}/#{@
|
|
33
|
+
File.open "#{@config['output-dir']}/#{@subconfig['output-file']}", 'w' do |f|
|
|
24
34
|
f.write self.to_yaml
|
|
25
35
|
end
|
|
26
36
|
end
|
|
@@ -2,29 +2,24 @@ require 'purdie'
|
|
|
2
2
|
|
|
3
3
|
Dotenv.load
|
|
4
4
|
|
|
5
|
+
FlickRaw.api_key = ENV['FLICKR_API_KEY']
|
|
6
|
+
FlickRaw.shared_secret = ENV['FLICKR_SECRET']
|
|
7
|
+
|
|
5
8
|
module Purdie
|
|
6
9
|
module Services
|
|
7
10
|
class Flickr
|
|
8
11
|
include Purdie::Ingester
|
|
9
12
|
|
|
10
|
-
def initialize config
|
|
11
|
-
@config = config
|
|
12
|
-
@items = []
|
|
13
|
-
|
|
14
|
-
FlickRaw.api_key = ENV['FLICKR_API_KEY']
|
|
15
|
-
FlickRaw.shared_secret = ENV['FLICKR_SECRET']
|
|
16
|
-
end
|
|
17
|
-
|
|
18
13
|
def licenses
|
|
19
14
|
@licenses ||= flickr.photos.licenses.getInfo
|
|
20
15
|
end
|
|
21
16
|
|
|
22
|
-
def
|
|
17
|
+
def get url
|
|
23
18
|
flickr.photos.getInfo photo_id: Purdie.get_id(url)
|
|
24
19
|
end
|
|
25
20
|
|
|
26
21
|
def distill url
|
|
27
|
-
photo =
|
|
22
|
+
photo = get url
|
|
28
23
|
results = {}
|
|
29
24
|
|
|
30
25
|
results['title'] = photo['title']
|
|
@@ -7,27 +7,22 @@ module Purdie
|
|
|
7
7
|
class SoundCloud
|
|
8
8
|
include Purdie::Ingester
|
|
9
9
|
|
|
10
|
-
def initialize config
|
|
11
|
-
@config = config
|
|
12
|
-
@items = []
|
|
13
|
-
end
|
|
14
|
-
|
|
15
10
|
def all_tracks
|
|
16
11
|
@all_tracks ||= begin
|
|
17
|
-
url = "#{@
|
|
12
|
+
url = "#{@subconfig['host']}/users/#{ENV['SOUNDCLOUD_USER_ID']}/tracks?client_id=#{ENV['SOUNDCLOUD_CLIENT_ID']}"
|
|
18
13
|
response = HTTParty.get url
|
|
19
14
|
JSON.parse response.body
|
|
20
15
|
end
|
|
21
16
|
end
|
|
22
17
|
|
|
23
|
-
def
|
|
18
|
+
def get url
|
|
24
19
|
all_tracks.select do |track|
|
|
25
20
|
Purdie.strip_scheme(track['permalink_url']) == Purdie.strip_scheme(url)
|
|
26
21
|
end[0]
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
def distill url
|
|
30
|
-
track =
|
|
25
|
+
track = get url
|
|
31
26
|
results = {}
|
|
32
27
|
results['title'] = track['title']
|
|
33
28
|
results['id'] = track['id']
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
require 'purdie'
|
|
2
2
|
|
|
3
|
-
Dotenv.load
|
|
4
|
-
|
|
5
3
|
module Purdie
|
|
6
4
|
module Services
|
|
7
5
|
class Vimeo
|
|
8
6
|
include Purdie::Ingester
|
|
9
|
-
|
|
10
|
-
def initialize config
|
|
11
|
-
@config = config
|
|
12
|
-
@items = []
|
|
13
|
-
end
|
|
14
7
|
|
|
15
|
-
def
|
|
8
|
+
def get url
|
|
16
9
|
@id = Purdie.get_id url
|
|
17
10
|
|
|
18
|
-
target = "#{@
|
|
11
|
+
target = "#{@subconfig['host']}/videos/#{@id}"
|
|
19
12
|
headers = {
|
|
20
13
|
'Authorization' => "bearer #{ENV['VIMEO_BEARER_TOKEN']}",
|
|
21
14
|
'Accept' => 'application/json'
|
|
@@ -26,7 +19,7 @@ module Purdie
|
|
|
26
19
|
end
|
|
27
20
|
|
|
28
21
|
def distill url
|
|
29
|
-
video =
|
|
22
|
+
video = get url
|
|
30
23
|
results = {}
|
|
31
24
|
|
|
32
25
|
results['title'] = video['name']
|
data/lib/purdie/version.rb
CHANGED
data/lib/purdie.rb
CHANGED
data/spec/purdie_spec.rb
CHANGED
|
@@ -19,5 +19,16 @@ module Purdie
|
|
|
19
19
|
it 'gets an id' do
|
|
20
20
|
expect(Purdie.get_id 'http://foo.bar/654321').to eq 654321
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
it 'gets a basename for a class' do
|
|
24
|
+
module Medeski
|
|
25
|
+
module Martin
|
|
26
|
+
class Wood
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
@mmw = Medeski::Martin::Wood.new
|
|
31
|
+
expect(Purdie.basename @mmw).to eq 'Wood'
|
|
32
|
+
end
|
|
22
33
|
end
|
|
23
34
|
end
|
|
@@ -8,32 +8,36 @@ module Purdie
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it 'distills data for a regular photo', :vcr do
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
dist = @f.distill 'https://www.flickr.com/photos/rawfunkmaharishi/15631479625/'
|
|
12
|
+
expect(dist.to_yaml).to eq(
|
|
13
|
+
"---
|
|
14
|
+
title: The Comedy, October 2014
|
|
15
|
+
date: '2014-10-22'
|
|
16
|
+
photo_page: https://www.flickr.com/photos/rawfunkmaharishi/15631479625/
|
|
17
|
+
photo_url: https://farm4.staticflickr.com/3933/15631479625_b6168ee903_m.jpg
|
|
18
|
+
license: Attribution-NonCommercial-ShareAlike
|
|
19
|
+
license_url: https://creativecommons.org/licenses/by-nc-sa/2.0/
|
|
20
|
+
photographer: kim
|
|
21
|
+
"
|
|
22
|
+
)
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
it 'ingests data for a photo without a specific photographer tag', :vcr do
|
|
23
26
|
@f.ingest 'https://www.flickr.com/photos/cluttercup/15950875724/'
|
|
24
|
-
expect(@f[0]).to eq (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
expect(@f[0].to_yaml).to eq (
|
|
28
|
+
"---
|
|
29
|
+
title: Raw Funk Maharishi
|
|
30
|
+
date: '2015-02-18'
|
|
31
|
+
photo_page: https://www.flickr.com/photos/cluttercup/15950875724/
|
|
32
|
+
photo_url: https://farm8.staticflickr.com/7398/15950875724_23d58be214_m.jpg
|
|
33
|
+
license: Attribution-NonCommercial
|
|
34
|
+
license_url: https://creativecommons.org/licenses/by-nc/2.0/
|
|
35
|
+
photographer: jane
|
|
36
|
+
"
|
|
37
|
+
)
|
|
33
38
|
end
|
|
34
39
|
|
|
35
|
-
it 'falls back to the default photographer name', :vcr do
|
|
36
|
-
expect(@f.distill('https://www.flickr.com/photos/pikesley/16649739916/')['photographer']).to eq 'pikesley'
|
|
40
|
+
it 'falls back to the default photographer name', :vcr do expect(@f.distill('https://www.flickr.com/photos/pikesley/16649739916/')['photographer']).to eq 'pikesley'
|
|
37
41
|
end
|
|
38
42
|
end
|
|
39
43
|
end
|
|
@@ -12,32 +12,37 @@ module Purdie
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it 'extracts a track', :vcr do
|
|
15
|
-
track = @sc.
|
|
15
|
+
track = @sc.get 'https://soundcloud.com/rawfunkmaharishi/hexaflexagon-1'
|
|
16
16
|
expect(track).to be_a Hash
|
|
17
17
|
expect(track['id']). to eq 193008299
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
it 'distills the data', :vcr do
|
|
21
|
-
|
|
22
|
-
expect(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
distilled = @sc.distill 'https://soundcloud.com/rawfunkmaharishi/hexaflexagon-1'
|
|
22
|
+
expect(distilled.to_yaml).to eq(
|
|
23
|
+
"---
|
|
24
|
+
title: Hexaflexagon
|
|
25
|
+
id: 193008299
|
|
26
|
+
location: Islington Academy
|
|
27
|
+
date: '2015-02-18'
|
|
28
|
+
license: Attribution-NonCommercial-ShareAlike
|
|
29
|
+
license_url: http://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
30
|
+
"
|
|
31
|
+
)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
it 'ingests a track', :vcr do
|
|
32
35
|
@sc.ingest 'https://soundcloud.com/rawfunkmaharishi/bernard'
|
|
33
|
-
expect(@sc[0]).to eq(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
expect(@sc[0].to_yaml).to eq(
|
|
37
|
+
"---
|
|
38
|
+
title: Bernard
|
|
39
|
+
id: 192841052
|
|
40
|
+
location: Islington Academy
|
|
41
|
+
date: '2015-02-18'
|
|
42
|
+
license: Attribution-NonCommercial-ShareAlike
|
|
43
|
+
license_url: http://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
44
|
+
"
|
|
45
|
+
)
|
|
41
46
|
end
|
|
42
47
|
end
|
|
43
48
|
end
|
data/spec/services/vimeo_spec.rb
CHANGED
|
@@ -8,17 +8,19 @@ module Purdie
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it 'gets a video', :vcr do
|
|
11
|
-
expect(@v.
|
|
11
|
+
expect(@v.get 'https://vimeo.com/117102891').to be_a Hash
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it 'ingests a video', :vcr do
|
|
15
15
|
@v.ingest 'https://vimeo.com/117102891'
|
|
16
|
-
expect(@v[0]).to eq(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
expect(@v[0].to_yaml).to eq(
|
|
17
|
+
"---
|
|
18
|
+
title: Bernard
|
|
19
|
+
id: 117102891
|
|
20
|
+
license: Attribution-NonCommercial-ShareAlike
|
|
21
|
+
license_url: http://creativecommons.org/licenses/by-nc-sa/3.0/
|
|
22
|
+
"
|
|
23
|
+
)
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
26
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: purdie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- pikesley
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-03-
|
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -281,8 +281,8 @@ files:
|
|
|
281
281
|
- Rakefile
|
|
282
282
|
- _config/defaults.yaml
|
|
283
283
|
- bin/purdie
|
|
284
|
-
- config/defaults.yaml
|
|
285
284
|
- cruft.rb
|
|
285
|
+
- features/bad-url.feature
|
|
286
286
|
- features/comments.feature
|
|
287
287
|
- features/flickr.feature
|
|
288
288
|
- features/purdie.feature
|
|
@@ -292,6 +292,7 @@ files:
|
|
|
292
292
|
- features/step_definitions/purdie_steps.rb
|
|
293
293
|
- features/support/env.rb
|
|
294
294
|
- features/support/fixtures/_config/purdie.yaml
|
|
295
|
+
- features/support/fixtures/vcr/A_URL_we_don_t_understand/Handle_a_URL_we_don_t_recognise.yml
|
|
295
296
|
- features/support/fixtures/vcr/First_contact_with_the_Real_World/Generate_YAML_for_the_Raw_Funk_Maharishi.yml
|
|
296
297
|
- features/support/fixtures/vcr/Flickr/Generate_Flickr_YAML.yml
|
|
297
298
|
- features/support/fixtures/vcr/Handle_comments/Handle_comments_in_a_source_file.yml
|
|
@@ -359,6 +360,7 @@ specification_version: 4
|
|
|
359
360
|
summary: Capture metadata from Flickr, SoundCloud et al for when we're building a
|
|
360
361
|
static site
|
|
361
362
|
test_files:
|
|
363
|
+
- features/bad-url.feature
|
|
362
364
|
- features/comments.feature
|
|
363
365
|
- features/flickr.feature
|
|
364
366
|
- features/purdie.feature
|
|
@@ -368,6 +370,7 @@ test_files:
|
|
|
368
370
|
- features/step_definitions/purdie_steps.rb
|
|
369
371
|
- features/support/env.rb
|
|
370
372
|
- features/support/fixtures/_config/purdie.yaml
|
|
373
|
+
- features/support/fixtures/vcr/A_URL_we_don_t_understand/Handle_a_URL_we_don_t_recognise.yml
|
|
371
374
|
- features/support/fixtures/vcr/First_contact_with_the_Real_World/Generate_YAML_for_the_Raw_Funk_Maharishi.yml
|
|
372
375
|
- features/support/fixtures/vcr/Flickr/Generate_Flickr_YAML.yml
|
|
373
376
|
- features/support/fixtures/vcr/Handle_comments/Handle_comments_in_a_source_file.yml
|
data/config/defaults.yaml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
source-dir: _sources
|
|
2
|
-
output-dir: _data
|
|
3
|
-
default-title: Bernard Purdie, the World's most-recorded drummer
|
|
4
|
-
|
|
5
|
-
license-lookups:
|
|
6
|
-
cc-by-nc-sa:
|
|
7
|
-
short-name: BY-NC-SA
|
|
8
|
-
full-name: Attribution-NonCommercial-ShareAlike
|
|
9
|
-
url: http://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
10
|
-
by-nc-sa:
|
|
11
|
-
short-name: BY-NC-SA
|
|
12
|
-
full-name: Attribution-NonCommercial-ShareAlike
|
|
13
|
-
url: http://creativecommons.org/licenses/by-nc-sa/3.0/
|
|
14
|
-
|
|
15
|
-
services:
|
|
16
|
-
SoundCloud:
|
|
17
|
-
host: https://api.soundcloud.com
|
|
18
|
-
output-file: soundcloud.yaml
|
|
19
|
-
|
|
20
|
-
Flickr:
|
|
21
|
-
output-file: flickr.yaml
|
|
22
|
-
|
|
23
|
-
Vimeo:
|
|
24
|
-
host: https://api.vimeo.com
|
|
25
|
-
output-file: vimeo.yaml
|