Skip to content

Commit

Permalink
TV show original language (#61)
Browse files Browse the repository at this point in the history
* Allow searching movies with filters

The [API for Movies](https://developers.themoviedb.org/3/search/search-movies)
allows searching with more than just the query. However, the gem didn't
have a way of adding this filters.

This commit allows passing a hash of filters to the search/find method
so these parameters can be added when searching.

* Bump the version

* Add original_language to TV shows

* Update version.rb

---------

Co-authored-by: Dan Kim <[email protected]>
  • Loading branch information
ferdynton and dankimio authored Oct 13, 2024
1 parent 4d2bd6b commit a8a5018
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/themoviedb/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ def self.list(conditions = {})
end
end

def self.search(query)
def self.search(query, conditions = {})
search = Tmdb::Search.new
search.resource(endpoints[:singular].to_s)
search.query(query)
search.filter(conditions)
search.fetch.collect do |result|
new(result)
end
Expand Down
1 change: 1 addition & 0 deletions lib/themoviedb/tv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class TV < Resource
:number_of_episodes,
:number_of_seasons,
:original_name,
:original_language,
:origin_country,
:overview,
:popularity,
Expand Down
13 changes: 13 additions & 0 deletions spec/movie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@
end
end

describe "For a movie search" do
before(:each) do
VCR.use_cassette "movie/search" do
@movies = Tmdb::Movie.search("House", year: 1977)
end
end

it "should return movies from the year specified" do
# House (1977) doesn't appear in the first page unless year is specified
expect(@movies).to include(an_object_having_attributes(id: 25623))
end
end

describe "For a movie detail with appended response" do
let(:append_fields) do
%w[ alternative_titles credits images keywords releases
Expand Down
1 change: 1 addition & 0 deletions spec/tv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
:number_of_episodes,
:number_of_seasons,
:original_name,
:original_language,
:origin_country,
:overview,
:popularity,
Expand Down
58 changes: 58 additions & 0 deletions spec/vcr/movie/search.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a8a5018

Please sign in to comment.