<commit_before>require 'httparty'

module TVDB
  API_KEY  = '<KEY>'
  BASE_URL = 'http://www.thetvdb.com/api/'

  def self.build_drama(series_id)
    xml = get(series_url(series_id))

    drama = parse_drama(xml["Data"]["Series"])
  end

  def self.parse_drama(drama_xml)
    name   = drama_xml['SeriesName']
    summary = drama_xml['Overview']
    image  = "http://www.thetvdb.com/banners/" + (drama_xml['poster'] || drama_xml['banner']).to_s
    tvdbid = drama_xml['id']

    drama = Drama.find_or_create_by(tvdbid: tvdbid)
    drama.update_attributes(name: name, summary: summary, image: image)
    return drama
  end

  def self.get(url)
    get_url = HTTParty.get(url)
  end

  def self.build_authenticated_url(path)
    BASE_URL + API_KEY + path
  end

  def self.series_url(series_id)
    build_authenticated_url('/series/' + series_id.to_s + '/all/en.xml')
  end

  def self.build_url(path)
    BASE_URL + path
  end

  def self.search(query)
    terms = query.split(' ').join("%20")

    xml = get(build_url("/GetSeries.php?seriesname=" + terms))
  
    result = xml["Data"].nil? ? []  : [xml["Data"]["Series"]]
    result.flatten.map do |drama|
      parse_drama(drama)
    end
  end
end<commit_msg>fixes to tvdb file to fix rubocop errors<commit_after>require "httparty"

module TVDB
  API_KEY = "<KEY>"
  BASE_URL = "http://www.thetvdb.com/api/"

  def self.build_drama(series_id)
    xml = get(series_url(series_id))

    parse_drama(xml["Data"]["Series"])
  end

  def self.parse_drama(drama_xml)
    name = drama_xml["SeriesName"]
    summary = drama_xml["Overview"]
    image = "http://www.thetvdb.com/banners/" + (drama_xml["poster"] || drama_xml["banner"]).to_s
    tvdbid = drama_xml["id"]

    drama = Drama.find_or_create_by(tvdbid: tvdbid)
    drama.update_attributes(name: name, summary: summary, image: image)
    drama
  end

  def self.get(url)
    HTTParty.get(url)
  end

  def self.build_authenticated_url(path)
    BASE_URL + API_KEY + path
  end

  def self.series_url(series_id)
    build_authenticated_url("/series/" + series_id.to_s + "/all/en.xml")
  end

  def self.build_url(path)
    BASE_URL + path
  end

  def self.search(query)
    terms = query.split(" ").join("%20")

    xml = get(build_url("/GetSeries.php?seriesname=" + terms))
    result = xml["Data"].nil? ? [] : [xml["Data"]["Series"]]
    result.flatten.map do |drama|
      parse_drama(drama)
    end
  end
end
{'fraction_non_alphanumeric': 0.14925373134328357, 'fraction_numerical': 0.001658374792703151, 'mean_word_length': 3.5614366729678637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 24}, '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': '2517350', 'n_tokens_mistral': 933, 'n_tokens_neox': 910, 'n_words': 161}