<commit_before>require 'spec_helper'

describe "VideoInfo" do

  describe "from Youtube" do
    subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
    
    its(:provider)         { should == 'YouTube' }
    its(:video_id)         { should == 'mZqGqE0D0n4' }
    its(:url)              { should == 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
    its(:title)            { should == 'Cherry Bloom - King Of The Knife' }
    its(:description)      { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
    its(:keywords)         { should == 'cherry, bloom, king, of, the, knife, guitar, drum, clip, rock, alternative, tremplin, Paris-Forum' }
    its(:duration)         { should == 175 }
    its(:width)            { should be_nil }
    its(:height)           { should be_nil }
    its(:date)             { should == Time.parse('Sat Apr 12 22:25:35 UTC 2008', Time.now.utc) }
    its(:thumbnail_small)  { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/2.jpg' }
    its(:thumbnail_large)  { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/0.jpg' }
    its(:view_count)       { should be > 4000 }
    it { should be_valid }
  end
  
  describe "from Youtube" do
    subject { VideoInfo.new('http://www.youtube.com/watch?v=JM9NgvjjVng') }
    
    its(:provider)         { should == 'YouTube' }
    its(:duration)         { should == 217 }
    it { should be_valid }
  end
  
  describe "from Vimeo" do
    subject { VideoInfo.new('http://www.vimeo.com/898029') }
    
    its(:provider)         { should == 'Vimeo' }
    its(:video_id)         { should == '898029' }
    its(:url)              { should == 'http://vimeo.com/898029' }
    its(:title)            { should == 'Cherry Bloom - King Of The Knife' }
    its(:description)      { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
    its(:keywords)         { should == 'cherry bloom, secret sounds, king of the knife, rock, alternative' }
    its(:duration)         { should == 175 }
    its(:width)            { should == 640 }
    its(:height)           { should == 360 }
    its(:date)             { should == Time.parse('Mon Apr 14 13:10:39 +0200 2008', Time.now.utc) }
    its(:thumbnail_small)  { should == 'http://b.vimeocdn.com/ts/343/731/34373130_100.jpg' }
    its(:thumbnail_large)  { should == 'http://b.vimeocdn.com/ts/343/731/34373130_640.jpg' }
    its(:view_count)       { should be > 4000 }
    it { should be_valid }
  end
  
  it "should be invalid with misstaped url" do
    video = VideoInfo.new('http://www.vimo.com/1')
    video.should_not be_valid
  end
  
  it "should be invalid with bad url" do
    video = VideoInfo.new('http://www.yasda.com/asdasd')
    video.should_not be_valid
  end
  
  it "should be invalid with blank url" do
    video = VideoInfo.new('')
    video.should_not be_valid
  end
  
  it "should be invalid with nil url" do
    video = VideoInfo.new(nil)
    video.should_not be_valid
  end
  
end<commit_msg>added spec for yt:statistics fix on youtube vids without views<commit_after>require 'spec_helper'

describe "VideoInfo" do

  describe "from Youtube" do
    subject { VideoInfo.new('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
    
    its(:provider)         { should == 'YouTube' }
    its(:video_id)         { should == 'mZqGqE0D0n4' }
    its(:url)              { should == 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
    its(:title)            { should == 'Cherry Bloom - King Of The Knife' }
    its(:description)      { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
    its(:keywords)         { should == 'cherry, bloom, king, of, the, knife, guitar, drum, clip, rock, alternative, tremplin, Paris-Forum' }
    its(:duration)         { should == 175 }
    its(:width)            { should be_nil }
    its(:height)           { should be_nil }
    its(:date)             { should == Time.parse('Sat Apr 12 22:25:35 UTC 2008', Time.now.utc) }
    its(:thumbnail_small)  { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/2.jpg' }
    its(:thumbnail_large)  { should == 'http://i.ytimg.com/vi/mZqGqE0D0n4/0.jpg' }
    its(:view_count)       { should be > 4000 }
    it { should be_valid }
  end
  
  describe "from Youtube" do
    subject { VideoInfo.new('http://www.youtube.com/watch?v=JM9NgvjjVng') }
    
    its(:provider)         { should == 'YouTube' }
    its(:duration)         { should == 217 }
    it { should be_valid }
  end
  
  describe "from Vimeo" do
    subject { VideoInfo.new('http://www.vimeo.com/898029') }
    
    its(:provider)         { should == 'Vimeo' }
    its(:video_id)         { should == '898029' }
    its(:url)              { should == 'http://vimeo.com/898029' }
    its(:title)            { should == 'Cherry Bloom - King Of The Knife' }
    its(:description)      { should == 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
    its(:keywords)         { should == 'cherry bloom, secret sounds, king of the knife, rock, alternative' }
    its(:duration)         { should == 175 }
    its(:width)            { should == 640 }
    its(:height)           { should == 360 }
    its(:date)             { should == Time.parse('Mon Apr 14 13:10:39 +0200 2008', Time.now.utc) }
    its(:thumbnail_small)  { should == 'http://b.vimeocdn.com/ts/343/731/34373130_100.jpg' }
    its(:thumbnail_large)  { should == 'http://b.vimeocdn.com/ts/343/731/34373130_640.jpg' }
    its(:view_count)       { should be > 4000 }
    it { should be_valid }
  end
  
  it "should be invalid with misstaped url" do
    video = VideoInfo.new('http://www.vimo.com/1')
    video.should_not be_valid
  end
  
  it "should be invalid with bad url" do
    video = VideoInfo.new('http://www.yasda.com/asdasd')
    video.should_not be_valid
  end
  
  it "should be invalid with blank url" do
    video = VideoInfo.new('')
    video.should_not be_valid
  end
  
  it "should be invalid with nil url" do
    video = VideoInfo.new(nil)
    video.should_not be_valid
  end
  
  it "should have no views to it" do
    video = VideoInfo.new('http://www.youtube.com/watch?v=oQ49W_xKzKA') # Video with no views (DON'T LOOK AT IT!)
    video.view_count.should == 0
  end
end
{'fraction_non_alphanumeric': 0.14039447119117876, 'fraction_numerical': 0.03960242273644976, 'mean_word_length': 2.4735706580366776, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 17, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1645959', 'n_tokens_mistral': 2406, 'n_tokens_neox': 2209, 'n_words': 523}