J-Wass / RLEB

https://www.reddit.com/r/RocketLeagueEsports
2 stars 0 forks source link

!streams #121

Closed J-Wass closed 2 years ago

J-Wass commented 2 years ago

js prototyping code

broadcast_tables = document.querySelectorAll("h4 ~ div > table.sortable.wikitable.jquery-tablesorter")
markdown = "|||||\n|:-|:-|:-|:-|"
pairs = []
for (table of broadcast_tables){
  rows = table.querySelectorAll('tbody')[0].querySelectorAll("tr")
  teams = rows[0].querySelectorAll("td")
  streams = rows[1].querySelectorAll("td")

  new_row = ""
  for (i = 0; i < teams.length; i++){
    teamname = teams[i].querySelectorAll("a")[0].title
    stream_name = "https://liquipedia.net/rocketleague/Rocket_League_Championship_Series/2021-22/Spring/Europe/1"
    if (i < streams.length){
      stream_name = streams[i].querySelectorAll("a")[0].title
      if (stream_name.includes("Special:Stream/twitch/")){
          split =  stream_name.split("/")
          stream_name = "https://www.twitch.tv/" + split[split.length-1]
      }
    }
    pairs.push([teamname, stream_name])

  }
  // create markdown, 4 teams per row

  while (pairs.length > 0){
      new_row = ""
      four_teams = pairs.slice(0,4)
      pairs = pairs.slice(4)

      console.log(four_teams)
      for (team of four_teams){
        new_row +=  `|[${team[0]}](${team[1]})`
      }        
      markdown += "\n" + new_row
  }
}
console.log(markdown)