ahl_scraper 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +85 -0
- data/.ruby-version +1 -0
- data/.solargraph.yml +15 -0
- data/.travis.yml +6 -0
- data/.vscode/settings.json +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +114 -0
- data/LICENSE.txt +21 -0
- data/README.md +235 -0
- data/Rakefile +8 -0
- data/ahl_scraper.gemspec +27 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/lib/ahl_scraper.rb +55 -0
- data/lib/ahl_scraper/fetchers/division_data_fetcher.rb +19 -0
- data/lib/ahl_scraper/fetchers/game_data_fetcher.rb +29 -0
- data/lib/ahl_scraper/fetchers/game_event_data_fetcher.rb +19 -0
- data/lib/ahl_scraper/fetchers/player_data_fetcher.rb +25 -0
- data/lib/ahl_scraper/fetchers/player_games/data_fetcher.rb +30 -0
- data/lib/ahl_scraper/fetchers/playoff_bracket_data_fetcher.rb +19 -0
- data/lib/ahl_scraper/fetchers/season_data_fetcher.rb +15 -0
- data/lib/ahl_scraper/fetchers/season_end_date_fetcher.rb +34 -0
- data/lib/ahl_scraper/fetchers/season_game_ids_fetcher.rb +21 -0
- data/lib/ahl_scraper/fetchers/season_start_date_fetcher.rb +30 -0
- data/lib/ahl_scraper/fetchers/season_type_fetcher.rb +33 -0
- data/lib/ahl_scraper/fetchers/team_data_fetcher.rb +19 -0
- data/lib/ahl_scraper/fetchers/team_games/data_fetcher.rb +22 -0
- data/lib/ahl_scraper/fetchers/team_roster_data_fetcher.rb +67 -0
- data/lib/ahl_scraper/fixed_games/1001050.json +2182 -0
- data/lib/ahl_scraper/fixed_games/1018774.json +2573 -0
- data/lib/ahl_scraper/fixed_games/1020527.json +2483 -0
- data/lib/ahl_scraper/games.rb +46 -0
- data/lib/ahl_scraper/games/events.rb +8 -0
- data/lib/ahl_scraper/helpers/birthdate_helper.rb +27 -0
- data/lib/ahl_scraper/helpers/elapsed_time_helper.rb +24 -0
- data/lib/ahl_scraper/helpers/ice_time_helper.rb +18 -0
- data/lib/ahl_scraper/helpers/parameterize_helper.rb +35 -0
- data/lib/ahl_scraper/helpers/period_time_helper.rb +25 -0
- data/lib/ahl_scraper/helpers/season_dates_helper.rb +14 -0
- data/lib/ahl_scraper/player_games.rb +19 -0
- data/lib/ahl_scraper/players.rb +12 -0
- data/lib/ahl_scraper/playoff_brackets.rb +17 -0
- data/lib/ahl_scraper/resource.rb +38 -0
- data/lib/ahl_scraper/resources/game.rb +373 -0
- data/lib/ahl_scraper/resources/game_list_item.rb +57 -0
- data/lib/ahl_scraper/resources/games/coach.rb +23 -0
- data/lib/ahl_scraper/resources/games/events/shot.rb +10 -0
- data/lib/ahl_scraper/resources/games/goal.rb +161 -0
- data/lib/ahl_scraper/resources/games/goalie.rb +106 -0
- data/lib/ahl_scraper/resources/games/info.rb +83 -0
- data/lib/ahl_scraper/resources/games/on_ice_skater.rb +35 -0
- data/lib/ahl_scraper/resources/games/overtime.rb +48 -0
- data/lib/ahl_scraper/resources/games/penalty.rb +101 -0
- data/lib/ahl_scraper/resources/games/penalty_shot.rb +82 -0
- data/lib/ahl_scraper/resources/games/period.rb +31 -0
- data/lib/ahl_scraper/resources/games/referee.rb +23 -0
- data/lib/ahl_scraper/resources/games/shootout_attempt.rb +61 -0
- data/lib/ahl_scraper/resources/games/skater.rb +94 -0
- data/lib/ahl_scraper/resources/games/star.rb +47 -0
- data/lib/ahl_scraper/resources/games/team.rb +85 -0
- data/lib/ahl_scraper/resources/goalie_game_list_item.rb +69 -0
- data/lib/ahl_scraper/resources/player.rb +71 -0
- data/lib/ahl_scraper/resources/playoff_bracket.rb +21 -0
- data/lib/ahl_scraper/resources/playoff_brackets/game.rb +43 -0
- data/lib/ahl_scraper/resources/playoff_brackets/round.rb +31 -0
- data/lib/ahl_scraper/resources/playoff_brackets/series.rb +73 -0
- data/lib/ahl_scraper/resources/playoff_brackets/team.rb +39 -0
- data/lib/ahl_scraper/resources/roster_player.rb +71 -0
- data/lib/ahl_scraper/resources/season.rb +93 -0
- data/lib/ahl_scraper/resources/season_list_item.rb +30 -0
- data/lib/ahl_scraper/resources/seasons/team.rb +77 -0
- data/lib/ahl_scraper/resources/skater_game_list_item.rb +65 -0
- data/lib/ahl_scraper/resources/team_game_list_item.rb +64 -0
- data/lib/ahl_scraper/resources/team_list_item.rb +20 -0
- data/lib/ahl_scraper/roster_players.rb +11 -0
- data/lib/ahl_scraper/seasons.rb +31 -0
- data/lib/ahl_scraper/services/games/create_skaters_service.rb +72 -0
- data/lib/ahl_scraper/services/games/on_ice_statlines_service.rb +117 -0
- data/lib/ahl_scraper/services/games/penalty_shot_statlines_service.rb +38 -0
- data/lib/ahl_scraper/services/games/penalty_shots_service.rb +30 -0
- data/lib/ahl_scraper/services/games/penalty_statlines_service.rb +62 -0
- data/lib/ahl_scraper/services/games/scoring_statlines_service.rb +115 -0
- data/lib/ahl_scraper/services/games/shootout_statlines_service.rb +42 -0
- data/lib/ahl_scraper/services/games/team_on_ice_goals_service.rb +152 -0
- data/lib/ahl_scraper/services/games/time_splits_service.rb +70 -0
- data/lib/ahl_scraper/services/seasons/teams_service.rb +20 -0
- data/lib/ahl_scraper/team_games.rb +17 -0
- data/lib/ahl_scraper/teams.rb +11 -0
- data/lib/ahl_scraper/version.rb +5 -0
- metadata +138 -0
data/Rakefile
ADDED
data/ahl_scraper.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/ahl_scraper/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ahl_scraper"
|
7
|
+
spec.version = AhlScraper::VERSION
|
8
|
+
spec.authors = ["jefftcraig"]
|
9
|
+
spec.email = ["jeffcraig35@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Scrape data from the AHL website"
|
12
|
+
spec.description = "Allows users to gather game, season, and player data from the AHL website"
|
13
|
+
spec.homepage = "http://www.ahltracker.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = "https://github.com/notnotjeff/ahl_scraper"
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/notnotjeff/ahl_scraper"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/notnotjeff/ahl_scraper"
|
20
|
+
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# !/usr/bin/env ruby
|
4
|
+
|
5
|
+
require "bundler/setup"
|
6
|
+
require "ahl_scraper"
|
7
|
+
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
10
|
+
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
12
|
+
# require "pry"
|
13
|
+
# Pry.start
|
14
|
+
|
15
|
+
require "irb"
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/ahl_scraper.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "nokogiri"
|
5
|
+
require "open-uri"
|
6
|
+
require "bigdecimal"
|
7
|
+
|
8
|
+
require "ahl_scraper/version"
|
9
|
+
|
10
|
+
require "ahl_scraper/fetchers/division_data_fetcher"
|
11
|
+
require "ahl_scraper/fetchers/game_data_fetcher"
|
12
|
+
require "ahl_scraper/fetchers/game_event_data_fetcher"
|
13
|
+
require "ahl_scraper/fetchers/player_data_fetcher"
|
14
|
+
require "ahl_scraper/fetchers/playoff_bracket_data_fetcher"
|
15
|
+
require "ahl_scraper/fetchers/season_data_fetcher"
|
16
|
+
require "ahl_scraper/fetchers/season_end_date_fetcher"
|
17
|
+
require "ahl_scraper/fetchers/season_game_ids_fetcher"
|
18
|
+
require "ahl_scraper/fetchers/season_start_date_fetcher"
|
19
|
+
require "ahl_scraper/fetchers/season_type_fetcher"
|
20
|
+
require "ahl_scraper/fetchers/team_data_fetcher"
|
21
|
+
require "ahl_scraper/fetchers/team_roster_data_fetcher"
|
22
|
+
|
23
|
+
require "ahl_scraper/helpers/birthdate_helper"
|
24
|
+
require "ahl_scraper/helpers/elapsed_time_helper"
|
25
|
+
require "ahl_scraper/helpers/ice_time_helper"
|
26
|
+
require "ahl_scraper/helpers/parameterize_helper"
|
27
|
+
require "ahl_scraper/helpers/period_time_helper"
|
28
|
+
require "ahl_scraper/helpers/season_dates_helper"
|
29
|
+
|
30
|
+
require "ahl_scraper/resource"
|
31
|
+
|
32
|
+
require "ahl_scraper/resources/game"
|
33
|
+
require "ahl_scraper/resources/playoff_bracket"
|
34
|
+
require "ahl_scraper/resources/season"
|
35
|
+
require "ahl_scraper/resources/team_list_item"
|
36
|
+
require "ahl_scraper/resources/team_game_list_item"
|
37
|
+
require "ahl_scraper/resources/game_list_item"
|
38
|
+
require "ahl_scraper/resources/goalie_game_list_item"
|
39
|
+
require "ahl_scraper/resources/season_list_item"
|
40
|
+
require "ahl_scraper/resources/skater_game_list_item"
|
41
|
+
require "ahl_scraper/resources/roster_player"
|
42
|
+
require "ahl_scraper/resources/player"
|
43
|
+
|
44
|
+
require "ahl_scraper/games"
|
45
|
+
require "ahl_scraper/seasons"
|
46
|
+
require "ahl_scraper/team_games"
|
47
|
+
require "ahl_scraper/teams"
|
48
|
+
require "ahl_scraper/player_games"
|
49
|
+
require "ahl_scraper/players"
|
50
|
+
require "ahl_scraper/playoff_brackets"
|
51
|
+
require "ahl_scraper/roster_players"
|
52
|
+
|
53
|
+
module AhlScraper
|
54
|
+
class Error < StandardError; end
|
55
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class DivisionDataFetcher
|
5
|
+
def initialize(season_id)
|
6
|
+
@season_id = season_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)&.first&.dig(:sections)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=teams&groupTeamsBy=division&site_id=1&season=#{@season_id}&key=50c2cd9b5e18e390&client_code=ahl&league_id=4&callback=json" # rubocop:disable Layout/LineLength
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class GameDataFetcher
|
5
|
+
BROKEN_GAMES = [1_018_774, 1_001_050, 1_020_527].freeze
|
6
|
+
|
7
|
+
def initialize(game_id)
|
8
|
+
@game_id = game_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
return fixed_game if BROKEN_GAMES.include? @game_id
|
13
|
+
|
14
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def fixed_game
|
20
|
+
path = File.join(File.dirname(__FILE__), "../fixed_games/#{@game_id}.json")
|
21
|
+
file = File.read(path)
|
22
|
+
JSON.parse(file, symbolize_names: true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def url
|
26
|
+
"http://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=gameSummary&game_id=#{@game_id}&key=50c2cd9b5e18e390&site_id=1&client_code=ahl&lang=en&league_id=&callback=json" # rubocop:disable Layout/LineLength
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class GameEventDataFetcher
|
5
|
+
def initialize(game_id)
|
6
|
+
@game_id = game_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=gameCenterPlayByPlay&game_id=#{@game_id}&key=50c2cd9b5e18e390&client_code=ahl&lang=en&league_id=&callback=json" # rubocop:disable Layout/LineLength
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class PlayerDataFetcher
|
5
|
+
def initialize(player_id)
|
6
|
+
@player_id = player_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(player_data_without_bio, symbolize_names: true)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=player&player_id=#{@player_id}&season_id=&site_id=3&key=ccb91f29d6744675&client_code=ahl&league_id=&lang=en&statsType=standard&callback=json" # rubocop:disable Layout/LineLength
|
17
|
+
end
|
18
|
+
|
19
|
+
def player_data_without_bio
|
20
|
+
data = Nokogiri::HTML(URI.parse(url).open).text[5..-2]
|
21
|
+
bio = data[/\"bio"\:(.*?)\,\"teamName/m, 1]
|
22
|
+
data.gsub(bio, "\"\"")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
module PlayerGames
|
5
|
+
class DataFetcher
|
6
|
+
def initialize(player_id, season_id)
|
7
|
+
@player_id = player_id
|
8
|
+
@season_id = season_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
player_data = JSON.parse(player_data_without_bio, symbolize_names: true)
|
13
|
+
|
14
|
+
player_data&.dig(:gameByGame, 0, :sections, 0, :data)&.map { |data| { **data, position: player_data[:info][:position] } }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def url
|
20
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=player&player_id=#{@player_id}&season_id=#{@season_id}&site_id=3&key=ccb91f29d6744675&client_code=ahl&league_id=&lang=en&statsType=standard&callback=json" # rubocop:disable Layout/LineLength
|
21
|
+
end
|
22
|
+
|
23
|
+
def player_data_without_bio
|
24
|
+
data = Nokogiri::HTML(URI.parse(url).open).text[5..-2]
|
25
|
+
bio = data[/\"bio"\:(.*?)\,\"teamName/m, 1]
|
26
|
+
data.gsub(bio, "\"\"")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class PlayoffBracketDataFetcher
|
5
|
+
def initialize(season_id)
|
6
|
+
@season_id = season_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true).dig(:SiteKit, :Brackets)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=modulekit&view=brackets&fmt=json&season_id=#{@season_id}&key=ccb91f29d6744675&client_code=ahl&site_id=3&lang=en&league_id=&callback=json" # rubocop:disable Layout/LineLength
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class SeasonDataFetcher
|
5
|
+
def call
|
6
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)&.dig(:seasons)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def url
|
12
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=bootstrap&season=latest&pageName=schedule&key=50c2cd9b5e18e390&client_code=ahl&site_id=1&league_id=&league_code=&lang=en&callback=json" # rubocop:disable Layout/LineLength
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class SeasonEndDateFetcher
|
5
|
+
def initialize(season_id, season_type)
|
6
|
+
@season_id = season_id
|
7
|
+
@season_type = season_type
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
return if %i[all_star_game exhibition].include? @season_type
|
12
|
+
|
13
|
+
return SeasonDatesHelper::DATE_EXCEPTIONS[@season_id][:end_date] if SeasonDatesHelper::DATE_EXCEPTIONS.keys.include? @season_id
|
14
|
+
|
15
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
|
16
|
+
&.first
|
17
|
+
&.dig(:sections)
|
18
|
+
&.first
|
19
|
+
&.dig(:data)
|
20
|
+
&.last
|
21
|
+
&.dig(:row, :date_with_day)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def end_month
|
27
|
+
SeasonDatesHelper::SEASON_MONTH_KEY[@season_type.to_sym][:end_month]
|
28
|
+
end
|
29
|
+
|
30
|
+
def url
|
31
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=schedule&team=-1&season=#{@season_id}&month=#{@end_month}&location=homeaway&key=50c2cd9b5e18e390&client_code=ahl&site_id=1&league_id=4&division_id=-1&lang=en&callback=json"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class SeasonGameIdsFetcher
|
5
|
+
def initialize(season_id)
|
6
|
+
@season_id = season_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open)
|
11
|
+
.text[5..-2], symbolize_names: true)
|
12
|
+
.dig(0, :sections, 0, :data)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def url
|
18
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=schedule&team=-1&season=#{@season_id}&month=-1&location=homeaway&key=ccb91f29d6744675&client_code=ahl&site_id=3&league_id=4&division_id=-1&lang=en&callback=json"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class SeasonStartDateFetcher
|
5
|
+
def initialize(season_id, season_type)
|
6
|
+
@season_id = season_id
|
7
|
+
@season_type = season_type
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
return if %i[all_star_game exhibition].include? @season_type
|
12
|
+
|
13
|
+
return SeasonDatesHelper::DATE_EXCEPTIONS[@season_id][:start_date] if SeasonDatesHelper::DATE_EXCEPTIONS.keys.include? @season_id
|
14
|
+
|
15
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
|
16
|
+
&.first
|
17
|
+
&.dig(:sections)
|
18
|
+
&.first
|
19
|
+
&.dig(:data)
|
20
|
+
&.first
|
21
|
+
&.dig(:row, :date_with_day)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def url
|
27
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=schedule&team=-1&season=#{@season_id}&month=#{@start_month}&location=homeaway&key=50c2cd9b5e18e390&client_code=ahl&site_id=1&callback=json"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class SeasonTypeFetcher
|
5
|
+
def initialize(season_id)
|
6
|
+
@season_id = season_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
season = JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)
|
11
|
+
.dig(:seasons)
|
12
|
+
&.find { |s| s[:id].to_i == @season_id.to_i }
|
13
|
+
return nil unless season
|
14
|
+
|
15
|
+
case season[:name]
|
16
|
+
when /Regular/
|
17
|
+
:regular
|
18
|
+
when /All-Star/
|
19
|
+
:all_star
|
20
|
+
when /Playoffs/
|
21
|
+
:playoffs
|
22
|
+
when /Exhibition/
|
23
|
+
:exhibition
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def url
|
30
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=bootstrap&season=latest&pageName=schedule&key=50c2cd9b5e18e390&client_code=ahl&site_id=1&league_id=&league_code=&lang=en&callback=json"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
class TeamDataFetcher
|
5
|
+
def initialize(season_id)
|
6
|
+
@season_id = season_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)&.first&.dig(:sections)&.map { |t| t[:data] }&.flatten
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def url
|
16
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=teams&groupTeamsBy=division&site_id=1&season=#{@season_id}&key=50c2cd9b5e18e390&client_code=ahl&league_id=4&callback=json" # rubocop:disable Layout/LineLength
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AhlScraper
|
4
|
+
module TeamGames
|
5
|
+
class DataFetcher
|
6
|
+
def initialize(team_id, season_id)
|
7
|
+
@team_id = team_id
|
8
|
+
@season_id = season_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
JSON.parse(Nokogiri::HTML(URI.parse(url).open).text[5..-2], symbolize_names: true)&.dig(0, :sections, 0, :data)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def url
|
18
|
+
"https://lscluster.hockeytech.com/feed/index.php?feed=statviewfeed&view=schedule&team=#{@team_id}&season=#{@season_id}&month=-1&location=homeaway&key=ccb91f29d6744675&client_code=ahl&site_id=3&league_id=4&division_id=-1&lang=en&callback=json" # rubocop:disable Layout/LineLength
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|