prls 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
+ SHA256:
3
+ metadata.gz: dac27d3d2d24e5b6eaf0a6b503e7c3d0877846b7ce582f918ac0c19d96fced75
4
+ data.tar.gz: 48e7f0024dea898a8b026b69030cfcc98fe9995f33dbffe173074d452b7ba4c2
5
+ SHA512:
6
+ metadata.gz: a185f34c48cb0830a64b7cd0cfa812ef7897dd90215c3c930e3ce2be4cafa0bb960b9e95d149f2c09ed5a0dc29e01df2082cc63d39f5b107c8bf00e75c4332fa
7
+ data.tar.gz: 3ff0de42b39fddaeebc602b601f760722fd5e07489e8789ac4181f5944b98538984a123533928abe37403c766ed27bfb06c0fc2728dde2ceef74affb1bde0d2c
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/prls.rb'
4
+
5
+ PRLS::CLI.new.call
@@ -0,0 +1,19 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'word_wrap'
4
+ require 'word_wrap/core_ext'
5
+
6
+
7
+ require_relative "./prls/version"
8
+
9
+ require_relative "./prls/cli"
10
+ require_relative "./prls/pro"
11
+ require_relative "./prls/dps"
12
+ require_relative "./prls/concord"
13
+ require_relative "./prls/mti"
14
+ require_relative "./prls/playscripts"
15
+ require_relative "./prls/bpp"
16
+ require_relative "./prls/scraper"
17
+
18
+
19
+
@@ -0,0 +1,33 @@
1
+ class PRLS::CLI::BPP < PRLS::CLI::PRO
2
+
3
+ BPP_PLAYS = []
4
+
5
+ def initialize(attributes)
6
+ super
7
+ BPP_PLAYS << self
8
+ end
9
+
10
+ def self.all
11
+ BPP_PLAYS
12
+ end
13
+
14
+ def self.get_plays
15
+ if self.all.empty?
16
+ url = "https://www.broadwayplaypub.com/catalog/plays/newly-published/?paged=&count=90"
17
+ self.new_from_scrape(PRLS::CLI::Scraper.new.bpp_index(url))
18
+ end
19
+ end
20
+
21
+ def self.list_plays
22
+ puts ""
23
+ puts "Here are Broadway Play Publishing, Inc.'s featured plays:"
24
+ super
25
+ end
26
+
27
+ def self.get_details(index)
28
+ if self.all[index].need_attr?
29
+ self.all[index].add_attr(PRLS::CLI::Scraper.new.bpp_info(self.all[index].url))
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,74 @@
1
+ class PRLS::CLI
2
+
3
+ def call
4
+ header
5
+ menu
6
+ end
7
+
8
+ def header
9
+ puts ""
10
+ puts "PERFORMING RIGHTS LOOKUP SERVICE"
11
+ puts "--------------------------------"
12
+ end
13
+
14
+ def pros
15
+ puts ""
16
+ puts "Select a PRO to see their currently featured plays:"
17
+ puts ""
18
+ puts "1. Dramatist's Play Service, Inc."
19
+ puts "2. Concord Theatricals (formerly Samuel French, Ltd.)"
20
+ puts "3. Music Theatre International"
21
+ puts "4. Playscripts, Inc."
22
+ puts "5. Broadway Play Publishing, Inc."
23
+ puts ""
24
+ puts "To exit, type 'exit'."
25
+ puts ""
26
+ end
27
+
28
+ def menu
29
+ input = nil
30
+ while input != 'exit'
31
+ pros
32
+ input = gets.chomp.downcase
33
+ case input.to_s
34
+ when '1'
35
+ puts ""
36
+ puts "Loading..."
37
+ puts ""
38
+ DPS.get_plays
39
+ DPS.list_plays
40
+ when '2'
41
+ puts ""
42
+ puts "Loading..."
43
+ puts ""
44
+ CONCORD.get_plays
45
+ CONCORD.list_plays
46
+ when '3'
47
+ puts ""
48
+ puts "Loading..."
49
+ puts ""
50
+ MTI.get_plays
51
+ MTI.list_plays
52
+ when '4'
53
+ puts ""
54
+ puts "Loading..."
55
+ puts ""
56
+ PLAYSCRIPTS.get_plays
57
+ PLAYSCRIPTS.list_plays
58
+ when '5'
59
+ puts ""
60
+ puts "Loading..."
61
+ puts ""
62
+ BPP.get_plays
63
+ BPP.list_plays
64
+ when 'exit'
65
+ puts 'Exiting...'
66
+ else
67
+ puts 'Invalid entry. Please try again.'
68
+ puts ""
69
+ menu
70
+ end
71
+ end
72
+ end
73
+
74
+ end
@@ -0,0 +1,33 @@
1
+ class PRLS::CLI::CONCORD < PRLS::CLI::PRO
2
+
3
+ CONCORD_PLAYS = []
4
+
5
+ def initialize(attributes)
6
+ super
7
+ CONCORD_PLAYS << self
8
+ end
9
+
10
+ def self.all
11
+ CONCORD_PLAYS
12
+ end
13
+
14
+ def self.get_plays
15
+ if self.all.empty?
16
+ url = "https://www.concordtheatricals.com/perform/plays"
17
+ self.new_from_scrape(PRLS::CLI::Scraper.new.concord_index(url))
18
+ end
19
+ end
20
+
21
+ def self.list_plays
22
+ puts ""
23
+ puts "Here are Concord Theatrical's featured plays:"
24
+ super
25
+ end
26
+
27
+ def self.get_details(index)
28
+ if self.all[index].need_attr?
29
+ self.all[index].add_attr(PRLS::CLI::Scraper.new.concord_info(self.all[index].url))
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,32 @@
1
+ class PRLS::CLI::DPS < PRLS::CLI::PRO
2
+
3
+ DPS_PLAYS = []
4
+
5
+ def initialize(attributes)
6
+ super
7
+ DPS_PLAYS << self
8
+ end
9
+
10
+ def self.all
11
+ DPS_PLAYS
12
+ end
13
+
14
+ def self.get_plays
15
+ if self.all.empty?
16
+ url = "https://www.dramatists.com/dps/nowpublished.aspx"
17
+ self.new_from_scrape(PRLS::CLI::Scraper.new.dps_index(url))
18
+ end
19
+ end
20
+
21
+ def self.list_plays
22
+ puts ""
23
+ puts "Here are Dramatist's Play Service, Inc.'s featured plays:"
24
+ super
25
+ end
26
+
27
+ def self.get_details(index)
28
+ if self.all[index].need_attr?
29
+ self.all[index].add_attr(PRLS::CLI::Scraper.new.dps_info(self.all[index].url))
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,33 @@
1
+ class PRLS::CLI::MTI < PRLS::CLI::PRO
2
+
3
+ MTI_PLAYS = []
4
+
5
+ def initialize(attributes)
6
+ super
7
+ MTI_PLAYS << self
8
+ end
9
+
10
+ def self.all
11
+ MTI_PLAYS
12
+ end
13
+
14
+ def self.get_plays
15
+ if self.all.empty?
16
+ url = "https://www.mtishows.com/shows/all"
17
+ self.new_from_scrape(PRLS::CLI::Scraper.new.mti_index(url))
18
+ end
19
+ end
20
+
21
+ def self.list_plays
22
+ puts ""
23
+ puts "Here are Music Theatre International's featured plays:"
24
+ super
25
+ end
26
+
27
+ def self.get_details(index)
28
+ if self.all[index].need_attr?
29
+ self.all[index].add_attr(PRLS::CLI::Scraper.new.mti_info(self.all[index].url))
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,33 @@
1
+ class PRLS::CLI::PLAYSCRIPTS < PRLS::CLI::PRO
2
+
3
+ PLAYSCRIPTS_PLAYS = []
4
+
5
+ def initialize(attributes)
6
+ super
7
+ PLAYSCRIPTS_PLAYS << self
8
+ end
9
+
10
+ def self.all
11
+ PLAYSCRIPTS_PLAYS
12
+ end
13
+
14
+ def self.get_plays
15
+ if self.all.empty?
16
+ url = "https://www.playscripts.com/find-a-play?sort=recentpopularity"
17
+ self.new_from_scrape(PRLS::CLI::Scraper.new.playscripts_index(url))
18
+ end
19
+ end
20
+
21
+ def self.list_plays
22
+ puts ""
23
+ puts "Here are Playscripts, Inc.'s featured plays:"
24
+ super
25
+ end
26
+
27
+ def self.get_details(index)
28
+ if self.all[index].need_attr?
29
+ self.all[index].add_attr(PRLS::CLI::Scraper.new.playscripts_info(self.all[index].url))
30
+ end
31
+ end
32
+
33
+ end
@@ -0,0 +1,82 @@
1
+ class PRLS::CLI::PRO
2
+
3
+ attr_accessor :title, :author, :summary, :blurb, :url
4
+
5
+ def initialize(attributes)
6
+ attributes.each do |key, val|
7
+ self.send("#{key}=", val) if self.respond_to?("#{key}=")
8
+ end
9
+ end
10
+
11
+ def add_attr(hash)
12
+ hash.each do |key, val|
13
+ self.send("#{key}=", val) if self.respond_to?("#{key}=")
14
+ end
15
+ self
16
+ end
17
+
18
+ def need_attr?
19
+ if self.instance_variables.size < 5
20
+ true
21
+ end
22
+ end
23
+
24
+ def self.new_from_scrape(array)
25
+ array.each do |data|
26
+ self.new(data)
27
+ end
28
+ end
29
+
30
+ def self.list_plays
31
+ puts ""
32
+ index = 0
33
+ self.all.each do |play|
34
+ puts "#{index + 1}. #{play.title}"
35
+ index += 1
36
+ end
37
+ puts ""
38
+ puts "Which play would you like to learn more about?"
39
+ puts ""
40
+ choice = gets.chomp
41
+ while choice.to_i > self.all.size + 1
42
+ puts "Invalid entry, please try again."
43
+ choice = gets.chomp
44
+ end
45
+ self.get_details(choice.to_i - 1)
46
+ self.list_details(choice.to_i - 1)
47
+ choice = 0
48
+ end
49
+
50
+ def self.list_details(index)
51
+ puts ""
52
+ puts "TITLE"
53
+ puts ""
54
+ puts "#{self.all[index].title} by #{self.all[index].author}"
55
+ puts ""
56
+ puts "SUMMARY"
57
+ puts ""
58
+ if self.all[index].summary == nil || self.all[index].summary == ""
59
+ puts "No summary found."
60
+ else
61
+ puts self.all[index].summary.split.join(' ').wrap
62
+ end
63
+ puts ""
64
+ puts "REVIEWS"
65
+ puts ""
66
+ if self.all[index].blurb == nil || self.all[index].blurb == ""
67
+ puts "No reviews found."
68
+ else
69
+ puts self.all[index].blurb.split.join(' ').wrap
70
+ end
71
+ puts ""
72
+ puts "Learn more about #{self.all[index].title} here: #{self.all[index].url}"
73
+ puts ""
74
+ puts "Would you like to learn more about another play? Y/N"
75
+ input = gets.chomp
76
+ if input.downcase == 'y'
77
+ puts ""
78
+ self.list_plays
79
+ end
80
+ end
81
+
82
+ end
@@ -0,0 +1,154 @@
1
+ class PRLS::CLI::Scraper
2
+
3
+ attr_accessor :dps_plays, :dps_content,
4
+ :mti_plays, :mti_content,
5
+ :concord_plays, :concord_content,
6
+ :playscripts_plays, :playscripts_content,
7
+ :bpp_plays, :bpp_content
8
+
9
+
10
+ def dps_index(url)
11
+ dps_index = Nokogiri::HTML(open(url))
12
+ @dps_plays = []
13
+
14
+ dps_index.css('table td a').each do |play|
15
+ if play != nil
16
+ @dps_plays << {
17
+ :title => play.text,
18
+ :url => play.attribute('href').value
19
+ }
20
+ end
21
+ end
22
+ @dps_plays
23
+ end
24
+
25
+ def dps_info(url)
26
+ dps_info = Nokogiri::HTML(open(url))
27
+ @dps_content = {}
28
+
29
+ dps_info.css('#single').each do |content|
30
+ @dps_content = {
31
+ :author => content.css('#authorname').text,
32
+ :summary => content.css('#lexisynopsis').text,
33
+ :blurb => content.css('.lexishorttext').text
34
+ }
35
+ end
36
+ @dps_content
37
+ end
38
+
39
+ def concord_index(url)
40
+ concord_index = Nokogiri::HTML(open(url))
41
+ @concord_plays = []
42
+ concord_index.css('.card__item--text').each do |play|
43
+ @concord_plays << {
44
+ :title => play.css('a').text,
45
+ :url => "https://www.concordtheatricals.com#{play.css('a').attribute('href').value}"
46
+ }
47
+ end
48
+ @concord_plays
49
+ end
50
+
51
+ def concord_info(url)
52
+ concord_info = Nokogiri::HTML(open(url))
53
+ @concord_content = {
54
+ :author => concord_info.css('.type-large-credits').css('a').text,
55
+ :summary => concord_info.css('.pdp-section .type-regular').css('.longer-content').text,
56
+ :blurb => []
57
+ }
58
+ concord_info.css('type-regular').css('.pdp-sub-section').each do |review|
59
+ @concord_content[:blurb] << review.text
60
+ end
61
+ @concord_content[:blurb] = @concord_content[:blurb].join(' ')
62
+ @concord_content
63
+ end
64
+
65
+ def mti_index(url)
66
+ mti_index = Nokogiri::HTML(open(url))
67
+ @mti_plays = []
68
+
69
+ mti_index.css('.alphabetical-item').each do |play|
70
+ @mti_plays << {
71
+ :title => play.css('span').text,
72
+ :url => play.css('a').attribute('href').value
73
+ }
74
+ end
75
+ @mti_plays
76
+ end
77
+
78
+ def mti_info(url)
79
+ mti_data = Nokogiri::HTML(open(url))
80
+ @mti_content = {}
81
+
82
+ mti_data.css('.group-content-main').each do |content|
83
+ @mti_content = {
84
+ :author => [],
85
+ :summary => content.css('.show__summary').text,
86
+ :blurb => content.css('.show__brief').text
87
+ }
88
+ end
89
+
90
+ mti_data.css('.show__attributions .attribution__author-name').each do |author|
91
+ @mti_content[:author] << author.text
92
+ end
93
+
94
+ @mti_content[:author] = @mti_content[:author].uniq.join(', ')
95
+
96
+ @mti_content
97
+ end
98
+
99
+ def playscripts_index(url)
100
+ playscripts_index = Nokogiri::HTML(open(url))
101
+ @playscripts_plays = []
102
+ playscripts_index.css('.theater-story').each do |play|
103
+ @playscripts_plays << {
104
+ :title => play.css('.infos').css('.text').text,
105
+ :url => "https://www.playscripts.com#{play.css('.infos').css('a').attribute('href').value}"
106
+ }
107
+ end
108
+ @playscripts_plays
109
+ end
110
+
111
+ def playscripts_info(url)
112
+ playscripts_info = Nokogiri::HTML(open(url))
113
+ @playscripts_content = {
114
+ :summary => playscripts_info.css('.infos').css('.story-description').text.split.join(' ').chomp(' Read More'),
115
+ :author => playscripts_info.css('.infos').css('.playauthors').css('a').text,
116
+ }
117
+ blurb_check = playscripts_info.css('.script-more-info').css('.content').css('.p-review').first
118
+ if blurb_check != nil
119
+ @playscripts_content[:blurb] = blurb_check.text.split.join(' ')
120
+ end
121
+ @playscripts_content
122
+ end
123
+
124
+ def bpp_index(url)
125
+ bpp_index = Nokogiri::HTML(open(url))
126
+ @bpp_plays = []
127
+ bpp_index.css('.product-details').each do |play|
128
+ @bpp_plays << {
129
+ :title => play.css('a').text.chomp(' [read more]'),
130
+ :url => play.css('a').attribute('href').value
131
+ }
132
+ end
133
+ @bpp_plays
134
+ end
135
+
136
+ def bpp_info(url)
137
+ bpp_data = Nokogiri::HTML(open(url))
138
+ play = bpp_data.css('.product-essential')
139
+ @bpp_content = {:author => play.css('.authorbilling').text, :blurb => []}
140
+ if play.css('.description p').first != nil
141
+ @bpp_content[:summary] = play.css('.description p').first.text
142
+ end
143
+ play.css('#tab-reviews p').each do |review|
144
+ if review != nil
145
+ @bpp_content[:blurb] << review.text
146
+ end
147
+ end
148
+ @bpp_content[:blurb] = @bpp_content[:blurb].join(' ')
149
+ @bpp_content
150
+ end
151
+
152
+ end
153
+
154
+
@@ -0,0 +1,3 @@
1
+ module PRLS
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prls
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Justin McLawhorn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - jwmclawhorn@gmail.com
16
+ executables:
17
+ - prls
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/prls
22
+ - lib/prls.rb
23
+ - lib/prls/bpp.rb
24
+ - lib/prls/cli.rb
25
+ - lib/prls/concord.rb
26
+ - lib/prls/dps.rb
27
+ - lib/prls/mti.rb
28
+ - lib/prls/playscripts.rb
29
+ - lib/prls/pro.rb
30
+ - lib/prls/scraper.rb
31
+ - lib/prls/version.rb
32
+ homepage: https://github.com/justinmcla/prls
33
+ licenses:
34
+ - MIT
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.3.0
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubygems_version: 3.1.4
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: Fetches featured plays from Performance Rights Organizations (PROs).
55
+ test_files: []