<commit_before>class Seeders::RiotStreams
  extend Forwardable
  def_delegators :@riot_streams, :active_streamgroups, :streams, :youtube_stream, :active_matches

  def initialize(source)
    @source = source
    @riot_streams = Riot::Streams.new
  end

  def seed
    seed_streams
    seed_active_matches
  end

  def seed_streams
    active_streamgroups.each do |streamgroup|
      stream = youtube_stream(streams(streamgroup['id']))

      riot_league_id = Seeders::League::LEAGUES.key(streamgroup['title'].gsub(' English', ''))

      seed_stream(stream, riot_league_id) if stream && riot_league_id
    end
  end

  def seed_stream(stream, riot_league_id)
    stream['embedHTML'] =~ /(https:\/\/www\.youtube\.com)(.*?)"/
    url = "#{$1}#{$2}"

    league = @source.leagues.find { |league| league.riot_id == riot_league_id }
    league.stream_url = url
  end

  def seed_active_matches
    active_matches.each_pair do |riot_league_id, match_ids|
      league = @source.leagues.find { |league| league.riot_id == riot_league_id }
      league.stream_match_ids = match_ids
    end
  end
end<commit_msg>Use manual mapping of streamgroup slug to league name to fix live streams not showing<commit_after>class Seeders::RiotStreams
  STREAMGROUPS_LEAGUES = {
    'msi' => 'MSI',
    'na-lcs' => 'NA LCS',
    'eu-lcs' => 'EU LCS',
    'lck-korea' => 'LCK',
    'lpl' => 'LPL',
    'lms' => 'LMS',
    'oce-opl' => 'OPL',
    'na-challenger' => 'NA CS',
    'eu-challenger' => 'EU CS'
  }

  extend Forwardable
  def_delegators :@riot_streams, :active_streamgroups, :streams, :youtube_stream, :active_matches

  def initialize(source)
    @source = source
    @riot_streams = Riot::Streams.new
  end

  def seed
    seed_streams
    seed_active_matches
  end

  def seed_streams
    active_streamgroups.each do |streamgroup|
      stream = youtube_stream(streams(streamgroup['id']))

      riot_league_id = stream_league_id(streamgroup['slug'])

      seed_stream(stream, riot_league_id) if stream && riot_league_id
    end
  end

  def seed_stream(stream, riot_league_id)
    stream['embedHTML'] =~ /(https:\/\/www\.youtube\.com)(.*?)"/
    url = "#{$1}#{$2}"

    league = @source.leagues.find { |league| league.riot_id == riot_league_id }
    league.stream_url = url
  end

  def seed_active_matches
    active_matches.each_pair do |riot_league_id, match_ids|
      league = @source.leagues.find { |league| league.riot_id == riot_league_id }
      league.stream_match_ids = match_ids
    end
  end

  def stream_league_id(slug)
    Seeders::League::LEAGUES.key(STREAMGROUPS_LEAGUES[slug])
  end
end
{'fraction_non_alphanumeric': 0.12673343605546997, 'fraction_numerical': 0.0015408320493066256, 'mean_word_length': 3.7304189435336976, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683073', 'n_tokens_mistral': 986, 'n_tokens_neox': 909, 'n_words': 179}