<commit_before>class EpisodesController < ApplicationController
  before_action :set_episode, only: [:show, :edit, :update, :destroy, :play, :unsee]

  # GET /episodes
  # GET /episodes.json
  def index
    @series = Series.find(params[:series_id].to_i)
    @new_episodes = @series.episodes.where(:seen => false).order("season desc, episode desc")
    @seen_episodes = @series.episodes.where(:seen => true).order("season desc, episode desc")
  end

  # GET /episodes/1
  # GET /episodes/1.json
  def show
  end

  # PUT /episodes/1/play
  def play
    @episode.update_attribute(:seen, true)
    Thread.new {
      quietly {
        Suby.download_subtitles [@episode.path], lang: (params[:lang] || APP_CONFIG['subs_locale']), force: true
        system APP_CONFIG['player'], "#{@episode.path}"
      }
      ActiveRecord::Base.connection.close
    }
    flash[:success] = "Downloading subtitles and playing #{@episode.series.name} - #{@episode.name}"<commit_msg>Fixed subtitles downloader<commit_after>class EpisodesController < ApplicationController
  before_action :set_episode, only: [:show, :edit, :update, :destroy, :play, :unsee]

  # GET /episodes
  # GET /episodes.json
  def index
    @series = Series.find(params[:series_id].to_i)
    @new_episodes = @series.episodes.where(:seen => false).order("season desc, episode desc")
    @seen_episodes = @series.episodes.where(:seen => true).order("season desc, episode desc")
  end

  # GET /episodes/1
  # GET /episodes/1.json
  def show
  end

  # PUT /episodes/1/play
  def play
    @episode.update_attribute(:seen, true)
    Thread.new {
      quietly {
        system "subliminal -l #{params[:lang] || APP_CONFIG['subs_locale']} -s -f -- #{"\"" + @episode.path.gsub('/', '\\') + "\""}"
        system APP_CONFIG['player'], "#{@episode.path}"
      }
      ActiveRecord::Base.connection.close
    }
    flash[:success] = "Downloading subtitles and playing #{@episode.series.name} - #{@episode.name}"
{'fraction_non_alphanumeric': 0.15805626598465472, 'fraction_numerical': 0.003069053708439898, 'mean_word_length': 3.657142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962554', 'n_tokens_mistral': 694, 'n_tokens_neox': 674, 'n_words': 134}