Υποστήριξη για το The Movie Database

Hello, I am trying to get all the Seasons (with the Episodes) for a TV Show:

I am trying to retrieve everything in 2 API calls.

What I am doing right now is:

  • Retrieving the TVShow using the Id -> Then, inside the TVShow object I have the seasons[] which I can use to get the amount of Seasons inside the specific TV Show

Example Query

https://api.themoviedb.org/3/tv/1418
  • By using the append_to_response I can retrieve all the seasons by building the new query dynamically based on the amount of Seasons retrieved from the previous point.
https://api.themoviedb.org/3/tv/1418?api_key=XXXX&append_to_response=season/1,season/2,season/3,season/4,season/5,season/6,season/7,season/8,season/9,season/10,season/11

The issue I am having is that those Seasons are coming into separate fields instead of a List:

...
"vote_average": 6.8,
"vote_count": 2966,
"season/1":{"_id": "5256cfbc19c2956ff60a042f", "air_date": "2007-09-24", "episodes":[{"air_date": "2007-09-24",…},
"season/2":{"_id": "5256cfbb19c2956ff60a0348", "air_date": "2008-09-22", "episodes":[{"air_date": "2008-09-22",…},
"season/3":{"_id": "5256cfbb19c2956ff60a037f", "air_date": "2009-09-21", "episodes":[{"air_date": "2009-09-21",…},
"season/4":{"_id": "5256cfbc19c2956ff60a03b8", "air_date": "2010-09-23", "episodes":[{"air_date": "2010-09-23",…},
"season/5":{"_id": "5256cfbc19c2956ff60a03f1", "air_date": "2011-09-22", "episodes":[{"air_date": "2011-09-22",…},
"season/6":{"_id": "5256cfbc19c2956ff60a0416", "air_date": "2012-09-27", "episodes":[{"air_date": "2012-09-27",…},
"season/7":{"_id": "5256cfbc19c2956ff60a0468", "air_date": "2013-09-25", "episodes":[{"air_date": "2013-09-25",…},
"season/8":{"_id": "53d1798b0e0a265e0100d01b", "air_date": "2014-09-22", "episodes":[{"air_date": "2014-09-22",…},
"season/9":{"_id": "55f0db989251416705000479", "air_date": "2015-09-21", "episodes":[{"air_date": "2015-09-21",…},
"season/10":{"_id": "57d2a4a69251415cb9002b29", "air_date": "2016-09-19", "episodes":[{"air_date": "2016-09-19",…},
"season/11":{"_id": "598251a392514151c501c11f", "air_date": "2017-09-25", "episodes":[{"air_date": "2017-09-25",…}
...

Is it possible to get all those Season objects inside a list? When parsing the response into the object, I don't know before hand how many Seasons does a Specific Tv Show has. So how many Season Fields to define in the TVShow POJO if every different TVShow will have different amount of Seasons.

Thanks a lot smiley

4 απαντήσεις(στη σελίδα 1 από 1)

Jump to last post

Hi there,

Unfortunately, no, this is not possible. The best way to think about/implement this is that every one of the appended methods that is specified in the append_to_response parameter will map to a JSON object in the root of the response with the same name as that field.

When parsing the response into the object, I don't know before hand how many Seasons does a Specific Tv Show has.

The API is not designed to go in blind like that. One option would be to make a request to the get details method which returns a list of the seasons, then make a second request with append_to_response to get the season data. That way you will only request data you know exists.

Okey @travisbell, I will implement it following your advice wink

Cheers!

We're do I get a API Key

@M3nt1r0s0 There's no need to hijack a thread with something unrelated, next time please create a new post.

The steps (with screenshots) to get an API can be found here: https://developers.themoviedb.org/3/getting-started/introduction

Δεν μπορείτε να βρείτε κάποια ταινία ή σειρά; Συνδεθείτε για να τη δημιουργήσετε.

Σε όλες τις σελίδες

s Εστίαση στη μπάρα αναζήτησης
p Άνοιγμα μενού προφίλ
esc Κλείσιμο ανοιχτού παραθύρου
? Άνοιγμα παραθύρου συντομεύσεων πληκτρολογίου

Στις σελίδες μέσων

b Επιστροφή στην προηγούμενη σελίδα(ή στην αρχική σελίδα όταν είναι εφικτό)
e Μετάβαση στη σελίδα επεξεργασίας

Στις σελίδες κύκλων σειρών

(Δεξιό βέλος) Μετάβαση στον επόμενο κύκλο
(Αριστερό βέλος) Μετάβαση στον προηγούμενο κύκλο

Στις σελίδες επεισοδίων σειρών

(Δεξιό βέλος) Μετάβαση στο επόμενο επεισόδιο
(Αριστερό βέλος) Μετάβαση στο προηγούμενο επεισόδιο

Σε όλες τις σελίδες εικόνων

a Άνοιγμα παραθύρου προσθήκης εικόνας

Σε όλες τις σελίδες επεξεργασίας

t Άνοιγμα επιλογέα μετάφρασης
ctrl+ s Υποβολή φόρμας

Στις σελίδες συζήτησης

n Δημιουργία νέας συζήτησης
w Ρύθμιση κατάστασης παρακολούθησης
p Ρύθμιση ως δημόσια/ιδιωτική
c Ρύθμιση ανοίγματος/κλεισίματος
a Άνοιγμα δραστηριότητας
r Απάντηση στη συζήτηση
l Μετάβαση στην τελευταία απάντηση
ctrl+ enter Υποβολή μηνύματος
(Δεξιό βέλος) Επόμενη σελίδα
(Αριστερό βέλος) Προηγούμενη σελίδα

Ρυθμίσεις

Θέλετε να αξιολογήσετε ή να προσθέσετε αυτό το στοιχείο σε μια λίστα;

Σύνδεση