Assistance de TMDB

I had built a film database for my own use in Excel & I had used the old 2.1 API version. The user typed in a film title or part of a title & pressed a button & the user form was then filled with the various film titles that contained the search criteria along with the Rating, Description, Release date & a link to the correct TMDB page. This worked great but how do I get it to work with version 3, I struggled to get it to work before & a work colleague ended up finishing it, now that person is no longer available & after reading all the version 3 info I realise I don't have enough experience to sort this out. Here is some of my original working code for the Excel userform (the API key has been altered), can someone make the necessary changes for?

Private Sub btnSearch_Click()

'Sorts out the columns for the userform & sends the film title & asks for the the film data back from the sub getfilmdata

Me.lbResults.ColumnCount = 5

Me.lbResults.ColumnWidths = "190pt;20pt;500pt;50pt;0pt;"

Me.lbResults.List = GetFilmData(Me.tbSearch.Text)

End Sub

Public Function GetFilmData(strMovie As String) As Variant

'This is the main API code that gets the film results, 5 results from nodes 5,11,13,15,16. It sends the results to the userform.

'If there are no film results then it opens a message box offering the user to try the TV database.

Dim rng() As Variant Dim xml As Object Dim nodes As Object Dim x As Long

With CreateObject("MSXML2.DOMDocument")

.Load "http://api.themoviedb.org/2.1/Movie.search/en/xml/123456789123456789123456789/" & strMovie

Do: DoEvents: Loop Until .readyState = 4

Set nodes = .getelementsbytagname("opensearch:totalResults")

If nodes(0).nodeTypedValue = 0 Then

    If MsgBox("Unable To Find Film, would you like to search for TV series?", vbYesNo + vbQuestion) = vbYes Then

        GetFilmData = GetTvData(strMovie)

        Exit Function

    Else

        GetFilmData = Array("No Results")

        Exit Function

    End If

Else

    Set nodes = .getelementsbytagname("movie")

    ReDim rng(1 To nodes.Length, 1 To 5)

    For x = 0 To nodes.Length - 1
      rng(x + 1, 1) = nodes(x).ChildNodes(5).nodeTypedValue
      rng(x + 1, 2) = nodes(x).ChildNodes(13).nodeTypedValue
      rng(x + 1, 3) = nodes(x)childishness(15).nodeTypedValue
      rng(x + 1, 4) = nodes(x).ChildNodes(16).nodeTypedValue
      rng(x + 1, 5) = nodes(x).ChildNodes(11).nodeTypedValue
    Next x
End If

End With

GetFilmData = rng

End Function

2 réponses (sur la page 1 sur 1)

Jump to last post

Hi Eno,

Unfortunately I don't have anything super helpful to contribute but what I can tell you is that the main difference between 2.1 and v3 is that we're no longer using XML. This means that however you get the data, you'll need to parse the response as a JSON object. I found this Stack Overflow question but don't honestly know if it is any help.

XML and JSON are quite different.

Thanks for your reply. With no formal experience I've pushed myself to the limits to get my original database to work & even then I had some help, but when it eventually worked it was a huge achievement. I hate asking for help & generally soldier on for hours & days at a time which is a great way to learn but this is just a bit too much for me to comprehend. I looked at the link you posted but to be honest I don't know enough to understand the help it contains. I see that the main differences are that JSON replaces XML & that the API TMDB thing uses film IDs. I can't even format my original post so the code looks correct, I need help.

Un film, une émission télévisée ou un artiste est introuvable ? Connectez-vous afin de créer une nouvelle fiche.

Général

s Mettre le curseur dans la barre de recherche
p Ouvrir le menu du profil
esc Fermer une fenêtre ouverte
? Ouvrir la fenêtre des raccourcis clavier

Sur les pages des médias

b Retour (ou vers le parent si faisable)
e Afficher la page de modification

Sur les pages des saisons des émissions télévisées

Afficher la saison suivante (flèche droite)
Afficher la saison précédente (flèche gauche)

Sur les pages des épisodes des émissions télévisées

Afficher l'épisode suivant (flèche droite)
Afficher l'épisode précédent (flèche gauche)

Sur toutes les pages des images / photos

a Ouvrir la fenêtre d'ajout d'image / photo

Sur toutes les pages de modifications

t Ouvrir le sélecteur de traduction
ctrl+ s Envoyer le formulaire

Sur les pages des discussions

n Créer une nouvelle discussion
w Basculer le statut de suivi
p Basculer publique / privée
c Basculer fermer / ouvrir
a Ouvrir l'activité
r Répondre à la discussion
l Afficher la dernière réponse
ctrl+ enter Envoyer votre message
Page suivante (flèche droite)
Page précédente (flèche gauche)

Paramètres

Vous souhaitez évaluer ou ajouter cet élément à une liste ?

Connexion