QuarantineLiveStreams 0.1.0
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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +0 -0
- data/QuarantineLiveStreams.gemspec +38 -0
- data/README.md +42 -0
- data/Rakefile +2 -0
- data/bin/QLS +4 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/.DS_Store +0 -0
- data/lib/QuarantineLiveStreams.rb +8 -0
- data/lib/QuarantineLiveStreams/cli.rb +194 -0
- data/lib/QuarantineLiveStreams/event.rb +49 -0
- data/lib/QuarantineLiveStreams/scraper.rb +38 -0
- data/lib/QuarantineLiveStreams/version.rb +3 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 90b1753bfc1e5543cd0c5e1dd84ae5e6a5dac45c022b4c08ca961d50028b0b08
|
4
|
+
data.tar.gz: dc427283450842321241d7c3d90a31c853aa4c798a5a61b106181e2e015efe24
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25f56453c5f67f146f3cdf4dbd35cce3502b45f5f2036eee64fddfcc545a693f1832198a9be9b767351d08aad4dc9cd472eac02130b7994f921ceda916f2a60d
|
7
|
+
data.tar.gz: f2eb3223502d96427a944ceea9ce05f2af44fe93094464b32ddc55ca8af8f34a0be5d81d9b404462b8bc595e70f155d7c59effab1b30e8bece12e64c7ff947bc
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at <github email address>. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 <github username>
|
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.
|
data/NOTES.md
ADDED
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'lib/QuarantineLiveStreams/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "QuarantineLiveStreams"
|
5
|
+
spec.version = QuarantineLiveStreams::VERSION
|
6
|
+
spec.authors = ["mattenbar"]
|
7
|
+
spec.email = ["matthew.enbar@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{CLI scraper for quarantine live streams}
|
10
|
+
spec.description = %q{Scrapes upcoming events that are being live streamed and then returns the date time and link ot the event}
|
11
|
+
spec.homepage = "https://github.com/mattenbar/QLS"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
#spec.metadata["allowed_push_host"] = spec.homepage
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/mattenbar/QLS"
|
19
|
+
#spec.metadata["changelog_uri"] = "https://github.com/mattenbar/QLS.git"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
32
|
+
spec.add_development_dependency "pry"
|
33
|
+
spec.add_dependency "nokogiri"
|
34
|
+
spec.add_dependency "uri"
|
35
|
+
spec.add_dependency "colorize", '~> 0.8.1'
|
36
|
+
|
37
|
+
end
|
38
|
+
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# QuarantineLiveStreams
|
2
|
+
|
3
|
+
Find upcoming music live streams during Quarantine
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'QuarantineLiveStreams'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install QuarantineLiveStreams
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Free for all
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
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).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mattenbar/QuarantineLiveStreams. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mattenbar/QuarantineLiveStreams/blob/master/CODE_OF_CONDUCT.md).
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
39
|
+
|
40
|
+
## Code of Conduct
|
41
|
+
|
42
|
+
Everyone interacting in the QuarantineLiveStreams project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mattenbar/QuarantineLiveStreams/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/QLS
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "QuarantineLiveStreams"
|
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__)
|
data/bin/setup
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative "./QuarantineLiveStreams/version"
|
2
|
+
require_relative "./QuarantineLiveStreams/cli"
|
3
|
+
require_relative "./QuarantineLiveStreams/scraper"
|
4
|
+
require_relative "./QuarantineLiveStreams/event"
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'pry'
|
8
|
+
require 'colorize'
|
@@ -0,0 +1,194 @@
|
|
1
|
+
class QuarantineLiveStreams::CLI
|
2
|
+
def call
|
3
|
+
welcome
|
4
|
+
make_events
|
5
|
+
menu
|
6
|
+
goodbye
|
7
|
+
end
|
8
|
+
|
9
|
+
def menu
|
10
|
+
input = nil
|
11
|
+
while input != "exit"
|
12
|
+
puts ""
|
13
|
+
puts 'Please enter "all" to see a list of all events,'
|
14
|
+
puts '"dates" to see a list of dates available,'
|
15
|
+
puts '"genres" to see a list of genres available, or "exit"'
|
16
|
+
puts ""
|
17
|
+
|
18
|
+
input = gets.strip.downcase
|
19
|
+
|
20
|
+
case input
|
21
|
+
when "all"
|
22
|
+
puts ""
|
23
|
+
puts "Enter the number of the event you would like to see,"
|
24
|
+
puts "or 0 to go back to menu"
|
25
|
+
display_all_event_names
|
26
|
+
puts ""
|
27
|
+
puts "Enter the number of the event you would like to see,"
|
28
|
+
puts "or 0 to go back to menu"
|
29
|
+
puts ""
|
30
|
+
all_input = gets.strip.to_i
|
31
|
+
|
32
|
+
if all_input > 0 && all_input <= QuarantineLiveStreams::Event.all.length
|
33
|
+
|
34
|
+
@current_event = QuarantineLiveStreams::Event.all[all_input - 1]
|
35
|
+
|
36
|
+
puts ""
|
37
|
+
puts "Live Stream: #{@current_event.name}"
|
38
|
+
puts "Genre: #{@current_event.genre}"
|
39
|
+
puts "Date: #{@current_event.date}"
|
40
|
+
puts "Time: #{@current_event.time} ET."
|
41
|
+
puts "Link: #{@current_event.link.colorize(:green)}"
|
42
|
+
puts ""
|
43
|
+
end
|
44
|
+
|
45
|
+
when "dates"
|
46
|
+
puts ""
|
47
|
+
display_all_dates #shows all dates
|
48
|
+
puts ""
|
49
|
+
puts "Please enter the number for the date to see events for that date,"
|
50
|
+
puts "or 0 to go back to main menu"
|
51
|
+
puts ""
|
52
|
+
date_input = gets.strip.to_i #gets what date we want from user
|
53
|
+
puts ""
|
54
|
+
|
55
|
+
|
56
|
+
current_date = @all_dates_array[date_input - 1]
|
57
|
+
|
58
|
+
QuarantineLiveStreams::Event.find_by_date(@all_dates_array.index(current_date)) #searching by string name
|
59
|
+
|
60
|
+
if date_input > 0 && date_input <= @all_dates_array.length
|
61
|
+
@events_by_date = QuarantineLiveStreams::Event.all.each_with_index do |event_obj, index|
|
62
|
+
if event_obj.date == current_date
|
63
|
+
puts "#{index + 1}. #{event_obj.name}"
|
64
|
+
event_obj
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
puts ""
|
69
|
+
puts "Please enter the number of the event you would like more info about,"
|
70
|
+
puts "or 0 to return to main menu"
|
71
|
+
puts ""
|
72
|
+
event_input = gets.strip.to_i
|
73
|
+
puts ""
|
74
|
+
|
75
|
+
|
76
|
+
if event_input > 0 && event_input <= QuarantineLiveStreams::Event.all.length
|
77
|
+
@current_event = QuarantineLiveStreams::Event.all[event_input - 1]
|
78
|
+
|
79
|
+
puts "Live Stream: #{@current_event.name}"
|
80
|
+
puts "Genre: #{@current_event.genre}"
|
81
|
+
puts "Date: #{@current_event.date}"
|
82
|
+
puts "Time: #{@current_event.time} ET."
|
83
|
+
puts "Link: #{@current_event.link.colorize(:green)}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
when "genres"
|
88
|
+
puts ""
|
89
|
+
|
90
|
+
display_all_genres
|
91
|
+
puts ""
|
92
|
+
puts "please enter the number of the genre you would like to see events for,"
|
93
|
+
puts "or 0 to go back to main menu"
|
94
|
+
puts ""
|
95
|
+
genre_input = gets.strip.to_i
|
96
|
+
puts ""
|
97
|
+
|
98
|
+
current_genre = @all_genres_array[genre_input - 1]
|
99
|
+
QuarantineLiveStreams::Event.find_by_genre(@all_genres_array.index(current_genre))
|
100
|
+
|
101
|
+
|
102
|
+
if genre_input > 0 && genre_input <= @all_genres_array.length
|
103
|
+
@events_by_genre = QuarantineLiveStreams::Event.all.each_with_index do |event_obj, index|
|
104
|
+
if event_obj.genre == current_genre
|
105
|
+
puts "#{index + 1}. #{event_obj.name}"
|
106
|
+
event_obj
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
puts ""
|
111
|
+
puts "Please enter the number of the event you would like more info about"
|
112
|
+
puts "or 0 to go back to main menu"
|
113
|
+
puts ""
|
114
|
+
event_input = gets.strip.to_i
|
115
|
+
puts ""
|
116
|
+
|
117
|
+
if event_input > 0 && event_input <= QuarantineLiveStreams::Event.all.length
|
118
|
+
@current_event = QuarantineLiveStreams::Event.all[event_input - 1]
|
119
|
+
|
120
|
+
puts "Live Stream: #{@current_event.name}"
|
121
|
+
puts "Genre: #{@current_event.genre}"
|
122
|
+
puts "Date: #{@current_event.date}"
|
123
|
+
puts "Time: #{@current_event.time} ET."
|
124
|
+
puts "Link: #{@current_event.link.colorize(:green)}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def make_events
|
132
|
+
QuarantineLiveStreams::Event.create_from_collection
|
133
|
+
end
|
134
|
+
|
135
|
+
def display_all_event_names
|
136
|
+
QuarantineLiveStreams::Event.all.each_with_index do |event_obj, index|
|
137
|
+
puts "#{index + 1}. #{event_obj.name}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def display_all_dates
|
142
|
+
@all_dates_array = QuarantineLiveStreams::Event.all.map do |event_obj|
|
143
|
+
event_obj.date
|
144
|
+
end
|
145
|
+
|
146
|
+
@all_dates_array = @all_dates_array.uniq
|
147
|
+
@all_dates_array.each_with_index do |date, index|
|
148
|
+
puts "#{index + 1}. #{date}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def display_all_genres
|
153
|
+
@all_genres_array = QuarantineLiveStreams::Event.all.map do |event_obj|
|
154
|
+
event_obj.genre
|
155
|
+
end
|
156
|
+
|
157
|
+
@all_genres_array = @all_genres_array.uniq
|
158
|
+
@all_genres_array.each_with_index do |genre, index|
|
159
|
+
puts "#{index + 1}. #{genre}"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def welcome
|
164
|
+
puts ""
|
165
|
+
puts "|******************************|".colorize(:light_blue)
|
166
|
+
puts "| WELCOME TO: |".colorize(:light_blue)
|
167
|
+
puts "| |".colorize(:light_blue)
|
168
|
+
puts "| ╭━━┳╮╭━━╮ |".colorize(:light_blue)
|
169
|
+
puts "| ┃╭╮┃┃┃━━┫ |".colorize(:light_blue)
|
170
|
+
puts "| ┃╰╯┃╰╋━━┃ |".colorize(:light_blue)
|
171
|
+
puts "| ╰━╮┣━┻━━╯ |".colorize(:light_blue)
|
172
|
+
puts "| ╱╱╰╯ |".colorize(:light_blue)
|
173
|
+
puts "| |".colorize(:light_blue)
|
174
|
+
puts "| Quarantine Live Streams |".colorize(:light_blue)
|
175
|
+
puts "|******************************|".colorize(:light_blue)
|
176
|
+
puts ""
|
177
|
+
end
|
178
|
+
|
179
|
+
def goodbye
|
180
|
+
puts ""
|
181
|
+
puts "|******************************|".colorize(:light_blue)
|
182
|
+
puts "| Quarantine Live Streams |".colorize(:light_blue)
|
183
|
+
puts "| |".colorize(:light_blue)
|
184
|
+
puts "| ╭━━┳╮╭━━╮ |".colorize(:light_blue)
|
185
|
+
puts "| ┃╭╮┃┃┃━━┫ |".colorize(:light_blue)
|
186
|
+
puts "| ┃╰╯┃╰╋━━┃ |".colorize(:light_blue)
|
187
|
+
puts "| ╰━╮┣━┻━━╯ |".colorize(:light_blue)
|
188
|
+
puts "| ╱╱╰╯ |".colorize(:light_blue)
|
189
|
+
puts "| |".colorize(:light_blue)
|
190
|
+
puts "| Thanks for listening |".colorize(:light_blue)
|
191
|
+
puts "|******************************|".colorize(:light_blue)
|
192
|
+
puts ""
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class QuarantineLiveStreams::Event
|
2
|
+
attr_accessor :date, :genre, :name, :time, :link
|
3
|
+
|
4
|
+
@@all = []
|
5
|
+
@events_by_genre = []
|
6
|
+
|
7
|
+
def initialize(event_hash)
|
8
|
+
@date = event_hash[:date]
|
9
|
+
@genre = event_hash[:genre]
|
10
|
+
@name = event_hash[:name]
|
11
|
+
@time = event_hash[:time]
|
12
|
+
@link = event_hash[:link]
|
13
|
+
@@all << self
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create_from_collection(events_array = QuarantineLiveStreams::Scraper.scrape_site)
|
17
|
+
events_array.each do |event_hash|
|
18
|
+
self.new(event_hash)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.all
|
23
|
+
@@all
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.find_by_genre(genre)
|
27
|
+
@events_by_genre = []
|
28
|
+
QuarantineLiveStreams::Event.all.each do |event_obj|
|
29
|
+
if event_obj.genre == genre
|
30
|
+
@events_by_genre << event_obj
|
31
|
+
end
|
32
|
+
end
|
33
|
+
@events_by_genre.each_with_index do |event_obj, index|
|
34
|
+
puts "#{index + 1}. #{event_obj.name}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.find_by_date(date)
|
39
|
+
@events_by_date = []
|
40
|
+
QuarantineLiveStreams::Event.all.each do |event_obj|
|
41
|
+
if event_obj.date == date
|
42
|
+
@events_by_date << event_obj
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@events_by_date.each_with_index do |event_obj, index|
|
46
|
+
puts "#{index + 1}. #{event_obj.name}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class QuarantineLiveStreams::Scraper
|
2
|
+
@events_array = []
|
3
|
+
|
4
|
+
def self.scrape_site
|
5
|
+
url = "https://www.npr.org/2020/03/17/816504058/a-list-of-live-virtual-concerts-to-watch-during-the-coronavirus-shutdown"
|
6
|
+
doc = Nokogiri::HTML(open(url))
|
7
|
+
content = doc.css(".storytext")
|
8
|
+
found = false
|
9
|
+
date = "test"
|
10
|
+
genre = "test"
|
11
|
+
content.children.each do |el|
|
12
|
+
if (el.name == 'h3')
|
13
|
+
found = true
|
14
|
+
end
|
15
|
+
if ((el.name == 'h3' || el.name == 'p' || el.name == 'h6') && found)
|
16
|
+
found = true
|
17
|
+
case el.name
|
18
|
+
when 'h3'
|
19
|
+
date = el.text
|
20
|
+
when 'h6'
|
21
|
+
genre = el.text
|
22
|
+
when 'p'
|
23
|
+
event_hash = {}
|
24
|
+
event_hash[:date] = date
|
25
|
+
event_hash[:genre] = genre.downcase
|
26
|
+
event_hash[:name] = el.css('strong').text
|
27
|
+
time = el.text.gsub(/.*?(?=Time)/im, "")
|
28
|
+
event_hash[:time] = time = time.slice(0..(time.index('. ETL')))
|
29
|
+
if event_hash[:link] = el.css('a').attr('href')
|
30
|
+
event_hash[:link] = el.css('a').attr('href').value
|
31
|
+
end
|
32
|
+
@events_array << event_hash
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
@events_array
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: QuarantineLiveStreams
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mattenbar
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-04-29 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: uri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: colorize
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.1
|
97
|
+
description: Scrapes upcoming events that are being live streamed and then returns
|
98
|
+
the date time and link ot the event
|
99
|
+
email:
|
100
|
+
- matthew.enbar@gmail.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".DS_Store"
|
106
|
+
- ".gitignore"
|
107
|
+
- CODE_OF_CONDUCT.md
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- NOTES.md
|
111
|
+
- QuarantineLiveStreams.gemspec
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/QLS
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- lib/.DS_Store
|
118
|
+
- lib/QuarantineLiveStreams.rb
|
119
|
+
- lib/QuarantineLiveStreams/cli.rb
|
120
|
+
- lib/QuarantineLiveStreams/event.rb
|
121
|
+
- lib/QuarantineLiveStreams/scraper.rb
|
122
|
+
- lib/QuarantineLiveStreams/version.rb
|
123
|
+
homepage: https://github.com/mattenbar/QLS
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata:
|
127
|
+
homepage_uri: https://github.com/mattenbar/QLS
|
128
|
+
source_code_uri: https://github.com/mattenbar/QLS
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.3.0
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubygems_version: 3.1.2
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: CLI scraper for quarantine live streams
|
148
|
+
test_files: []
|