دعم الموقع

Hello,

I'm working on a simple app for my programming course and I require some help - hopefully you can help me. I would like to use your API, but I get lost reading the documentation. Anyhow, this is the piece of code that I'm currently working on:

handleInputChange = (event) => {
        this.setState({
            inputField: event.target.value
        });
}
handleBtnClick = (event) => {
        event.preventDefault();
        const url = 'https://api.tvmaze.com/singlesearch/shows?q='+this.state.inputField.split(' ').join('+');
        this.fetchShow(url);
        console.log(url);
}
fetchShow(url){ fetch(url).then((res) => res.json()).then((data) => { this.setState({ tvId: data.id, genres: data.genres, name: data.name, url: data.url, image: data.image.original, rating: data.rating.average, })

        console.log(this.state.tvId, this.state.genres, this.state.name, this.state.url, this.state.image, this.state.rating);
    })
}

As you can see, I'm currently using a different API, but it's options are very limited. How, compared to what I wrote, can I find a tv show, get it's title, image, imdb rating, genre and id using your api? As in, what would the url look like for my code to work?

Second question might be a bit more complicated. You see, what I want to do, is (after finding a tv show using search ), to allow the user to find 1 more show(onClick) that share it's genre/genres (1-3). After that the user gets to see another show based on the one that he clicked, and so on, and so on "ad infinitum". Can you help me in finding a method on how to do that? How do I find tv shows based on genre using your API? I could then substitute genre with a variable that equals the genre of the primary search result.

I really hope you can help me. Your API looks great, but like I said, I find it hard to use. Thanks

edit: I have a key :)

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

Jump to last post

How, compared to what I wrote, can I find a tv show, get it's title, image, imdb rating, genre and id using your api? As in, what would the url look like for my code to work?

I believe this document mostly outlines what you are trying to. It's using the movie method and search, but all you have to do is swap those out for the TV methods.

Second question might be a bit more complicated. You see, what I want to do, is (after finding a tv show using search ), to allow the user to find 1 more show(onClick) that share it's genre/genres (1-3).

Two different approaches. First, to do what you're asking, you can tap into TV discover for this. Let's say you pull Doctor Who (id 57243) and get it's genre ids: 10759, 18, 10765.

    https://api.themoviedb.org/3/tv/57243?api_key=###

You can then make a call like so (comma separate are an 'AND' query):

https://api.themoviedb.org/3/discover/tv?api_key=###&with_genres=10759,18,10765

But, this seems like a good use case for recommendations, in which case you can just make one call to get the details and recommendations by using append_to_response:

https://api.themoviedb.org/3/tv/57243?api_key=###&append_to_response=recommendations

You'll see a recommendations object is now part of the response, with a list of shows that are similar.

Thanks, it works great!

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

عام

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

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

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

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

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

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

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

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

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

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

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

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

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

الاعدادات

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

تسجيل الدخول