دعم الموقع

Hi all, i am trying to fetch the genre data for each movie with discover/movie. The only value available are the genre id which is an integer. what i need is the genre type that match this specific movie object. I have seen that i can get the genre by adding with_genre but not sure how or where to this. How can i get this data? Can someone help me, please? thanks

{
    "adult": false,
    "backdrop_path": "/tutaKitJJIaqZPyMz7rxrhb4Yxm.jpg",
    "genre_ids": [
        16,
        35,
        10751,
        10402
    ],
    "id": 438695,
    "original_language": "en",
    "original_title": "Sing 2",
    "overview": "Buster and his new cast now have their sights set on debuting a new show at the Crystal Tower Theater in glamorous Redshore City. But with no connections, he and his singers must sneak into the Crystal Entertainment offices, run by the ruthless wolf mogul Jimmy Crystal, where the gang pitches the ridiculous idea of casting the lion rock legend Clay Calloway in their show. Buster must embark on a quest to find the now-isolated Clay and persuade him to return to the stage.",
    "popularity": 8913.036,
    "poster_path": "/aWeKITRFbbwY8txG5uCj4rMCfSP.jpg",
    "release_date": "2021-12-01",
    "title": "Sing 2",
    "video": false,
    "vote_average": 8.2,
    "vote_count": 740
}

6 ردود (على هذه الصفحة 1 من 1)

Jump to last post

An example discover query looking for say, action (id 28) and adventure (id 12) would look like this:

https://api.themoviedb.org/3/discover/movie?api_key=###&with_genres=28,12

This is an AND query. If you wanted to do an OR query, you would want to change the comma to a pipe:

https://api.themoviedb.org/3/discover/movie?api_key=###&with_genres=28|12

Discover supports well over 30 options and filters so make sure to read the docs to start and understand how powerful it is.

Hi Travis, thanks for supporting on a sunday. I am fetching it this way using an async function. Where should i add the with_genres in this set up,please?

const fetchMovies = async () => {

    const { data: {results}} = await axios.get(`${API_URL}/discover/movie/with_genres`, {
      params: {
        api_key: process.env.REACT_APP_MOVIE_API_KEY,
      },
    })

@llator01 said:

Hi Travis, thanks for supporting on a sunday. I am fetching it this way using an async function. Where should i add the with_genres in this set up,please?

No problem. Just chilling with some coffee wink

You're looking for something a little more like this:

 const fetchMovies = async () => {

     const { data: {results}} = await axios.get(`${API_URL}/discover/movie`, {
       params: {
         api_key: process.env.REACT_APP_MOVIE_API_KEY,
         with_genres: ${GENRE_QUERY}
       },
     })

$GENRE_QUERY in this case would be a string like 28,12, but I don't know anything about Axios so that might not be the proper convention. Structurally that's right in any case.

thanks for this, i will have to dig deeper but it helps.
One more thing, is there a way to get all genres not only 1 specific.
From the data set i have provide as you can see the movie has 4 genres id, which i assume correspond to the respectif genre this movie is belonging to.
If i want to display these 4 genres on the movie card, how would i do this?
Alternatively, in the first data set there are the genre ids, is there a way to get this ref return the matching name of the ref?
thanks again

const API_URL = Base_URL + "/discover/movie?sort_by=popularity.desc&" + API_KEY;

@llator01 said:
Alternatively, in the first data set there are the genre ids, is there a way to get this ref return the matching name of the ref?
thanks again

No. You will always receive the Gender ID.
I think at the very least you need to have the Gender ID match list with the Gender.
Look here:
https://developers.themoviedb.org/3/genres/get-movie-list
https://developers.themoviedb.org/3/genres/get-tv-list
Knowing which ID corresponds to which Genre you should on your side, in your code, do the conversion.

If i want to display these 4 genres on the movie card, how would i do this?

I don't know what you mean by movie card
I believe that only AXIOS code programmers can help you with this question.

لم تجد الفلم أو المسلسل ؟ سجل دخولك و انشئها

عام

s ركز شريط البحث
p افتح قائمة الملف الشخصي
esc اغلق النافذة المفتوحة
? افتح نافذة اختصارات لوحة المفاتيح

على كافة صفحات الوسائط

b ارجع للخلف (او للصفحة الام عند التطبيق)
e انتقل لصفحة التعديل

على كافة صفحات موسم المسلسل

(السهم الايمن) انتقل للموسم التالي
(السهم الايسر) انتقل للموسم السابق

على كافة صفحات حلقة المسلسل

(السهم الايمن) انتقل للحلقة التالية
(السهم الايسر) انتقل للحلقة السابقة

على كافة صفحات الصور

a افتح صفحة اضافة الصورة

على كافة صفحات التعديل

t افتح محدد الترجمة
ctrl+ s ارسال النموذج

على صفحات المناقشة

n انشى نقاش جديد
w تبديل حالة المتابعة
p تبديل عام / خاص
c تبديل اغلاق / فتح
a افتح الانشطة
r رد على النقاش
l انتقل لأخر رد
ctrl+ enter أرسل رسالتك
(السهم الايمن) الصفحة التالية
(السهم الايسر) الصفحة السابقة

الاعدادات

هل تريد تقييم او اضافة هذا العنصر للقائمة؟

تسجيل الدخول