<commit_before>module Mediaman

  require "to_name"

  class MediaFilename

    attr_accessor :filename
  
    def initialize(filename)        
      self.filename = override_filename filename
      @parsed_name = self.to_name
    end

    def override_filename(name)
      name.gsub!("2012", "") if name.include?("Newsroom")
      name
    end

    def to_name
      fn = ToName.to_name(filename)
      {
        name: fn.name,
        year: fn.year,
        raw_name: fn.raw_name,
        location: fn.location,
        season_number: fn.series,
        episode_number: fn.episode
      }
    end
    
    def to_hash
      {
        filename: self.filename,
        name: self.formatted_name,
        raw_name: self.raw_name,
        year: self.year,
        tv: self.tv?,
        movie: self.movie?,
        season_number: self.season,
        episode_number: self.episode,
        hd: self.hd?,
        hd_format: self.hd_format,
        title_slug: self.title_slug
      }
    end
  
    def raw_name
      self.filename
    end
    
    def formatted_name
      name = @parsed_name[:name]
    
      # Hacks
      name.gsub! /Extended( Version)( Edition)/i, ""
    
      name
    end
  
    def title_slug
      slug = formatted_name.parameterize
    
      #Hacks
      slug = "the-newsroom-2012" if slug == "the-newsroom"
    
      slug
    end

    def season
      @parsed_name[:season_number]
    end

    def episode
      @parsed_name[:episode_number]
    end

    def tv?
      episode.present? && season.present?
    end
  
    def year
      @parsed_name[:year]
    end
  
    def movie?
      !tv? && year.present?
    end<commit_msg>extended edition fixes<commit_after>module Mediaman

  require "to_name"

  class MediaFilename

    attr_accessor :filename
  
    def initialize(filename)        
      self.filename = override_filename filename
      @parsed_name = self.to_name
    end

    def override_filename(name)
      name.gsub!("2012", "") if name.include?("Newsroom")
      name
    end

    def to_name
      fn = ToName.to_name(filename)
      {
        name: fn.name,
        year: fn.year,
        raw_name: fn.raw_name,
        location: fn.location,
        season_number: fn.series,
        episode_number: fn.episode
      }
    end
    
    def to_hash
      {
        filename: self.filename,
        name: self.formatted_name,
        raw_name: self.raw_name,
        year: self.year,
        tv: self.tv?,
        movie: self.movie?,
        season_number: self.season,
        episode_number: self.episode,
        hd: self.hd?,
        hd_format: self.hd_format,
        title_slug: self.title_slug
      }
    end
  
    def raw_name
      self.filename
    end
    
    def formatted_name
      name = @parsed_name[:name]
    
      # Hacks
      name.gsub! /Extended( Version)?( Edition)?/i, ""
    
      name.strip.chomp
    end
  
    def title_slug
      slug = formatted_name.parameterize
    
      #Hacks
      slug = "the-newsroom-2012" if slug == "the-newsroom"
    
      slug
    end

    def season
      @parsed_name[:season_number]
    end

    def episode
      @parsed_name[:episode_number]
    end

    def tv?
      episode.present? && season.present?
    end
  
    def year
      @parsed_name[:year]
    end
  
    def movie?
      !tv? && year.present?
    end
{'fraction_non_alphanumeric': 0.08946262383668568, 'fraction_numerical': 0.004803362353647553, 'mean_word_length': 1.7605633802816902, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '2205388', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1089, 'n_words': 229}