<commit_before>module Imba
  class MovieList
    attr_reader :movies

    def initialize
      @movies = Movie.all
    end

    def movie_dirs
      # don't belong here...
      # get movie names (dirs)
      @movie_dirs ||= Dir['*'].select {|f| File.directory? f}
    end

    def add
      Imba::DataStore[:movies] = movie_dirs
    end
    # @movie_dirs.each { |d| FileUtils.cd(d) { FileUtils.touch ".hello" } }

    def synch
      # for each movie
      movie_dirs.each do |movie_name|
        # check movie name on imdb
        result = Imdb::Movie.search(movie_name).first
        # puts foundings
        movie = "#{result.title} (#{result.id}) #{result.genres} #{result.rating}/10"
        Imba::DataStore["#{result.id}"] = movie
        puts "#{movie_name} \t=>\t #{movie}"
          # ask if founding is correct
          # update movie name? (folder)

        # write .imdb_uniq_id in movie folder
        # save movie name and imdb_uniq_id in DataStore[:movies]
        # or serialize hole imdb movie object?!
      end
    end

  end
end<commit_msg>ask for updating directory name<commit_after>module Imba
  class MovieList
    attr_reader :movies

    def initialize
      @movies = Movie.all
    end

    def movie_dirs
      # don't belong here...
      # get movie names (dirs)
      @movie_dirs ||= Dir['*'].select {|f| File.directory? f}
    end

    def add
      Imba::DataStore[:movies] = movie_dirs
    end
    # @movie_dirs.each { |d| FileUtils.cd(d) { FileUtils.touch ".hello" } }

    def synch
      # for each movie
      movie_dirs.each do |movie_name|
        # check movie name on imdb
        result = Imdb::Movie.search(movie_name).first # needs rescue?
        # puts foundings
        movie_title = result.title.gsub(/\(\d+\)/, '').strip
        movie = "#{movie_title}, #{result.year}, #{result.genres}, #{result.rating}/10"
        Imba::DataStore["#{result.id}"] = movie

        # update movie name? (folder)
        if movie_name != movie_title
          puts "change #{movie_name} => #{movie_title}? \n(enter 'y' to confirm or anything else to continue)"
          if STDIN.gets.strip.downcase == "y"
            FileUtils.mv(movie_name, movie_title)
          end
        end

        # ask if founding is correct
        # write .imdb_uniq_id in movie folder
        # save movie name and imdb_uniq_id in DataStore[:movies]
        # or serialize hole imdb movie object?!
      end
      "done"
    end

  end
end
{'fraction_non_alphanumeric': 0.11726384364820847, 'fraction_numerical': 0.0016286644951140066, 'mean_word_length': 2.232894736842105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '883514', 'n_tokens_mistral': 821, 'n_tokens_neox': 788, 'n_words': 218}