The Movie Database Support Forum

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 Antworten (Seite 1 von 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.

Es fehlt ein Film oder eine Serie? Logge dich ein zum Ergänzen.

Allgemein

s Fokus auf Suchfeld
p Profil öffnen
esc Fenster schließen
? Tastenkürzel anzeigen

Videos

b Zurück
e Bearbeiten

Staffeln

Nächste Staffel
Vorherige Staffel

Episoden

Nächste Episode
Vorherige Episode

Bilder

a Poster oder Hintergrundbild hinzufügen

Editieren

t Sprachauswahl öffnen
ctrl+ s Speichern

Diskussionen

n Neue Diskussion erstellen
w Beobachten an / aus
p Diskussion öffentlich / privat
c Diskussion öffnen / schließen
a Diskussionsverlauf anzeigen
r Auf Diskussion antworten
l Letzte Antwort anzeigen
ctrl+ enter Senden
Nächste Seite
Vorherige Seite

Einstellungen

Diesen Eintrag bewerten oder zu einer Liste hinzufügen?

Anmelden