Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need more detail documentations. #43

Closed
tigers2020 opened this issue Dec 24, 2017 · 5 comments
Closed

need more detail documentations. #43

tigers2020 opened this issue Dec 24, 2017 · 5 comments

Comments

@tigers2020
Copy link

tigers2020 commented Dec 24, 2017

would you provide more detail in documents with more examples? like how to use popular movies or pagination etcs.

@tigers2020
Copy link
Author

which way calling Movie is better?
movie = tmdb.Movie(342)
info = movie.info()
video = movie.video()
images = movie.images()
or
info = tmdb.movie(342).info()
video =tmdb.movie(342).video()
image = tmdb.movie(342).images()

@celiao
Copy link
Owner

celiao commented Dec 30, 2017

A good place to find more documentation and examples is the Closed Issues.

@celiao
Copy link
Owner

celiao commented Dec 30, 2017

You can call Movies() either way. It's a matter of preference.

Movie Examples

import tmdbsimple as tmdb
tmdb.API_KEY = 'YOUR_API_KEY_HERE'

Call Format 1 - Instance attributes

Create an instance of the type Movies. Call methods on the instance (movie.info(), movie.videos(), and movie.images()). Then you can access the instance attributes (movie.title, movie.results, movie.posters[0]). See The Movie Database API for the names of the attributes. For example, https://developers.themoviedb.org/3/movies/get-movie-details for info() attributes.

movie = tmdb.Movies(342)
info = movie.info()
videos = movie.videos()
images = movie.images()
movie.title, movie.results, movie.posters[0]
('Summer Storm',
 [{'id': '5581bf5c92514132b800001b',
   'iso_3166_1': 'US',
   'iso_639_1': 'en',
   'key': 'A4YghiZxHfw',
   'name': 'Trailer 1',
   'site': 'YouTube',
   'size': 360,
   'type': 'Trailer'}],
 {'aspect_ratio': 0.6790123456790124,
  'file_path': '/o9J7BEdsv0fUl89WwUCCW9Iq9Xj.jpg',
  'height': 4860,
  'iso_639_1': 'en',
  'vote_average': 5.377289377289378,
  'vote_count': 2,
  'width': 3300})

Call Format 2 - Direct Access

If you don't create an instance, you need to access the dict values directly.

info = tmdb.Movies(342).info()
videos = tmdb.Movies(342).videos()
images = tmdb.Movies(342).images()
info['title'], videos['results'], images['posters'][0]
('Summer Storm',
 [{'id': '5581bf5c92514132b800001b',
   'iso_3166_1': 'US',
   'iso_639_1': 'en',
   'key': 'A4YghiZxHfw',
   'name': 'Trailer 1',
   'site': 'YouTube',
   'size': 360,
   'type': 'Trailer'}],
 {'aspect_ratio': 0.6790123456790124,
  'file_path': '/o9J7BEdsv0fUl89WwUCCW9Iq9Xj.jpg',
  'height': 4860,
  'iso_639_1': 'en',
  'vote_average': 5.377289377289378,
  'vote_count': 2,
  'width': 3300})

@celiao celiao closed this as completed Dec 30, 2017
@tigers2020
Copy link
Author

so calling two option have no different performance?
like option 1 take 0.3 s and option 2 take 0.25 something like that?

@celiao
Copy link
Owner

celiao commented Dec 31, 2017

For this kind of programming, it's more important to care about readability than execution speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants