diff --git a/Parse-NBA.ps1 b/Parse-NBA.ps1 deleted file mode 100755 index 35aed93..0000000 --- a/Parse-NBA.ps1 +++ /dev/null @@ -1,121 +0,0 @@ -Param( - #[Parameter(Mandatory = $true)] - [datetime]$StartDate = "2015-11-20", - [datetime]$EndDate = (Get-Date).AddDays(-1).Date -) - -#Get all the teams in the league according to thesportsdb -$thesportsdbTeams = @{} - -# Set up web session -$websession = new-object Microsoft.PowerShell.Commands.WebRequestSession -$websession.Headers.Add("Referer","http://stats.nba.com/scores") - -$teamUrl = "http://www.thesportsdb.com/api/v1/json/8123456712556/lookup_all_teams.php?id=4387" -$teams = (Invoke-WebRequest $teamUrl -WebSession $websession | ConvertFrom-Json).teams - - - -#Make a hash table that we can use here to map the results of our original search to thesportsdb values -foreach ( $team in $teams ) { - try { - $thesportsdbTeams.Add( $team.strTeamShort, $team ) - } catch { - Write-Error "No short team name for $($team.strTeam)" - } -} - -#Work out all the dates that we need to query for -$dates = @($StartDate.Date) -while ( $StartDate -ne $EndDate -and $EndDate ) { - $StartDate = $StartDate.AddDays(1) - $dates += $StartDate.Date -} - -$events = @() -$LeagueID = '00' - -#Get all the events that happened on this day for league 00 -foreach ( $date in $dates) { - $properDate = "$($date.Year)-$($date.Month.ToString("00"))-$($date.Day.ToString("00"))" - $schedUrl = "http://stats.nba.com/stats/scoreboard/?GameDate=$properDate&LeagueID=$LeagueID&DayOffset=0" - $output = ((Invoke-WebRequest $schedUrl -WebSession $websession).Content | ConvertFrom-Json).resultSets - $games = ($output | where { $_.Name -eq 'GameHeader'}).rowSet - $scores = ($output | where { $_.Name -eq 'LineScore'}).rowSet - if ( !($games -and $scores) ) { - continue - } - - foreach ($game in $games) { - #Create an object for this event - $homeTeamShort = $scores | where { $_[3] -eq $game[6]} | %{ $_[4] } - $awayTeamShort = $scores | where { $_[3] -eq $game[7]} | %{ $_[4] } - $homeTeam = $scores | where { $_[3] -eq $game[6]} | %{ $thesportsdbTeams.($_[4]).strTeam } - #if ( !$homeTeam ) { - # Write-Host "No name for $homeTeamShort" - #} - $awayTeam = $scores | where { $_[3] -eq $game[7]} | %{ $thesportsdbTeams.($_[4]).strTeam } - #if ( !$awayTeam ) { - # Write-Host "No name for $awayTeamShort" - #} - $homeScore = $scores | where { $_[3] -eq $game[6]} | %{ $_[21] } - $awayScore = $scores | where { $_[3] -eq $game[7]} | %{ $_[21] } - $events += New-Object -TypeName psobject -Property @{ - idEvent = $null - idSoccerXML = $null - strEvent = "$homeTeam vs $awayTeam" - strFilename = "NBA $properDate $homeTeam vs $awayTeam" - strSport = "Basketball" - idLeague = "4387" - strLeague = "NBA" - strSeason = "1516" - strDescriptionEN = $null - strHomeTeam = "$homeTeam" - strAwayTeam = "$awayTeam" - intHomeScore = "$homeScore" - intRound = "0" - intAwayScore = "$awayScore" - intSpectators = $null - strHomeGoalDetails = $null - strHomeRedCards = $null - strHomeYellowCards = $null - strHomeLineupGoalkeeper = $null - strHomeLineupDefense = $null - strHomeLineupMidfield = $null - strHomeLineupForward = $null - strHomeLineupSubstitutes = $null - strHomeFormation = $null - strAwayRedCards = $null - strAwayYellowCards = $null - strAwayGoalDetails = $null - strAwayLineupGoalkeeper = $null - strAwayLineupDefense = $null - strAwayLineupMidfield = $null - strAwayLineupForward = $null - strAwayLineupSubstitutes = $null - strAwayFormation = $null - intHomeShots = $null - intAwayShots = $null - dateEvent = "$properDate" - strDate = $null - strTime = $null - strTVStation = $null - idHomeTeam = $($thesportsdbTeams.($homeTeamShort).idTeam) - idAwayTeam = $($thesportsdbTeams.($awayTeamShort).idTeam) - strResult = $null - strRaceCircuit = $null - strRaceCountry = $null - strRaceLocality = $null - strPoster = $null - strFanart = $null - strThumb = $null - strBanner = $null - strMap = $null - strLocked = "unlocked" - } - } -} - -$events | ConvertTo-Csv -NoTypeInformation | out-file -Encoding ascii -FilePath "C:\temp\NBAresults.csv" -Force - - diff --git a/Parse-NHL.ps1 b/Parse-NHL.ps1 deleted file mode 100755 index 891e859..0000000 --- a/Parse-NHL.ps1 +++ /dev/null @@ -1,99 +0,0 @@ -[CmdletBinding()] -param ( - #[Parameter(Mandatory = $true)] - [datetime] - $StartDate = "2015-10-10", - - [datetime] - $EndDate = (Get-Date).AddDays(-1).Date -) - -#Get all the teams in the league according to thesportsdb -$thesportsdbTeams = @{} - -$teamUrl = "http://www.thesportsdb.com/api/v1/json/8123456712556/lookup_all_teams.php?id=4380" -$teams = (Invoke-RestMethod $teamUrl).teams - -#Make a hash table that we can use here to map the results of our original search to thesportsdb values -foreach ( $team in $teams ) { - try { - $thesportsdbTeams.Add($team.strTeam, $team) - } catch { - Write-Error "No short team name for $($team.strTeam)" - } -} - -$events = @() -$totalGames = 0 - -# Get all games through this time period -$startDateStr = "$($StartDate.Year)-$($StartDate.Month.ToString("00"))-$($StartDate.Day.ToString("00"))" -$endDateStr = "$($EndDate.Year)-$($EndDate.Month.ToString("00"))-$($EndDate.Day.ToString("00"))" -$schedurl = "https://statsapi.web.nhl.com/api/v1/schedule?startDate=$startDateStr&endDate=$endDateStr" -$dates = (Invoke-RestMethod $schedUrl).dates - -#Get all the events that happened on this day -foreach ($date in $dates) { - foreach ($game in $date.games) { - $homeTeamLong = ($game.teams.home.team.name -replace 'é', 'e') - $awayTeamLong = ($game.teams.away.team.name -replace 'é', 'e') - #Create an object for this event - $events += New-Object -TypeName psobject -Property @{ - idEvent = $null - idSoccerXML = $null - strEvent = "$homeTeamLong vs $awayTeamLong" - strFilename = "NHL $($date.date) $homeTeamLong vs $awayTeamLong" - strSport = "Ice Hockey" - idLeague = "4380" - strLeague = "NHL" - strSeason = "1718" - strDescriptionEN = $null - strHomeTeam = $homeTeamLong - strAwayTeam = $awayTeamLong - intHomeScore = "$($game.teams.home.score)" - intRound = "0" - intAwayScore = "$($game.teams.away.score)" - intSpectators = $null - strHomeGoalDetails = $null - strHomeRedCards = $null - strHomeYellowCards = $null - strHomeLineupGoalkeeper = $null - strHomeLineupDefense = $null - strHomeLineupMidfield = $null - strHomeLineupForward = $null - strHomeLineupSubstitutes = $null - strHomeFormation = $null - strAwayRedCards = $null - strAwayYellowCards = $null - strAwayGoalDetails = $null - strAwayLineupGoalkeeper = $null - strAwayLineupDefense = $null - strAwayLineupMidfield = $null - strAwayLineupForward = $null - strAwayLineupSubstitutes = $null - strAwayFormation = $null - intHomeShots = $null - intAwayShots = $null - dateEvent = "$($date.date)" - strDate = $null - strTime = $null - strTVStation = $null - idHomeTeam = $($thesportsdbTeams.($game.teams.home.team.name -replace 'é', 'e').idTeam) - idAwayTeam = $($thesportsdbTeams.($game.teams.away.team.name -replace 'é', 'e').idTeam) - strResult = $null - strRaceCircuit = $null - strRaceCountry = $null - strRaceLocality = $null - strPoster = $null - strFanart = $null - strThumb = $null - strBanner = $null - strMap = $null - strLocked = "unlocked" - } - } -} - -$events | ConvertTo-Csv -NoTypeInformation | out-file -Encoding ascii -FilePath "C:\temp\NHLresults.csv" -Force - - diff --git a/README.md b/README.md index c3c2cb6..f8589b4 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,18 @@ [![Join the chat at https://gitter.im/mmmmmtasty/SportScanner](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mmmmmtasty/SportScanner?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -# This project is no longer actively maintained. Please submit PRs and I will review but support is patchy at best! Thanks for watching! +# Status Update + +I am intending to make some improvements to this scanner and metadata agent. Please feel free to raise issues with requests. Support may still be patchy ;) + +Whish list: + - Shell script for fast unraid testing + - Consider writing tests to enable more refactoring/expansion without breaking existing functionality + - Consider new thesportsdb.com APIs to see if they add value + - Consider support for multi-part events, double headers and cup competitions + - Investigate alternatives or improvements to season setup + +------------- Scanner and Metadata Agent for Plex that uses www.thesportsdb.com