Kometa-Team / TMDbAPIs

A lightweight Python library for TMDb V3 and V4 APIs.
https://tmdbapis.metamanager.wiki
MIT License
11 stars 0 forks source link

[Docs]: Please add usage examples. #195

Open swasher opened 4 months ago

swasher commented 4 months ago

What is the improvement or update to the Documentation you wish to see?

Hello, and thank you for sharing your work! Can you add more usage examples for common scenarios? For example, search movie, add movie to list, add so on. Thanks!

PS. For example, I can't understand how to call API3's (or API4's) methods, like account_mark_as_favorite. Do I need create instance of API4 class directly? Or in any other manner?

Does the docs page already exist? Please link to it.

No response

meisnate12 commented 1 day ago

@swasher man im sorry i didnt see this until just now ill try and add more examples. but for you specific ask this is how to do it via the Object API.

from tmdbapis import TMDbAPIs

apikey = "0010843563404748808d3fc9c562c05e"
v4_access_token = "sohsnrfiemrsdvsavvt4h426GWEGW434gSgSdnjhcyuwbBYHBOSIYCBWgyNTYxNTY4OGQ5NTJjZCIsInN1YiI6IjVkMzM5ZmI0MmY4ZDAfdfdgegeGGregerfge34345BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIvfdvsdfveregrgqgfsfghjhOR0shmZZ_ZekFiuyl7o56921C0"

tmdb = TMDbAPIs(apikey, v4_access_token=v4_access_token)

print(tmdb.v4_authenticate())
input("Navigate to the URL and then hit enter when Authenticated")
tmdb.v4_approved()

movie = tmdb.movie(11) # TMDb Movie ID
movie.mark_as_favorite()

There are 2 ways to do every method one uses the Object API and the other uses the RAW API. There shouldn't really be a reason to use the RAW API in my opinion as everything can be done easier using the Object API.

Most methods that grab a list of data like movie/show lists, change lists, certification lists, and searches/discover are all direct methods under the main TMDbAPIs Object. Other methods that deal with for example a specific movie/show like Mark as Favorite are methods of the object they deal with. So first you need to use another method to get that object.

For example, there are three collections requests in the api (Details, Images, and Translations). By doing tmdbapis.collection(ID) you can get the collection object which has attributes containing all the info in Details as well as posters and backdrops from Images and translations from Translations.

Let me know if you have any more questions ill check back here to respond