<commit_before>class Seeders::YoutubeLinkParser
  def initialize(url)
    @url = Addressable::URI.parse(url)
  end

  def parse
    return nil if @url.nil? || @url.empty?

    if @url.path =~ %r{^/embed/}
      parse_embed
    elsif @url.path =~ %r{/watch}
      parse_watch
    else
      raise "URL #{@url} is not a valid Youtube link"
    end
  end

  def parse_embed
    video_id = @url.basename
    start_time = (@url.query_values && @url.query_values["start"]) || "0"

    { id: video_id, start: start_time }
  end

  def parse_watch
    params = @url.query_values
    video_id = params["v"]
    start_time = params["start"] || "0"

    { id: video_id, start: start_time }
  end
end<commit_msg>Parse the https://youtu.be/{video_id} format as well<commit_after>class Seeders::YoutubeLinkParser
  def initialize(url)
    @url = Addressable::URI.parse(url)
  end

  def parse
    return nil if @url.nil? || @url.empty?

    if @url.path =~ %r{^/embed/}
      parse_embed
    elsif @url.path =~ %r{/watch}
      parse_watch
    else
      parse_embed
    end
  end

  def parse_embed
    video_id = @url.basename
    start_time = (@url.query_values && @url.query_values["start"]) || "0"

    { id: video_id, start: start_time }
  end

  def parse_watch
    params = @url.query_values
    video_id = params["v"]
    start_time = params["start"] || "0"

    { id: video_id, start: start_time }
  end
end
{'fraction_non_alphanumeric': 0.13328581610833928, 'fraction_numerical': 0.002851033499643621, 'mean_word_length': 2.857142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, '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': '4649796', 'n_tokens_mistral': 521, 'n_tokens_neox': 501, 'n_words': 120}