movies 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,7 +41,7 @@ class Movies
41
41
  return self unless found?
42
42
 
43
43
  content.keys.each do |name|
44
- instance_variable_set "@" + name.to_s.downcase, content[name]
44
+ instance_variable_set "@" + name.to_s.downcase, (content[name] == "N/A" ? nil : content[name])
45
45
  end
46
46
 
47
47
  @year = @year.to_i
@@ -67,7 +67,7 @@ class Movies
67
67
 
68
68
  def released
69
69
  Date.parse(@released)
70
- rescue ArgumentError
70
+ rescue
71
71
  return nil
72
72
  end
73
73
 
@@ -14,9 +14,12 @@ excluded:
14
14
  - workprint
15
15
  - brrip|bluray|blu(-?)ray
16
16
  - dvd(-?)r
17
- - x264
17
+ - (.+-)?x264(-.+)?
18
18
  - UNRATED
19
19
  - IMAGiNE
20
20
  - SCR
21
21
  - "((ac3(-[a-z]+)?))"
22
- - LIMITED
22
+ - LIMITED
23
+ - (.+)?SUB
24
+ - NTSC
25
+ - PAL
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "movies"
6
- s.version = "0.1.1"
6
+ s.version = "0.1.2"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Linus Oleander"]
9
9
  s.email = ["linus@oleander.nu"]
@@ -0,0 +1,139 @@
1
+ require "spec_helper"
2
+
3
+ describe "exclude.yaml" do
4
+ it "should not contain 'EXTENDED'" do
5
+ Movies.cleaner("The Town 2010 EXTENDED 720p BRRip XviD AC3-Rx").should_not match(/extended/i)
6
+ end
7
+
8
+ it "should not contain 'XviD'" do
9
+ Movies.cleaner("The Town 2010 EXTENDED 720p BRRip XviD AC3-Rx").should_not match(/xvid/i)
10
+ end
11
+
12
+ it "should not contain '720p'" do
13
+ Movies.cleaner("The Town 2010 EXTENDED 720p BRRip XviD AC3-Rx").should_not match(/720p/i)
14
+ end
15
+
16
+ it "should not contain '1080p'" do
17
+ Movies.cleaner("The Town 2010 EXTENDED 1080p BRRip XviD AC3-Rx").should_not match(/1080p/i)
18
+ end
19
+
20
+ it "should not contain 'BRRip'" do
21
+ Movies.cleaner("The Town 2010 EXTENDED 1080p BRRip XviD AC3-Rx").should_not match(/BRRip/i)
22
+ end
23
+
24
+ it "should not contain 'CAM'" do
25
+ Movies.cleaner("Paul 2011 CAM XViD-UNDEAD").should_not match(/cam/i)
26
+ end
27
+
28
+ it "should not contain 'TELESYNC'" do
29
+ Movies.cleaner("Easy A TELESYNC XviD-TWiZTED").should_not match(/telesync/i)
30
+ end
31
+
32
+ it "should not contain 'TELECINE'" do
33
+ Movies.cleaner("Easy A TELECINE XviD-TWiZTED").should_not match(/telecine/i)
34
+ end
35
+
36
+ it "should not contain 'RX'" do
37
+ Movies.cleaner("The Company Men 2010 DVDRip XviD-Rx").should_not match(/rx/i)
38
+ end
39
+
40
+ it "should not contain 'DVDSCR'" do
41
+ Movies.cleaner("Black Swan (2010) DVDSCR Xvid-Nogrp").should_not match(/dvdscr/)
42
+ end
43
+
44
+ it "should not contain 'Screener'" do
45
+ Movies.cleaner("Devil 2010 Screener Xvid AC3 LKRG").should_not match(/screener/i)
46
+ end
47
+
48
+ it "should not contain 'HDTV'" do
49
+ Movies.cleaner("Bones S06E19 HDTV XviD-LOL").should_not match(/hdtv/i)
50
+ end
51
+
52
+ it "should not contain 'DVDRip'" do
53
+ Movies.cleaner("The Company Men 2010 DVDRip XviD-Rx").should_not match(/dvdrip/i)
54
+ end
55
+
56
+ it "should not contain 'WorkPrint'" do
57
+ Movies.cleaner("Elephant White 2011 WorkPrint XviD AC3-ViSiON").should_not match(/workprint/i)
58
+ end
59
+
60
+ it "should not contain 'Bluray'" do
61
+ Movies.cleaner("Last Night 2010 Bluray 720p Bluray DTS x264-CHD").should_not match(/bluray/i)
62
+ end
63
+
64
+ it "should not contain 'Blu-ray'" do
65
+ Movies.cleaner("Big Mommas Like Father Like Son 2011 Blu-ray RE 720 DTS Mysilu").should_not match(/blu-ray/i)
66
+ end
67
+
68
+ it "should not contain 'MDVDR'" do
69
+ Movies.cleaner("Exposed DVD Tupac Breaking The Oath 2010 NTSC MDVDR-C4DV").should_not match(/mdvdr/i)
70
+ end
71
+
72
+ it "should not contain 'NTSC'" do
73
+ Movies.cleaner("Exposed DVD Tupac Breaking The Oath 2010 NTSC MDVDR-C4DV").should_not match(/ntsc/i)
74
+ end
75
+
76
+ it "should not contain 'DVD-R'" do
77
+ Movies.cleaner("Lawrence Of Arabia 1962 iNTERNAL DVDRiP XviD-DVD-R").should_not match(/dvd-r/i)
78
+ end
79
+
80
+ it "should not contain 'x264-SFM'" do
81
+ Movies.cleaner("Great British Food Revival S01E04 720p HDTV x264-SFM").should_not match(/x264-sfm|sfm/i)
82
+ end
83
+
84
+ it "should not contain 'UNRATED'" do
85
+ Movies.cleaner("The Other Guys 2010 UNRATED DVDRip XviD AC3-YeFsTe").should_not match(/unrated/i)
86
+ end
87
+
88
+ it "should not contain 'IMAGiNE'" do
89
+ Movies.cleaner("Hop 2011 TS READNFO XViD - IMAGiNE").should_not match(/imagine/i)
90
+ end
91
+
92
+ it "should not contain 'SCR'" do
93
+ Movies.cleaner("The Last Exorcism SCR XViD - IMAGiNE").should_not match(/scr/i)
94
+ end
95
+
96
+ it "should not contain 'AC3-*'" do
97
+ Movies.cleaner("Biutiful 2010 DVDRip XviD AC3-TiMPE").should_not match(/ac3-timpe|ac3/i)
98
+ end
99
+
100
+ it "should not contain 'LIMITED'" do
101
+ Movies.cleaner("Stone LIMITED BDRip XviD-SAPHiRE").should_not match(/limited/i)
102
+ end
103
+
104
+ it "should not contain 'SWESUB'" do
105
+ Movies.cleaner("Sex And The City 2 2010 SWESUB DVDRip XviD AC3-Rx").should_not match(/swesub/i)
106
+ end
107
+
108
+ it "should not contain 'SUB'" do
109
+ Movies.cleaner("Sex And The City 2 2010 SUB DVDRip XviD AC3-Rx").should_not match(/sub/i)
110
+ end
111
+
112
+ it "should not contain 'NTSC'" do
113
+ Movies.cleaner("Piranha 2010 NTSC DVDR-TWiZTED").should_not match(/ntsc/i)
114
+ end
115
+
116
+ it "should not contain 'PAL'" do
117
+ Movies.cleaner("1942 PAL VC Arcade Wii-LaKiTu").should_not match(/pal/i)
118
+ end
119
+
120
+ it "should not contain a year" do
121
+ Movies.cleaner("1942 PAL VC Arcade Wii-LaKiTu").should_not match(/1942/)
122
+ end
123
+
124
+ it "should not contain dots" do
125
+ Movies.cleaner("Sex.And.The.City.2.2010.SUB.DVDRip.XviD.AC3-Rx").should_not match(/\./)
126
+ end
127
+
128
+ it "should not contain dash" do
129
+ Movies.cleaner("Sex.And.The.City.2.2010.SUB.DVDRip.XviD.AC3-Rx").should_not match(/-/)
130
+ end
131
+
132
+ it "should not contain to much whitespace" do
133
+ Movies.cleaner("A B").should eq("A B")
134
+ end
135
+
136
+ it "should strip ingoing params" do
137
+ Movies.cleaner(" A B ").should eq("A B")
138
+ end
139
+ end
@@ -10,7 +10,7 @@
10
10
  accept-encoding:
11
11
  - gzip, deflate
12
12
  timeout:
13
- - "10"
13
+ - "3"
14
14
  response: !ruby/struct:VCR::Response
15
15
  status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
@@ -35,7 +35,7 @@
35
35
  x-powered-by:
36
36
  - ASP.NET
37
37
  date:
38
- - Sat, 30 Apr 2011 03:37:31 GMT
38
+ - Sat, 30 Apr 2011 14:02:22 GMT
39
39
  content-length:
40
40
  - "469"
41
41
  body: !binary |
@@ -0,0 +1,54 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://www.imdbapi.com:80/?i=tt1570337
6
+ body:
7
+ headers:
8
+ accept:
9
+ - "*/*; q=0.5, application/xml"
10
+ accept-encoding:
11
+ - gzip, deflate
12
+ timeout:
13
+ - "3"
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ cache-control:
20
+ - no-cache
21
+ pragma:
22
+ - no-cache
23
+ content-type:
24
+ - text/html; charset=utf-8
25
+ content-encoding:
26
+ - gzip
27
+ expires:
28
+ - "-1"
29
+ vary:
30
+ - Accept-Encoding
31
+ server:
32
+ - Microsoft-IIS/7.0
33
+ x-aspnet-version:
34
+ - 4.0.30319
35
+ x-powered-by:
36
+ - ASP.NET
37
+ date:
38
+ - Sat, 30 Apr 2011 14:02:26 GMT
39
+ content-length:
40
+ - "462"
41
+ body: !binary |
42
+ H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3m
43
+ kuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZk
44
+ AWz2zkrayZ4hgKrIHz9+fB8/In7xR2+Ktsw/evTRF9l0krfzj0Yf/T55VtMH
45
+ ezu7O/TXq6zNZ/Tni7vH+Csv86zhDz5Nv5y2qbb6PF/WgPK0zhYZ/f20qPNp
46
+ WwHOq/Uqr9v086oqZ/TNd+uizfH5d4uyLLJF+nqevc2bVZ4RgNFHx3iroa9f
47
+ Zm1dTN+mr9v8KqvbUfplWVzmdfpkXU/no/T1+gfZcpnjz1m+HKVP8mV6ktWr
48
+ fAnoo49ellVLUATrl1WDTx99NG/b1aO7d4tsvMhnRbZdLGaT8bRa3C0W2UXe
49
+ 3P3i7hc/ef/JF2++2nnx5vfZe/H0i/svntHf5f0n2fLJ8vd++6z9qTfTqy+e
50
+ frX34qd/n3cvjn/P33P8+//k7vj3f/1739vbGf/06oI6e7VetsUCxJDOiYDF
51
+ 8oL+fDDeoz9/smpzjG/3wX366+wp/dq2u/cf7Ny794A+eEWkqJYNXn9Tr/OP
52
+ fsn/A6ZTWkyiAQAA
53
+
54
+ http_version: "1.1"
@@ -56,7 +56,7 @@
56
56
  accept-encoding:
57
57
  - gzip, deflate
58
58
  timeout:
59
- - "10"
59
+ - "3"
60
60
  response: !ruby/struct:VCR::Response
61
61
  status: !ruby/struct:VCR::ResponseStatus
62
62
  code: 200
@@ -81,7 +81,7 @@
81
81
  x-powered-by:
82
82
  - ASP.NET
83
83
  date:
84
- - Sat, 30 Apr 2011 03:37:30 GMT
84
+ - Sat, 30 Apr 2011 14:02:20 GMT
85
85
  content-length:
86
86
  - "144"
87
87
  body: !binary |
@@ -168,7 +168,7 @@
168
168
  accept-encoding:
169
169
  - gzip, deflate
170
170
  timeout:
171
- - "10"
171
+ - "3"
172
172
  response: !ruby/struct:VCR::Response
173
173
  status: !ruby/struct:VCR::ResponseStatus
174
174
  code: 200
@@ -193,7 +193,7 @@
193
193
  x-powered-by:
194
194
  - ASP.NET
195
195
  date:
196
- - Sat, 30 Apr 2011 03:37:28 GMT
196
+ - Sat, 30 Apr 2011 14:02:16 GMT
197
197
  content-length:
198
198
  - "593"
199
199
  body: !binary |
@@ -64,7 +64,7 @@
64
64
  accept-encoding:
65
65
  - gzip, deflate
66
66
  timeout:
67
- - "10"
67
+ - "3"
68
68
  response: !ruby/struct:VCR::Response
69
69
  status: !ruby/struct:VCR::ResponseStatus
70
70
  code: 200
@@ -89,7 +89,7 @@
89
89
  x-powered-by:
90
90
  - ASP.NET
91
91
  date:
92
- - Sat, 30 Apr 2011 03:37:29 GMT
92
+ - Sat, 30 Apr 2011 14:02:17 GMT
93
93
  content-length:
94
94
  - "540"
95
95
  body: !binary |
@@ -111,7 +111,7 @@
111
111
  accept-encoding:
112
112
  - gzip, deflate
113
113
  timeout:
114
- - "10"
114
+ - "3"
115
115
  response: !ruby/struct:VCR::Response
116
116
  status: !ruby/struct:VCR::ResponseStatus
117
117
  code: 200
@@ -136,7 +136,7 @@
136
136
  x-powered-by:
137
137
  - ASP.NET
138
138
  date:
139
- - Sat, 30 Apr 2011 03:37:30 GMT
139
+ - Sat, 30 Apr 2011 14:02:19 GMT
140
140
  content-length:
141
141
  - "571"
142
142
  body: !binary |
@@ -10,7 +10,7 @@
10
10
  accept-encoding:
11
11
  - gzip, deflate
12
12
  timeout:
13
- - "10"
13
+ - "3"
14
14
  response: !ruby/struct:VCR::Response
15
15
  status: !ruby/struct:VCR::ResponseStatus
16
16
  code: 200
@@ -35,7 +35,7 @@
35
35
  x-powered-by:
36
36
  - ASP.NET
37
37
  date:
38
- - Sat, 30 Apr 2011 03:37:31 GMT
38
+ - Sat, 30 Apr 2011 14:02:28 GMT
39
39
  content-length:
40
40
  - "643"
41
41
  body: !binary |
@@ -67,7 +67,7 @@
67
67
  accept-encoding:
68
68
  - gzip, deflate
69
69
  timeout:
70
- - "10"
70
+ - "3"
71
71
  response: !ruby/struct:VCR::Response
72
72
  status: !ruby/struct:VCR::ResponseStatus
73
73
  code: 200
@@ -92,7 +92,7 @@
92
92
  x-powered-by:
93
93
  - ASP.NET
94
94
  date:
95
- - Sat, 30 Apr 2011 03:37:32 GMT
95
+ - Sat, 30 Apr 2011 14:02:30 GMT
96
96
  content-length:
97
97
  - "583"
98
98
  body: !binary |
@@ -157,7 +157,7 @@
157
157
  accept-encoding:
158
158
  - gzip, deflate
159
159
  timeout:
160
- - "10"
160
+ - "3"
161
161
  response: !ruby/struct:VCR::Response
162
162
  status: !ruby/struct:VCR::ResponseStatus
163
163
  code: 200
@@ -182,7 +182,7 @@
182
182
  x-powered-by:
183
183
  - ASP.NET
184
184
  date:
185
- - Sat, 30 Apr 2011 03:37:29 GMT
185
+ - Sat, 30 Apr 2011 14:02:18 GMT
186
186
  content-length:
187
187
  - "550"
188
188
  body: !binary |
@@ -112,7 +112,7 @@ describe Movies do
112
112
 
113
113
  context "bug1" do
114
114
  use_vcr_cassette "bug1"
115
- it "should not raise an error when date is invalid" do
115
+ it "should not raise an error when date is invalid" do
116
116
  lambda {
117
117
  Movies.new("http://www.imdbapi.com/?t=Consinsual&y=2010").prepare.released.should be_nil
118
118
  }.should_not raise_error
@@ -120,6 +120,19 @@ describe Movies do
120
120
  end
121
121
  end
122
122
 
123
+ context "N/A" do
124
+ use_vcr_cassette "n-a-tt1570337"
125
+ it "Fields that contains N/A should be nil or zero" do
126
+ movie = Movies.new("http://www.imdbapi.com/?i=tt1570337").prepare
127
+
128
+ movie.runtime.should eq(0)
129
+ movie.plot.should be_nil
130
+ movie.rated.should be_nil
131
+
132
+ a_request(:get, "http://www.imdbapi.com/?i=tt1570337").should have_been_made.once
133
+ end
134
+ end
135
+
123
136
  context "tomatoes" do
124
137
  use_vcr_cassette "tt0337978"
125
138
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: movies
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Linus Oleander
@@ -86,7 +86,9 @@ files:
86
86
  - lib/movies.rb
87
87
  - lib/movies/exclude.yml
88
88
  - movies.gemspec
89
+ - spec/exclude_spec.rb
89
90
  - spec/fixtures/vcr_cassettes/bug1.yml
91
+ - spec/fixtures/vcr_cassettes/n-a-tt1570337.yml
90
92
  - spec/fixtures/vcr_cassettes/not_found.yml
91
93
  - spec/fixtures/vcr_cassettes/true-grit-1969.yml
92
94
  - spec/fixtures/vcr_cassettes/true-grit-2010.yml
@@ -124,7 +126,9 @@ signing_key:
124
126
  specification_version: 3
125
127
  summary: Movies is the bridge between IMDb's unofficial API; imdbapi.com and Ruby.
126
128
  test_files:
129
+ - spec/exclude_spec.rb
127
130
  - spec/fixtures/vcr_cassettes/bug1.yml
131
+ - spec/fixtures/vcr_cassettes/n-a-tt1570337.yml
128
132
  - spec/fixtures/vcr_cassettes/not_found.yml
129
133
  - spec/fixtures/vcr_cassettes/true-grit-1969.yml
130
134
  - spec/fixtures/vcr_cassettes/true-grit-2010.yml