<commit_before>module BitsOnTheRun
  class Video

    def self.list(options = nil)
      if options.is_a?(String) && !options.empty?
        require 'cgi'
        uri = URI.parse(options)
        options = CGI.parse(uri.query)
      end
      
      client = Client.new('/videos/list', options)
      client.response.elements["//videos"].map do |fragment|
        new(REXML::Document.new(fragment.to_s)) if fragment.respond_to?(:name)
      end.compact

    end

    def self.show(video_key)
      client = Client.new('/videos/show', :video_key => video_key)
      new(client.response)
    end

    def self.create!(params = {})
      returning new(params) do |video|
        video.save!
      end
    end

    def self.update(video_key, video_attributes)
      Video.update_attributes(video_key,video_attributes)
    end

    def self.update_attributes(video_key, video_attributes)
      status = CLient.new('videos/update', :video_key => video_key, :video_attributes => video_attributes)
      status.response.elements["//status"]
    end

    def self.delete!(video_key)
      Video.delete(video_key)
    end

    def self.delete(video_key)
      status = Client.new('/videos/delete', :video_key => video_key)
      status.response.elements["//status"]
    end
    
    attr_reader :key
    attr_accessor :author, :date, :description, :duration, :link, :status
    attr_accessor :tags, :title, :filename

    def initialize(*args)
      if args.first.is_a?(REXML::Document)
        initialize_from_xml(args.first)
      else
        initialize_from_hash(*args)
      end
    end

    def templates
      @templates ||= VideoTemplate.list(key)
    end

    def conversions
      @conversions ||= VideoConversion.list(key)
    end

    def save!
      client = Client.new('/videos/create',
        :title       => title,
        :tags        => tags.join(", "),
        :description => description,
        :author      => author,
        :date        => date.to_i,
        :link        => link,<commit_msg>update response status for video deleteand update<commit_after>module BitsOnTheRun
  class Video

    def self.list(options = nil)
      if options.is_a?(String) && !options.empty?
        require 'cgi'
        uri = URI.parse(options)
        options = CGI.parse(uri.query)
      end
      
      client = Client.new('/videos/list', options)
      client.response.elements["//videos"].map do |fragment|
        new(REXML::Document.new(fragment.to_s)) if fragment.respond_to?(:name)
      end.compact

    end

    def self.show(video_key)
      client = Client.new('/videos/show', :video_key => video_key)
      new(client.response)
    end

    def self.create!(params = {})
      returning new(params) do |video|
        video.save!
      end
    end

    def self.update(video_key, video_attributes)
      Video.update_attributes(video_key,video_attributes)
    end

    def self.update_attributes(video_key, video_attributes)
      status = Client.new('videos/update', :video_key => video_key, :video_attributes => video_attributes)
      status.response.elements["//status"][0]
    end

    def self.delete!(video_key)
      Video.delete(video_key)
    end

    def self.delete(video_key)
      status = Client.new('/videos/delete', :video_key => video_key)
      status.response.elements["//status"][0]
    end
    
    attr_reader :key
    attr_accessor :author, :date, :description, :duration, :link, :status
    attr_accessor :tags, :title, :filename

    def initialize(*args)
      if args.first.is_a?(REXML::Document)
        initialize_from_xml(args.first)
      else
        initialize_from_hash(*args)
      end
    end

    def templates
      @templates ||= VideoTemplate.list(key)
    end

    def conversions
      @conversions ||= VideoConversion.list(key)
    end

    def save!
      client = Client.new('/videos/create',
        :title       => title,
        :tags        => tags.join(", "),
        :description => description,
        :author      => author,
        :date        => date.to_i,
        :link        => link,
{'fraction_non_alphanumeric': 0.12124199112863479, 'fraction_numerical': 0.0004928536224741252, 'mean_word_length': 2.466268146883006, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '638072', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1236, 'n_words': 247}