Поддержка The Movie Database

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 ответов (на странице 1 из 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.

Не можете найти фильм или сериал? Войдите на сайт, чтобы добавить его.

Глобальные

s фокусироваться на панели поиска
p открыть меню профиля
esc закрыть открытое окно
? открыть окно сочетаний клавиш

На страницах медиа

b назад (или выше, если применимо)
e перейти на страницу правки

На страницах сезонов

(стрелка вправо) перейти к следующему сезону
(стрелка влево) перейти к предыдущему сезону

На страницах эпизодов

(стрелка вправо) перейти к следующему эпизоду
(стрелка влево) перейти к предыдущему эпизоду

На всех страницах изображений

a открыть окно добавления изображения

На всех страницах правки

t открыть переключатель переводов
ctrl+ s отправить форму

На страницах обсуждения

n создать новое обсуждение
w сменить статус отслеживания
p публичное/приватное
c закрыть/открыть
a открыть страницу действий
r ответить в обсуждении
l перейти к последнему ответу
ctrl+ enter отправить своё сообщение
(стрелка вправо) следующая страница
(стрелка влево) предыдущая страница

Параметры

Хотите поставить оценку или добавить в список?

Войти