Film Veri Tabanı Desteği

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 yanıt (toplam 1 sayfanın 1.sayfasında)

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.

Bir filmi veya diziyi bulamıyor musun? Eklemek için oturum aç.

Genel

s arama çubuğuna odaklan
p profil menüsünü aç
esc açık bir pencereyi kapat
? klavye kısayol penceresini aç

Medya sayfalarında

b geri git (veya uygulanabilirse ana ekrana)
e sayfayı düzenlemeye git

TV sezonu sayfalarında

(sağa ok) sonraki sezona git
(sol ok) önceki sezona git

TV bölüm sayfalarında

(sağa ok) sonraki bölüme git
(sol ok) önceki bölüme git

Tüm görüntü sayfalarında

a resim ekle penceresini aç

Tüm düzenleme sayfalarında

t çeviri seçiciyi aç
ctrl+ s formu gönder

Tartışma sayfalarında

n yeni tartışma oluştur
w izleme durumunu değiştir
p umumi/hususi değiştir
c kapalı/açık değiştir
a etkinliği aç
r tartışmayı yanıtla
l son yanıta git
ctrl+ enter mesajını gönder
(sağa ok) sonraki sayfa
(sol ok) önceki sayfa

Ayarlar

Bu öğeyi derecelendirmek veya bir listeye eklemek ister misiniz?

Giriş