fronkin_bandcamp_scraper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1ec436a6610753f56f5314a8fab687e51906e5d9
4
+ data.tar.gz: d449ca8e9c6350c1a4d04f99cea1d0aac6cfd0bb
5
+ SHA512:
6
+ metadata.gz: 6fa18f6c586535fce639aa9a10fb0ef2310824be1baec4333471687fd9091eb53624532621f4f3bfc1fc83ccf9fad0cd65ba5f67bdf0ca567773d3e183cc0a9a
7
+ data.tar.gz: 5ee3877ff7bf508a00d5bde46c09163c6672eb43c5c6f3143a843cb23598d5b8e0b833c06adf2fa536d99441e5189465648fc628a5f52863ebf0e27de50c4586
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.pryrc ADDED
@@ -0,0 +1,9 @@
1
+ require 'fronkin_bandcamp_scraper'
2
+ require 'awesome_print'
3
+
4
+ def reload!
5
+ load 'fronkin_bandcamp_scraper/scraper.rb'
6
+ end
7
+
8
+ url = 'https://piglet.bandcamp.com/album/lava-land'
9
+ scraper = FronkinBandcampScraper::Scraper.new(url)
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,30 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Mantras
4
+
5
+ * **Don't be a shithead, check yo self before you wreck yo self**
6
+ * Be respectful of differing viewpoints and experiences
7
+ * Gracefully accept constructive criticism
8
+ * Focus on what is best for the community
9
+ * Showing empathy towards other community members
10
+ * Bring da ruckus
11
+
12
+ ## Responsibilities
13
+
14
+ Project maintainers are responsible for clarifying the standards of acceptable
15
+ behavior and are expected to take appropriate and fair corrective action in
16
+ response to any instances of unacceptable behavior.
17
+
18
+ Project maintainers have the right and responsibility to remove, edit, or
19
+ reject comments, commits, code, wiki edits, issues, and other contributions
20
+ that are not aligned to this Code of Conduct, or to ban temporarily or
21
+ permanently any contributor for other behaviors that they deem inappropriate,
22
+ threatening, offensive, or harmful.
23
+
24
+ ## Attribution
25
+
26
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
27
+ available at [http://contributor-covenant.org/version/1/4][version]
28
+
29
+ [homepage]: http://contributor-covenant.org
30
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in fronkin_bandcamp_scraper.gemspec
6
+ gemspec
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fronkin_bandcamp_scraper (0.1.0)
5
+ nokogiri (~> 1.8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ awesome_print (1.8.0)
11
+ byebug (10.0.2)
12
+ coderay (1.1.2)
13
+ diff-lcs (1.3)
14
+ method_source (0.9.0)
15
+ mini_portile2 (2.3.0)
16
+ nokogiri (1.8.2)
17
+ mini_portile2 (~> 2.3.0)
18
+ pry (0.11.3)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.9.0)
21
+ pry-byebug (3.6.0)
22
+ byebug (~> 10.0)
23
+ pry (~> 0.10)
24
+ rake (10.4.2)
25
+ rspec (3.7.0)
26
+ rspec-core (~> 3.7.0)
27
+ rspec-expectations (~> 3.7.0)
28
+ rspec-mocks (~> 3.7.0)
29
+ rspec-core (3.7.1)
30
+ rspec-support (~> 3.7.0)
31
+ rspec-expectations (3.7.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.7.0)
34
+ rspec-mocks (3.7.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.7.0)
37
+ rspec-support (3.7.1)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ awesome_print (~> 1.8)
44
+ bundler (~> 1.16)
45
+ fronkin_bandcamp_scraper!
46
+ pry (~> 0.11)
47
+ pry-byebug (~> 3.6)
48
+ rake (~> 10.0)
49
+ rspec (~> 3.7)
50
+
51
+ BUNDLED WITH
52
+ 1.16.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Fronk Lom Lom
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,116 @@
1
+ # FronkinBandcampScraper
2
+
3
+ Maybe you thought you'd flop your way to a championship.
4
+
5
+ Maybe you blame the refs for blowing calls.
6
+
7
+ Maybe you assumed this was the year.
8
+
9
+ **BALL DON'T LIE**
10
+
11
+ This is a simple webscraper for bandcamp. Read through the entire README
12
+ before you try anything, thanks!
13
+
14
+ ## I. Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'fronkin_bandcamp_scraper'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install fronkin_bandcamp_scraper
29
+
30
+ ## II. Usage
31
+
32
+ ### Initialization
33
+
34
+ Given a bandcamp release URL, initialize a `Scraper` object like so:
35
+
36
+ ```ruby
37
+ url =
38
+ 'https://clevergirl.bandcamp.com/album/no-drum-and-bass-in-the-jazz-room'
39
+ scraper = FronkinBandcampScraper::Scraper.new(url)
40
+ ```
41
+
42
+ A `FronkingBandcampScraper::Scraper` has two public methods `#artist`
43
+ and `#release`, each with their own attributes.
44
+
45
+ ### Artist
46
+
47
+ ```ruby
48
+ scraper.artist.name # Clever Girl
49
+ scraper.artist.location # London, UK
50
+ scraper.artist.photo # Artist photo
51
+ ```
52
+
53
+ ### Release
54
+
55
+ ```ruby
56
+ scraper.release.title # No Drum and Bass in the Jazz Room
57
+ scraper.release.date # 20140423
58
+ scraper.release.cover # Release cover
59
+ scraper.release.tracks
60
+
61
+ [
62
+ [0] #<Struct:FronkinBandcampScraper::Track:0x7fe59082b158
63
+ duration = "05:28",
64
+ number = 1,
65
+ title = "Elm"
66
+ >,
67
+ [1] #<Struct:FronkinBandcampScraper::Track:0x7fe59082b0e0
68
+ duration = "06:09",
69
+ number = 2,
70
+ title = "ohmygodiloveyoupleasedontleaveme"
71
+ >,
72
+ [2] #<Struct:FronkinBandcampScraper::Track:0x7fe59082b0b8
73
+ duration = "05:07",
74
+ number = 3,
75
+ title = "Sleepyhead Symphony"
76
+ >,
77
+ [3] #<Struct:FronkinBandcampScraper::Track:0x7fe59082b040
78
+ duration = "05:28",
79
+ number = 4,
80
+ title = "Teleblister"
81
+ >
82
+ ]
83
+
84
+ scraper.release.tags # ["world", "London"]
85
+ ```
86
+
87
+ ## III. Miscellaneous
88
+
89
+ ### TODO
90
+
91
+ * Scrape release formats
92
+ * Scrape release fans
93
+ * Add CLI
94
+
95
+ ### Development
96
+
97
+ 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.
98
+
99
+ 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).
100
+
101
+ ### Contributing
102
+
103
+
104
+ Is something broken? Does this README need to be updated? Open an issue,
105
+ or even better, help me fix my shit! Suggestions and improvements are
106
+ welcome!
107
+
108
+ Bug reports and pull requests are welcome on GitHub at https://github.com/FTLam11/fronkin_bandcamp_scraper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
109
+
110
+ ### License
111
+
112
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
113
+
114
+ ### Code of Conduct
115
+
116
+ Everyone interacting in the FronkinBandcampScraper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/FTLam11/fronkin_bandcamp_scraper/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fronkin_bandcamp_scraper"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fronkin_bandcamp_scraper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fronkin_bandcamp_scraper'
8
+ spec.version = FronkinBandcampScraper::VERSION
9
+ spec.authors = ['Fronk Lom Lom']
10
+ spec.email = ['ryzingsun11@yahoo.com']
11
+
12
+ spec.summary = 'This gem is a convenient web scraper for Bandcamp releases.'
13
+ spec.description = 'YO, this gem is a convenient web scraper for Bandcamp releases. Currently, it scrapes artist and release information.'
14
+ spec.homepage = 'https://github.com/FTLam11/fronkin_bandcamp_scraper'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'nokogiri', '~> 1.8'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.7'
29
+ spec.add_development_dependency 'pry', '~> 0.11'
30
+ spec.add_development_dependency 'pry-byebug', '~> 3.6'
31
+ spec.add_development_dependency 'awesome_print', '~> 1.8'
32
+ end
@@ -0,0 +1,5 @@
1
+ require 'fronkin_bandcamp_scraper/version'
2
+ require 'fronkin_bandcamp_scraper/scraper'
3
+
4
+ module FronkinBandcampScraper
5
+ end
@@ -0,0 +1,9 @@
1
+ module FronkinBandcampScraper
2
+ class Artist
3
+ attr_accessor :name, :photo, :location
4
+
5
+ def initialize
6
+ yield self if block_given?
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ require 'fronkin_bandcamp_scraper/track'
2
+
3
+ module FronkinBandcampScraper
4
+ class Release
5
+ attr_accessor :doc, :title, :date, :cover, :tracks, :tags, :formats, :fans
6
+
7
+ def initialize(doc)
8
+ @doc = doc
9
+ @title = doc.css('div#name-section h2.trackTitle').text.strip
10
+ @date = doc.css('div.tralbumData.tralbum-credits meta').attribute('content').value
11
+ @cover = doc.css('div#tralbumArt a.popupImage').attribute('href').value
12
+ @tracks = scrape_tracks
13
+ @tags = doc.css('div.tralbumData.tralbum-tags a.tag').map(&:text)
14
+ end
15
+
16
+ private
17
+
18
+ def scrape_tracks
19
+ track_titles = doc.css('table#track_table td.title-col span[itemprop="name"]').map(&:text)
20
+ track_durations = doc.css('table#track_table td.title-col span.time').map { |node| node.text.strip }
21
+ track_titles.zip(track_durations).map.with_index { |t, idx| Track.new(idx + 1, t[0], t[1]) }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'fronkin_bandcamp_scraper/release'
4
+ require 'fronkin_bandcamp_scraper/artist'
5
+
6
+ module FronkinBandcampScraper
7
+ class Scraper
8
+ attr_reader :doc, :release, :artist
9
+
10
+ def initialize(url)
11
+ @doc = Nokogiri::HTML(open(url), nil, 'utf-8') { |config| config.noblanks }
12
+ scrape
13
+ end
14
+
15
+ private
16
+
17
+ def scrape
18
+ @release = Release.new(doc)
19
+ @artist = Artist.new do |a|
20
+ a.name = doc.css('div#bio-container span.title').text
21
+ a.photo = doc.css('div#bio-container div.bio-pic a.popupImage').attribute('href').value
22
+ a.location = doc.css('div#bio-container span.location').text
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module FronkinBandcampScraper
2
+ Track = Struct.new(:number, :title, :duration)
3
+ end
@@ -0,0 +1,3 @@
1
+ module FronkinBandcampScraper
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fronkin_bandcamp_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Fronk Lom Lom
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.16'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.16'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: awesome_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.8'
111
+ description: YO, this gem is a convenient web scraper for Bandcamp releases. Currently,
112
+ it scrapes artist and release information.
113
+ email:
114
+ - ryzingsun11@yahoo.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".pryrc"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - fronkin_bandcamp_scraper.gemspec
132
+ - lib/fronkin_bandcamp_scraper.rb
133
+ - lib/fronkin_bandcamp_scraper/artist.rb
134
+ - lib/fronkin_bandcamp_scraper/release.rb
135
+ - lib/fronkin_bandcamp_scraper/scraper.rb
136
+ - lib/fronkin_bandcamp_scraper/track.rb
137
+ - lib/fronkin_bandcamp_scraper/version.rb
138
+ homepage: https://github.com/FTLam11/fronkin_bandcamp_scraper
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: This gem is a convenient web scraper for Bandcamp releases.
162
+ test_files: []