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.

찾으시는 영화나 TV 프로그램이 없나요? 로그인 하셔서 직접 만들어주세요.

전체

s 검색 바 띄우기
p 프로필 메뉴 열기
esc 열린 창 닫기
? 키보드 단축키 창 열기

미디어 페이지

b 돌아가기
e 편집 페이지로 이동

TV 시즌 페이지

(우 화살표) 다음 시즌으로 가기
(좌 화살표) 이전 시즌으로 가기

TV 에피소드 페이지

(우 화살표) 다음 에피소드로 가기
(좌 화살표) 이전 에피소드로 가기

모든 이미지 페이지

a 이미지 추가 창 열기

모든 편집 페이지

t 번역 선택 열기
ctrl+ s 항목 저장

토론 페이지

n 새 토론 만들기
w 보기 상태
p 공개/비공개 전환
c 열기/닫기 전환
a 활동 열기
r 댓글에 글쓰기
l 마지막 댓글로 가기
ctrl+ enter 회원님의 메세지 제출
(우 화살표) 다음 페이지
(좌 화살표) 이전 페이지

설정

이 항목을 평가하거나 목록에 추가할까요?

로그인