TMDb の API を使ってTV作品情報(JSON形式)を取得するお勉強 その1
目的
MovieJukeBox は WatTmdb.dll を利用させていただき、TMDb から映画や俳優情報を取得している。しかし、WatTmdb.dll には 24 や Fringe などのTVシリーズ情報を TMDb から取得する機能を実装していないので MovieJukeBox ではTVシリーズの情報を管理していない。そこで、TMDb API を使用して、TMDb からTVシリーズ情報を取得するクラスを作ってみる。言語はVB。DLL化の方法はわからないので、App_Codeフォルダに ClassTMDbTV.vb として作成する。
また、JSON のデシリアライズについてもよくわかっていないので、これを機に少し勉強してみる。
「勉強」と書いているとおり、勉強なので正しい使い方をしていないなど、あると思う。これはこの記事に限らず言えることだけど。
事前準備
APIキーの取得
TMDb API を使用するにはアカウント登録し、APIキーを取得する。TMDb API のドキュメント
- The Movie Database API · Apiary
http://docs.themoviedb.apiary.io/ - The Movie Database API · Apiary - searchtv-
http://docs.themoviedb.apiary.io/reference/search/searchtv - The Movie Database API · Apiary - TV -
http://docs.themoviedb.apiary.io/reference/tv/get - The Movie Database API · Apiary - TV Seasons -
http://docs.themoviedb.apiary.io/reference/tv-seasons - The Movie Database API · Apiary - TV Episodes -
http://docs.themoviedb.apiary.io/reference/tv-episodes
TV情報取得のためのご作法
URLパラメータでパラメータを指定すると、JSON形式で返してくれる。タイトルが fringe を検索
https://api.themoviedb.org/3/search/tv?api_key=APIKEY&query=fringe↓
{"page":1,"results":[{"backdrop_path":"/5fdhXHOfqhbW1XYswNk40nwd3oF.jpg","id":1705,"original_name":"Fringe","first_air_date":"2008-09-09","origin_country":["US","CA"],"poster_path":"/5GNoi8evnGGdOrFioTx3lAGFUgI.jpg","popularity":0.995520983851327,"name":"Fringe","vote_average":8.5,"vote_count":27},{"backdrop_path":null,"id":58595,"original_name":"Before the Fringe","first_air_date":null,"origin_country":[],"poster_path":null,"popularity":2.36108671507542e-26,"name":"Before the Fringe","vote_average":0.0,"vote_count":0},{"backdrop_path":null,"id":44042,"original_name":"On the Fringe 1987","first_air_date":null,"origin_country":["SG"],"poster_path":null,"popularity":2.28125645884409e-26,"name":"On the Fringe 1987","vote_average":0.0,"vote_count":0},{"backdrop_path":null,"id":42061,"original_name":"On the Fringe 2011","first_air_date":null,"origin_country":["SG"],"poster_path":null,"popularity":7.76882027124243e-24,"name":"On the Fringe 2011","vote_average":0.0,"vote_count":0},{"backdrop_path":null,"id":31912,"original_name":"On the Fringe","first_air_date":null,"origin_country":[],"poster_path":null,"popularity":2.36108671507542e-26,"name":"On the Fringe","vote_average":0.0,"vote_count":0},{"backdrop_path":null,"id":24598,"original_name":"Before The Fringe","first_air_date":null,"origin_country":["GB"],"poster_path":null,"popularity":8.1664432072667e-22,"name":"Before The Fringe","vote_average":0.0,"vote_count":0}],"total_pages":1,"total_results":6}
6作品が JSON で返却される。
複数該当がある場合、XBMC(Kodi)のような利用者に選択させるインターフェースが必要になるかな。
TMDb で fringe を検索した結果も同様に6作品が表示される。
https://www.themoviedb.org/search?query=fringe
タイトルが fringe で 放送開始年 が 2008 を検索
ここで検索したいのは、オリビア・ダナムが主人公の Fringe なので、放送開始年が 2008 で絞り込むために first_air_date_year に 2008 を指定する。同じ放送開始年で同じタイトルの作品はないと思うので、放送開始年を指定すれば検索結果を一意にできると思う。https://api.themoviedb.org/3/search/tv?api_key=APIKEY&query=fringe&first_air_date_year=2008
↓
{"page":1,"results":[{"backdrop_path":"/5fdhXHOfqhbW1XYswNk40nwd3oF.jpg","id":1705,"original_name":"Fringe","first_air_date":"2008-09-09","origin_country":["US","CA"],"poster_path":"/5GNoi8evnGGdOrFioTx3lAGFUgI.jpg","popularity":0.995520983851327,"name":"Fringe","vote_average":8.5,"vote_count":27}],"total_pages":1,"total_results":1}
id が 1705 の基本情報を取得
https://api.themoviedb.org/3/tv/1705?api_key=APIKEY↓
{"backdrop_path":"/5fdhXHOfqhbW1XYswNk40nwd3oF.jpg","created_by":[{"id":15344,"name":"J.J. Abrams","profile_path":"/7tOozDlTGNpCxFQZ6AjSju7uehf.jpg"},{"id":15345,"name":"Alex Kurtzman","profile_path":"/5cO0ug7TtRqzbYU4ukKzUzfuUk.jpg"},{"id":15346,"name":"Roberto Orci","profile_path":"/5SNw3lnRD6UQJFy52IH3MdFGIrs.jpg"}],"episode_run_time":[60],"first_air_date":"2008-09-09","genres":[{"id":18,"name":"Drama"},{"id":9648,"name":"Mystery"}],"homepage":"http://www.fox.com/fringe","id":1705,"in_production":false,"languages":["en"],"last_air_date":"2013-01-18","name":"Fringe","networks":[{"id":19,"name":"Fox Broadcasting Company"}],"number_of_episodes":100,"number_of_seasons":5,"original_name":"Fringe","origin_country":["US","CA"],"overview":"Fringe is an American science fiction television series that follows Olivia Dunham, Peter Bishop, and Walter Bishop, members of a Federal Bureau of Investigation \"Fringe Division\" team based in Boston, Massachusetts under the supervision of Homeland Security. The team uses \"fringe\" science and FBI investigative techniques to investigate a series of unexplained, often ghastly occurrences, which are related to mysteries surrounding a parallel universe. The series has been described as a hybrid of The X-Files, Altered States, and The Twilight Zone.","popularity":0.995520983851327,"poster_path":"/5GNoi8evnGGdOrFioTx3lAGFUgI.jpg","production_companies":[{"name":"Warner Bros. Television","id":1957}],"seasons":[{"air_date":"2009-10-05","id":4689,"poster_path":"/cYa5bk7yUAB7Lq97G9BwxC3BrYO.jpg","season_number":0},{"air_date":"2008-09-09","id":4690,"poster_path":"/kMmeA68BBA6zcwaAcrcL3oICAY6.jpg","season_number":1},{"air_date":"2009-09-17","id":4691,"poster_path":"/vZM823Tk9XjrI0Yd4q9yDlVRqRc.jpg","season_number":2},{"air_date":"2010-09-23","id":4692,"poster_path":"/9TB6bHGmqRNyUnI40c9eBNBvW7V.jpg","season_number":3},{"air_date":"2011-09-23","id":4693,"poster_path":"/43pwP3fZp2P61W9yK6kJQZudHrX.jpg","season_number":4},{"air_date":"2012-09-28","id":4694,"poster_path":"/nypm5lQuouvw1wGs9q2a2ZMEGoc.jpg","season_number":5}],"status":"Ended","vote_average":8.5,"vote_count":27}
id が 1705 で シーズンが 1 のシーズン情報を取得
https://api.themoviedb.org/3/tv/1705/season/1?api_key=APIKEY↓
{"air_date":"2008-09-09","episodes":[{"air_date":"2008-09-09","crew":[{"id":1213537,"credit_id":"525710e519c295731c03397a","name":"Alex Graves","department":"Directing","job":"Director","profile_path":null},{"id":15346,"credit_id":"525710e419c295731c0338ee","name":"Roberto Orci","department":"Writing","job":"Writer","profile_path":"/5SNw3lnRD6UQJFy52IH3MdFGIrs.jpg"},{"id":15345,"credit_id":"525710e419c295731c0338ae","name":"Alex Kurtzman","department":"Writing","job":"Writer","profile_path":"/5cO0ug7TtRqzbYU4ukKzUzfuUk.jpg"},{"id":15344,"credit_id":"525710e519c295731c033952","name":"J.J. Abrams","department":"Writing","job":"Writer","profile_path":"/7tOozDlTGNpCxFQZ6AjSju7uehf.jpg"}],"episode_number":1,"guest_stars":[{"id":12978,"name":"Peter Outerbridge","credit_id":"525710e419c295731c0337b2","character":"","order":0,"profile_path":"/nRGnRHtjtWnowESjTyN7fnOCp6f.jpg"},{"id":55861,"name":"Kirk Acevedo","credit_id":"525710e419c295731c0337e4","character":"","order":1,"profile_path":"/9CTkCXyKQrHTFZWFN3JtDM2mF0U.jpg"},{"id":136530,"name":"Mark Valley","credit_id":"525710e419c295731c03380a","character":"","order":2,"profile_path":"/bWCr7EhKM0aB19fONmeGcetMlQa.jpg"},{"id":129101,"name":"Lance Reddick","credit_id":"525710e419c295731c03383c","character":"","order":3,"profile_path":"/5t4j7zvsjG5UyVxBJzly5OUMR3x.jpg"},{"id":142294,"name":"Jason Butler
以下省略
id が 1705 で シーズンが 1 で エピソードが 1 エピソード情報を取得
https://api.themoviedb.org/3/tv/1705/season/1/episode/1?api_key=APIKEY↓
{"air_date":"2008-09-09","crew":[{"id":1213537,"credit_id":"525710e519c295731c03397a","name":"Alex Graves","department":"Directing","job":"Director","profile_path":null},{"id":15346,"credit_id":"525710e419c295731c0338ee","name":"Roberto Orci","department":"Writing","job":"Writer","profile_path":"/5SNw3lnRD6UQJFy52IH3MdFGIrs.jpg"},{"id":15345,"credit_id":"525710e419c295731c0338ae","name":"Alex Kurtzman","department":"Writing","job":"Writer","profile_path":"/5cO0ug7TtRqzbYU4ukKzUzfuUk.jpg"},{"id":15344,"credit_id":"525710e519c295731c033952","name":"J.J. Abrams","department":"Writing","job":"Writer","profile_path":"/7tOozDlTGNpCxFQZ6AjSju7uehf.jpg"}],"episode_number":1,"guest_stars":[{"id":12978,"name":"Peter Outerbridge","credit_id":"525710e419c295731c0337b2","character":"","order":0,"profile_path":"/nRGnRHtjtWnowESjTyN7fnOCp6f.jpg"},{"id":55861,"name":"Kirk Acevedo","credit_id":"525710e419c295731c0337e4","character":"","order":1,"profile_path":"/9CTkCXyKQrHTFZWFN3JtDM2mF0U.jpg"},{"id":136530,"name":"Mark Valley","credit_id":"525710e419c295731c03380a","character":"","order":2,"profile_path":"/bWCr7EhKM0aB19fONmeGcetMlQa.jpg"},{"id":129101,"name":"Lance Reddick","credit_id":"525710e419c295731c03383c","character":"","order":3,"profile_path":"/5t4j7zvsjG5UyVxBJzly5OUMR3x.jpg"},{"id":142294,"name":"Jason Butler Harner","credit_id":"525710e419c295731c033868","character":"","order":4,"profile_path":"/nKGxvOnWjOJl9fCnLQuvAkWj3cX.jpg"}],"name":"Pilot","overview":"When all the passengers on a plane die, FBI agent Olivia Dunham investigates the events and her partner almost dies. A desperate Olivia looks for help from Dr. Walter Bishop who has been institutionalized. Olivia, Dr. Bishop and his son Peter begin to discover what really happened on Flight 627 and begin to uncover a larger truth.","id":87875,"production_code":null,"season_number":1,"still_path":"/aPVxQJDzmL1TuW3DYUCHNVwHkgF.jpg","vote_average":0.0,"vote_count":0}
ソース
入力項目のエラーチェックとか、すべての情報を取得するとかまだやってない。とりあえず、キーワードからTV情報を取得できるか?をテストするだけ。- GetTMDbJSON
パラメータで指定されたURLの JSON をバイト列で取得し、UTF-8でエンコードする。それを System.Web.Script.Serialization の JavaScriptSerializer でデシリアライズし、ハッシュに入れてそれをオブジェクト化する。 - SearchTMDbTVID
タイトルと放送開始年をキーに、TMDbを検索する。 - GetTMDbTV
TV の ID をキーにTV作品の基本情報を取得する。 - GetTMDbTVSeason
TV の ID と シーズン番号をキーにシーズン情報を取得する。 - GetTMDbTVSeasonEpisode
TV の ID と シーズン番号とエピソード番号をキーにエピソード情報を取得する。
ClassTMDbTV.vb
Imports System.Net
Imports System.Web.Script.Serialization
Imports System.Data
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Namespace MJBTMDb.V3
Public Class ClassTMDbTV
Public Shared Function GetTMDbJSON(ByVal TargetURL As String) As Object
Dim objWeb As WebClient = New WebClient()
Dim objSrializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim objEncode As Encoding = Encoding.UTF8
Dim byteResult As Byte()
byteResult = objWeb.DownloadData(TargetURL)
Dim UT8byteResult As String = objEncode.GetString(byteResult)
Dim Hash As Hashtable = objSrializer.Deserialize(Of Hashtable)(UT8byteResult)
Dim objresults As Object = Hash
Return objresults
End Function
Public Shared Function SearchTMDbTVID(ByVal Title As String, first_air_date_year As String, language As String) As Object
Dim TMDbSearchTVURL As String = "https://api.themoviedb.org/3/search/tv?api_key="
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String
If first_air_date_year = "" Then
TargetUrl = TMDbSearchTVURL + tmdbAPIKey + "&query=" + Title + "&language=" + language
Else
TargetUrl = TMDbSearchTVURL + tmdbAPIKey + "&query=" + Title + "&language=" + language + "&first_air_date_year=" + first_air_date_year
End If
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTV(ByVal TMDbTVID As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTVSeason(ByVal TMDbTVID As String, SeasonNumber As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "/season/" + SeasonNumber + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTVSeasonEpisode(ByVal TMDbTVID As String, SeasonNumber As String, EpisodeNumber As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "/season/" + SeasonNumber + "/episode/" + EpisodeNumber + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
End Class
End Namespace
Imports System.Web.Script.Serialization
Imports System.Data
Imports Microsoft.VisualBasic
Imports System.Collections.Generic
Namespace MJBTMDb.V3
Public Class ClassTMDbTV
Public Shared Function GetTMDbJSON(ByVal TargetURL As String) As Object
Dim objWeb As WebClient = New WebClient()
Dim objSrializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim objEncode As Encoding = Encoding.UTF8
Dim byteResult As Byte()
byteResult = objWeb.DownloadData(TargetURL)
Dim UT8byteResult As String = objEncode.GetString(byteResult)
Dim Hash As Hashtable = objSrializer.Deserialize(Of Hashtable)(UT8byteResult)
Dim objresults As Object = Hash
Return objresults
End Function
Public Shared Function SearchTMDbTVID(ByVal Title As String, first_air_date_year As String, language As String) As Object
Dim TMDbSearchTVURL As String = "https://api.themoviedb.org/3/search/tv?api_key="
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String
If first_air_date_year = "" Then
TargetUrl = TMDbSearchTVURL + tmdbAPIKey + "&query=" + Title + "&language=" + language
Else
TargetUrl = TMDbSearchTVURL + tmdbAPIKey + "&query=" + Title + "&language=" + language + "&first_air_date_year=" + first_air_date_year
End If
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTV(ByVal TMDbTVID As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTVSeason(ByVal TMDbTVID As String, SeasonNumber As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "/season/" + SeasonNumber + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
Public Shared Function GetTMDbTVSeasonEpisode(ByVal TMDbTVID As String, SeasonNumber As String, EpisodeNumber As String, language As String) As Object
Dim TMDbTVAPIGETURL As String = ConfigurationManager.AppSettings("TMDbTVAPIGETURL")
Dim tmdbAPIKey As String = ConfigurationManager.AppSettings("tmdbAPIKey")
Dim TargetUrl As String = TMDbTVAPIGETURL + TMDbTVID + "/season/" + SeasonNumber + "/episode/" + EpisodeNumber + "?api_key=" + tmdbAPIKey + "&language=" + language
Return GetTMDbJSON(TargetUrl)
End Function
End Class
End Namespace
TMDbTVTest2.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="TMDbTVTest2.aspx.vb" Inherits="TMDbTVTest2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBoxTitle" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBoxfirst_air_date_year" runat="server"></asp:TextBox>
<asp:DropDownList ID="DropDownListLanguage" runat="server">
<asp:ListItem Selected="True" Value="en"></asp:ListItem>
<asp:ListItem Value="ja"></asp:ListItem>
<asp:ListItem Value="de"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="ButtonTVSearch" runat="server" Text="" style="height: 21px" />
<br />
<h3>SearchTMDbTVID</h3>
<asp:GridView ID="GridViewTVID" runat="server">
</asp:GridView>
<asp:DataList ID="DataListTVID" runat="server" RepeatColumns="10" RepeatDirection="Horizontal">
<ItemTemplate>
<div>
<asp:Image ID="ImageTVIDPoster" runat="server" ImageUrl='<%# eval("TVIDPosterPathW150") %>' />
<br />
TMDbTVID:<asp:Label ID="LabelTVID" runat="server" Text='<%# eval("TMDbTVID") %>'></asp:Label>
<br />
<asp:Label ID="Labeloriginal_name" runat="server" Text='<%# eval("original_name") %>'></asp:Label>
<br />
<asp:Label ID="Labelfirst_air_date" runat="server" Text='<%# eval("first_air_date") %>'></asp:Label>
<br />
<asp:Label ID="Labelname" runat="server" Text='<%# eval("name") %>'></asp:Label>
</div>
<asp:Image ID="ImageTVIDBackdrop" runat="server" ImageUrl='<%# eval("TVIDBackdropPathW150") %>' />
<asp:Label ID="LabelPosterW300" runat="server" Text='<%# eval("TVIDPosterPathW300") %>' Visible="False"></asp:Label>
<asp:Label ID="LabelBackdropW600" runat="server" Text='<%# eval("TVIDBackdropPathW600") %>' Visible="False"></asp:Label>
<br />
<asp:Button ID="ButtonSelect" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<br />
<h3>SearchTMDbTVID</h3>
TMDbTVID:<asp:Label ID="LabelTMDbTVIDSearchResult" runat="server"></asp:Label>
<br />
original_name:<asp:Label ID="Labeloriginal_nameSearchResult" runat="server"></asp:Label>
<br />
name:<asp:Label ID="LabelnameSearchResult" runat="server"></asp:Label>
<br />
<asp:Image ID="ImagePosterSearchResult" runat="server" />
<asp:Image ID="ImageBackdropSearchResult" runat="server" />
<br />
<h3>GetTMDbTV</h3>
backdrop_path:<asp:Label ID="LabelGetTMDbTVbackdrop_path" runat="server"></asp:Label>
<br />
episode_run_time:<asp:Label ID="LabelGetTMDbTVepisode_run_time" runat="server"></asp:Label>
<br />
first_air_date:<asp:Label ID="LabelGetTMDbTVfirst_air_date" runat="server"></asp:Label>
<br />
homepage:<asp:Label ID="LabelGetTMDbTVhomepage" runat="server"></asp:Label>
<br />
id:<asp:Label ID="LabelGetTMDbTVid" runat="server"></asp:Label>
<br />
in_production:<asp:Label ID="LabelGetTMDbTVin_production" runat="server"></asp:Label>
<br />
last_air_date:<asp:Label ID="LabelGetTMDbTVlast_air_date" runat="server"></asp:Label>
<br />
name:<asp:Label ID="LabelGetTMDbTVname" runat="server"></asp:Label>
<br />
number_of_episodes:<asp:Label ID="LabelGetTMDbTVnumber_of_episodes" runat="server"></asp:Label>
<br />
number_of_seasons:<asp:Label ID="LabelGetTMDbTVnumber_of_seasons" runat="server"></asp:Label>
<br />
original_name:<asp:Label ID="LabelGetTMDbTVoriginal_name" runat="server"></asp:Label>
<br />
overview:<asp:Label ID="LabelGetTMDbTVoverview" runat="server"></asp:Label>
<br />
popularity:<asp:Label ID="LabelGetTMDbTVpopularity" runat="server"></asp:Label>
<br />
poster_path:<asp:Label ID="LabelGetTMDbTVposter_path" runat="server"></asp:Label>
<br />
status:<asp:Label ID="LabelGetTMDbTVstatus" runat="server"></asp:Label>
<br />
vote_average:<asp:Label ID="LabelGetTMDbTVvote_average" runat="server"></asp:Label>
<br />
vote_count:<asp:Label ID="LabelGetTMDbTVvote_count" runat="server"></asp:Label>
<br />
<h3></h3>
<asp:DataList ID="DataListSeasons" runat="server" RepeatColumns="10" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="ImageSeason" runat="server" ImageUrl='<%# eval("TVSeasonPosterPathW150") %>' />
<br />
SeasonID:<asp:Label ID="LabelSeasonID" runat="server" Text='<%# eval("TMDbTVSeasonID") %>'></asp:Label>
<br />
SeasonNumber:<asp:Label ID="Labelseason_number" runat="server" Text='<%# eval("season_number") %>'></asp:Label>
<br />
<asp:Label ID="Labelair_date" runat="server" Text='<%# eval("air_date") %>'></asp:Label>
<br />
<asp:Label ID="Labelposter_path" runat="server" Text='<%# eval("poster_path") %>' Visible="False"></asp:Label>
<br />
<asp:Button ID="ButtonGetSeason" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<h3></h3>
SeasonNumber:<asp:Label ID="Labelseason_number" runat="server"></asp:Label>
<br />
:<asp:Label ID="Labelair_dateSeason" runat="server"></asp:Label>
<br />
Overview of Season:<asp:Label ID="LabelOverViewSeason" runat="server"></asp:Label>
<br />
<h3></h3>
<asp:DataList ID="DataListEpisodes" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# eval("TVEpisodestill_pathW150") %>' />
<br />
SeasonNumber:<asp:Label ID="LabelSeasonNumber" runat="server" Text='<%# eval("season_number") %>'></asp:Label>
<br />
EpisodeID:<asp:Label ID="LabelTMDbTVEpisodeID" runat="server" Text='<%# eval("TMDbTVEpisodeID") %>'></asp:Label>
<br />
EpisodeNumber:<asp:Label ID="LabelEpisode_number" runat="server" Text='<%# eval("Episode_number") %>'></asp:Label>
<br />
Name:<asp:Label ID="Labelname" runat="server" Text='<%# eval("name") %>'></asp:Label>
<br />
<asp:Label ID="Labelair_date" runat="server" Text='<%# eval("air_date") %>'></asp:Label>
<br />
<asp:Button ID="ButtonGetEpisode" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<br />
<h3></h3>
SeasonNumber:<asp:Label ID="LabelSeasonNUmber" runat="server"></asp:Label>
<br />
:<asp:Label ID="LabelEpisode_number" runat="server"></asp:Label>
<br />
EpisodeName:<asp:Label ID="LabelEpisodeNmae" runat="server"></asp:Label>
<br />
EpisodeID:<asp:Label ID="LabelEpisodeID" runat="server"></asp:Label>
<br />
production_code:<br />
still_path:<br />
vote_average:<br />
vote_count:<br />
air_date:<br />
<br />
<br />
</div>
</form>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBoxTitle" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBoxfirst_air_date_year" runat="server"></asp:TextBox>
<asp:DropDownList ID="DropDownListLanguage" runat="server">
<asp:ListItem Selected="True" Value="en"></asp:ListItem>
<asp:ListItem Value="ja"></asp:ListItem>
<asp:ListItem Value="de"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="ButtonTVSearch" runat="server" Text="" style="height: 21px" />
<br />
<h3>SearchTMDbTVID</h3>
<asp:GridView ID="GridViewTVID" runat="server">
</asp:GridView>
<asp:DataList ID="DataListTVID" runat="server" RepeatColumns="10" RepeatDirection="Horizontal">
<ItemTemplate>
<div>
<asp:Image ID="ImageTVIDPoster" runat="server" ImageUrl='<%# eval("TVIDPosterPathW150") %>' />
<br />
TMDbTVID:<asp:Label ID="LabelTVID" runat="server" Text='<%# eval("TMDbTVID") %>'></asp:Label>
<br />
<asp:Label ID="Labeloriginal_name" runat="server" Text='<%# eval("original_name") %>'></asp:Label>
<br />
<asp:Label ID="Labelfirst_air_date" runat="server" Text='<%# eval("first_air_date") %>'></asp:Label>
<br />
<asp:Label ID="Labelname" runat="server" Text='<%# eval("name") %>'></asp:Label>
</div>
<asp:Image ID="ImageTVIDBackdrop" runat="server" ImageUrl='<%# eval("TVIDBackdropPathW150") %>' />
<asp:Label ID="LabelPosterW300" runat="server" Text='<%# eval("TVIDPosterPathW300") %>' Visible="False"></asp:Label>
<asp:Label ID="LabelBackdropW600" runat="server" Text='<%# eval("TVIDBackdropPathW600") %>' Visible="False"></asp:Label>
<br />
<asp:Button ID="ButtonSelect" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<br />
<h3>SearchTMDbTVID</h3>
TMDbTVID:<asp:Label ID="LabelTMDbTVIDSearchResult" runat="server"></asp:Label>
<br />
original_name:<asp:Label ID="Labeloriginal_nameSearchResult" runat="server"></asp:Label>
<br />
name:<asp:Label ID="LabelnameSearchResult" runat="server"></asp:Label>
<br />
<asp:Image ID="ImagePosterSearchResult" runat="server" />
<asp:Image ID="ImageBackdropSearchResult" runat="server" />
<br />
<h3>GetTMDbTV</h3>
backdrop_path:<asp:Label ID="LabelGetTMDbTVbackdrop_path" runat="server"></asp:Label>
<br />
episode_run_time:<asp:Label ID="LabelGetTMDbTVepisode_run_time" runat="server"></asp:Label>
<br />
first_air_date:<asp:Label ID="LabelGetTMDbTVfirst_air_date" runat="server"></asp:Label>
<br />
homepage:<asp:Label ID="LabelGetTMDbTVhomepage" runat="server"></asp:Label>
<br />
id:<asp:Label ID="LabelGetTMDbTVid" runat="server"></asp:Label>
<br />
in_production:<asp:Label ID="LabelGetTMDbTVin_production" runat="server"></asp:Label>
<br />
last_air_date:<asp:Label ID="LabelGetTMDbTVlast_air_date" runat="server"></asp:Label>
<br />
name:<asp:Label ID="LabelGetTMDbTVname" runat="server"></asp:Label>
<br />
number_of_episodes:<asp:Label ID="LabelGetTMDbTVnumber_of_episodes" runat="server"></asp:Label>
<br />
number_of_seasons:<asp:Label ID="LabelGetTMDbTVnumber_of_seasons" runat="server"></asp:Label>
<br />
original_name:<asp:Label ID="LabelGetTMDbTVoriginal_name" runat="server"></asp:Label>
<br />
overview:<asp:Label ID="LabelGetTMDbTVoverview" runat="server"></asp:Label>
<br />
popularity:<asp:Label ID="LabelGetTMDbTVpopularity" runat="server"></asp:Label>
<br />
poster_path:<asp:Label ID="LabelGetTMDbTVposter_path" runat="server"></asp:Label>
<br />
status:<asp:Label ID="LabelGetTMDbTVstatus" runat="server"></asp:Label>
<br />
vote_average:<asp:Label ID="LabelGetTMDbTVvote_average" runat="server"></asp:Label>
<br />
vote_count:<asp:Label ID="LabelGetTMDbTVvote_count" runat="server"></asp:Label>
<br />
<h3></h3>
<asp:DataList ID="DataListSeasons" runat="server" RepeatColumns="10" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="ImageSeason" runat="server" ImageUrl='<%# eval("TVSeasonPosterPathW150") %>' />
<br />
SeasonID:<asp:Label ID="LabelSeasonID" runat="server" Text='<%# eval("TMDbTVSeasonID") %>'></asp:Label>
<br />
SeasonNumber:<asp:Label ID="Labelseason_number" runat="server" Text='<%# eval("season_number") %>'></asp:Label>
<br />
<asp:Label ID="Labelair_date" runat="server" Text='<%# eval("air_date") %>'></asp:Label>
<br />
<asp:Label ID="Labelposter_path" runat="server" Text='<%# eval("poster_path") %>' Visible="False"></asp:Label>
<br />
<asp:Button ID="ButtonGetSeason" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<h3></h3>
SeasonNumber:<asp:Label ID="Labelseason_number" runat="server"></asp:Label>
<br />
:<asp:Label ID="Labelair_dateSeason" runat="server"></asp:Label>
<br />
Overview of Season:<asp:Label ID="LabelOverViewSeason" runat="server"></asp:Label>
<br />
<h3></h3>
<asp:DataList ID="DataListEpisodes" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# eval("TVEpisodestill_pathW150") %>' />
<br />
SeasonNumber:<asp:Label ID="LabelSeasonNumber" runat="server" Text='<%# eval("season_number") %>'></asp:Label>
<br />
EpisodeID:<asp:Label ID="LabelTMDbTVEpisodeID" runat="server" Text='<%# eval("TMDbTVEpisodeID") %>'></asp:Label>
<br />
EpisodeNumber:<asp:Label ID="LabelEpisode_number" runat="server" Text='<%# eval("Episode_number") %>'></asp:Label>
<br />
Name:<asp:Label ID="Labelname" runat="server" Text='<%# eval("name") %>'></asp:Label>
<br />
<asp:Label ID="Labelair_date" runat="server" Text='<%# eval("air_date") %>'></asp:Label>
<br />
<asp:Button ID="ButtonGetEpisode" runat="server" Text="" />
</ItemTemplate>
</asp:DataList>
<br />
<h3></h3>
SeasonNumber:<asp:Label ID="LabelSeasonNUmber" runat="server"></asp:Label>
<br />
:<asp:Label ID="LabelEpisode_number" runat="server"></asp:Label>
<br />
EpisodeName:<asp:Label ID="LabelEpisodeNmae" runat="server"></asp:Label>
<br />
EpisodeID:<asp:Label ID="LabelEpisodeID" runat="server"></asp:Label>
<br />
production_code:<br />
still_path:<br />
vote_average:<br />
vote_count:<br />
air_date:<br />
<br />
<br />
</div>
</form>
</body>
</html>
TMDbTVTest2.aspx.vb
Imports System.Data
Imports MJBTMDb.V3
Partial Class TMDbTVTest2
Inherits System.Web.UI.Page
Protected Sub ButtonTVSearch_Click(sender As Object, e As EventArgs) Handles ButtonTVSearch.Click
LabelTMDbTVIDSearchResult.Text = ""
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim Title As String = TextBoxTitle.Text
Dim first_air_date_year As String = TextBoxfirst_air_date_year.Text
Dim SearchResults As Object = ClassTMDbTV.SearchTMDbTVID(Title, first_air_date_year, DropDownListLanguage.SelectedValue)
Dim TMDbTVID As Object = SearchResults("results")
Dim total_pages As Object = SearchResults("total_pages")
Dim total_results As Object = SearchResults("total_results")
If TMDbTVID.length <> 0 Then
Dim tableTVID As New DataTable
tableTVID.Columns.Add("TMDbTVID")
tableTVID.Columns.Add("backdrop_path")
tableTVID.Columns.Add("original_name")
tableTVID.Columns.Add("first_air_date")
tableTVID.Columns.Add("poster_path")
tableTVID.Columns.Add("popularity")
tableTVID.Columns.Add("name")
tableTVID.Columns.Add("vote_average")
tableTVID.Columns.Add("vote_count")
tableTVID.Columns.Add("TVIDPosterPathW150")
tableTVID.Columns.Add("TVIDBackdropPathW150")
tableTVID.Columns.Add("TVIDPosterPathW300")
tableTVID.Columns.Add("TVIDBackdropPathW600")
For Each item In TMDbTVID
'1
If TMDbTVID.length = 1 Then
LabelTMDbTVIDSearchResult.Text = item("id")
Labeloriginal_nameSearchResult.Text = item("original_name")
LabelnameSearchResult.Text = item("name")
ImageBackdropSearchResult.ImageUrl = ImageURLW600 + item("backdrop_path")
ImagePosterSearchResult.ImageUrl = ImageURLW300 + item("poster_path")
Dim objTMDbTV As Object = ClassTMDbTV.GetTMDbTV(item("id"), DropDownListLanguage.SelectedValue)
LabelGetTMDbTVbackdrop_path.Text = objTMDbTV("backdrop_path")
LabelGetTMDbTVfirst_air_date.Text = objTMDbTV("first_air_date")
LabelGetTMDbTVhomepage.Text = objTMDbTV("homepage")
LabelGetTMDbTVid.Text = objTMDbTV("id")
LabelGetTMDbTVin_production.Text = objTMDbTV("production")
LabelGetTMDbTVlast_air_date.Text = objTMDbTV("last_air_date")
LabelGetTMDbTVname.Text = objTMDbTV("name")
LabelGetTMDbTVnumber_of_episodes.Text = ("number_of_episodes")
LabelGetTMDbTVnumber_of_seasons.Text = objTMDbTV("number_of_seasons")
LabelGetTMDbTVoriginal_name.Text = objTMDbTV("original_name")
LabelGetTMDbTVoverview.Text = objTMDbTV("overview")
LabelGetTMDbTVpopularity.Text = objTMDbTV("popularity")
LabelGetTMDbTVposter_path.Text = objTMDbTV("poster_path")
LabelGetTMDbTVstatus.Text = objTMDbTV("status")
LabelGetTMDbTVvote_average.Text = objTMDbTV("vote_average")
LabelGetTMDbTVvote_count.Text = objTMDbTV("vote_count")
End If
Dim rowTVID = tableTVID.NewRow()
rowTVID("TMDbTVID") = item("id")
rowTVID("backdrop_path") = item("backdrop_path")
rowTVID("original_name") = item("original_name")
rowTVID("first_air_date") = item("first_air_date")
rowTVID("poster_path") = item("poster_path")
rowTVID("popularity") = item("popularity")
rowTVID("name") = item("name")
rowTVID("vote_average") = item("vote_average")
rowTVID("vote_count") = item("vote_count")
rowTVID("TVIDPosterPathW150") = ImageURLW150 + item("poster_path")
rowTVID("TVIDBackdropPathW150") = ImageURLW150 + item("backdrop_path")
rowTVID("TVIDPosterPathW300") = ImageURLW300 + item("poster_path")
rowTVID("TVIDBackdropPathW600") = ImageURLW600 + item("backdrop_path")
tableTVID.Rows.Add(rowTVID)
Next
GridViewTVID.DataSource = tableTVID
GridViewTVID.DataBind()
DataListTVID.DataSource = tableTVID
DataListTVID.DataBind()
End If
End Sub
Protected Sub DataListTVID_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListTVID.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
Dim objLabelTVID As Object = item.FindControl("LabelTVID")
LabelTMDbTVIDSearchResult.Text = objLabelTVID.text
Dim objLabeloriginal_name As Object = item.FindControl("Labeloriginal_name")
Labeloriginal_nameSearchResult.Text = objLabeloriginal_name.text
Dim objLabelname As Object = item.FindControl("Labelname")
LabelnameSearchResult.Text = objLabelname.text
Dim objLabelPosterW300 As Object = item.FindControl("LabelPosterW300")
ImagePosterSearchResult.ImageUrl = objLabelPosterW300.text
Dim objLabelBackdropW600 As Object = item.FindControl("LabelBackdropW600")
ImageBackdropSearchResult.ImageUrl = objLabelBackdropW600.text
'
Dim objTMDbTV As Object = ClassTMDbTV.GetTMDbTV(objLabelTVID.text, DropDownListLanguage.SelectedValue)
LabelGetTMDbTVbackdrop_path.Text = objTMDbTV("backdrop_path")
LabelGetTMDbTVfirst_air_date.Text = objTMDbTV("first_air_date")
LabelGetTMDbTVhomepage.Text = objTMDbTV("homepage")
LabelGetTMDbTVid.Text = objTMDbTV("id")
LabelGetTMDbTVin_production.Text = objTMDbTV("production")
LabelGetTMDbTVlast_air_date.Text = objTMDbTV("last_air_date")
LabelGetTMDbTVname.Text = objTMDbTV("name")
LabelGetTMDbTVnumber_of_episodes.Text = ("number_of_episodes")
LabelGetTMDbTVnumber_of_seasons.Text = objTMDbTV("number_of_seasons")
LabelGetTMDbTVoriginal_name.Text = objTMDbTV("original_name")
LabelGetTMDbTVoverview.Text = objTMDbTV("overview")
LabelGetTMDbTVpopularity.Text = objTMDbTV("popularity")
LabelGetTMDbTVposter_path.Text = objTMDbTV("poster_path")
LabelGetTMDbTVstatus.Text = objTMDbTV("status")
LabelGetTMDbTVvote_average.Text = objTMDbTV("vote_average")
LabelGetTMDbTVvote_count.Text = objTMDbTV("vote_count")
'
Dim tableTMDbTVGenres As New DataTable
tableTMDbTVGenres.Columns.Add("")
tableTMDbTVGenres.Columns.Add("")
tableTMDbTVGenres.Columns.Add("")
'
Dim objSeasons As Object = objTMDbTV("seasons")
If objSeasons.length <> 0 Then
Dim tableTVSeason As New DataTable
tableTVSeason.Columns.Add("air_date")
tableTVSeason.Columns.Add("TMDbTVSeasonID")
tableTVSeason.Columns.Add("poster_path")
tableTVSeason.Columns.Add("season_number")
tableTVSeason.Columns.Add("TVSeasonPosterPathW150")
tableTVSeason.Columns.Add("TVSeasonPosterPathW300")
For Each season In objSeasons
Dim rowTVSeason = tableTVSeason.NewRow()
rowTVSeason("air_date") = season("air_date")
rowTVSeason("TMDbTVSeasonID") = season("id")
rowTVSeason("poster_path") = season("poster_path")
rowTVSeason("season_number") = season("season_number")
rowTVSeason("TVSeasonPosterPathW150") = ImageURLW150 + season("poster_path")
rowTVSeason("TVSeasonPosterPathW300") = ImageURLW300 + season("poster_path")
tableTVSeason.Rows.Add(rowTVSeason)
Next
DataListSeasons.DataSource = tableTVSeason
DataListSeasons.DataBind()
End If
End Sub
Protected Sub DataListSeasons_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListSeasons.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
Dim objLabelseason_number As Object = item.FindControl("Labelseason_number")
Labelseason_number.Text = objLabelseason_number.text
'
Dim objTMDbTVSeason As Object = ClassTMDbTV.GetTMDbTVSeason(LabelTMDbTVIDSearchResult.Text, objLabelseason_number.text, DropDownListLanguage.SelectedValue)
LabelOverViewSeason.Text = objTMDbTVSeason("overview")
Labelair_dateSeason.Text = objTMDbTVSeason("air_date")
'
Dim objEpisodes As Object = objTMDbTVSeason("episodes")
If objEpisodes.length <> 0 Then
Dim tableTVEpisode As New DataTable
tableTVEpisode.Columns.Add("air_date")
tableTVEpisode.Columns.Add("TMDbTVEpisodeID")
tableTVEpisode.Columns.Add("season_number")
tableTVEpisode.Columns.Add("name")
tableTVEpisode.Columns.Add("Episode_number")
tableTVEpisode.Columns.Add("still_path")
tableTVEpisode.Columns.Add("TVEpisodestill_pathW150")
tableTVEpisode.Columns.Add("TVEpisodestill_pathW300")
For Each Episode In objEpisodes
Dim rowTVEpisode = tableTVEpisode.NewRow()
rowTVEpisode("air_date") = Episode("air_date")
rowTVEpisode("TMDbTVEpisodeID") = Episode("id")
rowTVEpisode("season_number") = Episode("season_number")
rowTVEpisode("name") = Episode("name")
rowTVEpisode("Episode_number") = Episode("episode_number")
rowTVEpisode("still_path") = Episode("still_path")
rowTVEpisode("TVEpisodestill_pathW150") = ImageURLW150 + Episode("still_path")
rowTVEpisode("TVEpisodestill_pathW300") = ImageURLW300 + Episode("still_path")
tableTVEpisode.Rows.Add(rowTVEpisode)
Next
DataListEpisodes.DataSource = tableTVEpisode
DataListEpisodes.DataBind()
End If
End Sub
Protected Sub DataListEpisodes_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListEpisodes.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
'
Dim objLabelSeasonNUmber As Object = item.FindControl("LabelSeasonNUmber")
Labelseason_number.Text = objLabelSeasonNUmber.text
'
Dim objLabelEpisode_number As Object = item.FindControl("LabelEpisode_number")
LabelEpisode_number.Text = objLabelEpisode_number.text
'
Dim objTMDbTVSeason As Object = ClassTMDbTV.GetTMDbTVSeason(LabelTMDbTVIDSearchResult.Text, objLabelSeasonNUmber.text, DropDownListLanguage.SelectedValue)
Dim objTMDbTVSeasonEpisode As Object = objTMDbTVSeason("episodes")
For Each episode In objTMDbTVSeasonEpisode
If episode("episode_number") = LabelEpisode_number.Text Then
LabelSeasonNUmber.Text = episode("season_number")
LabelEpisode_number.Text = episode("episode_number")
LabelOverViewSeason.Text = episode("overview")
Labelair_dateSeason.Text = episode("air_date")
LabelEpisodeNmae.Text = episode("name")
Dim objCrew As Object = episode("crew")
Dim objguest_stars As Object = episode("guest_stars")
End If
Next
End Sub
End Class
Imports MJBTMDb.V3
Partial Class TMDbTVTest2
Inherits System.Web.UI.Page
Protected Sub ButtonTVSearch_Click(sender As Object, e As EventArgs) Handles ButtonTVSearch.Click
LabelTMDbTVIDSearchResult.Text = ""
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim Title As String = TextBoxTitle.Text
Dim first_air_date_year As String = TextBoxfirst_air_date_year.Text
Dim SearchResults As Object = ClassTMDbTV.SearchTMDbTVID(Title, first_air_date_year, DropDownListLanguage.SelectedValue)
Dim TMDbTVID As Object = SearchResults("results")
Dim total_pages As Object = SearchResults("total_pages")
Dim total_results As Object = SearchResults("total_results")
If TMDbTVID.length <> 0 Then
Dim tableTVID As New DataTable
tableTVID.Columns.Add("TMDbTVID")
tableTVID.Columns.Add("backdrop_path")
tableTVID.Columns.Add("original_name")
tableTVID.Columns.Add("first_air_date")
tableTVID.Columns.Add("poster_path")
tableTVID.Columns.Add("popularity")
tableTVID.Columns.Add("name")
tableTVID.Columns.Add("vote_average")
tableTVID.Columns.Add("vote_count")
tableTVID.Columns.Add("TVIDPosterPathW150")
tableTVID.Columns.Add("TVIDBackdropPathW150")
tableTVID.Columns.Add("TVIDPosterPathW300")
tableTVID.Columns.Add("TVIDBackdropPathW600")
For Each item In TMDbTVID
'1
If TMDbTVID.length = 1 Then
LabelTMDbTVIDSearchResult.Text = item("id")
Labeloriginal_nameSearchResult.Text = item("original_name")
LabelnameSearchResult.Text = item("name")
ImageBackdropSearchResult.ImageUrl = ImageURLW600 + item("backdrop_path")
ImagePosterSearchResult.ImageUrl = ImageURLW300 + item("poster_path")
Dim objTMDbTV As Object = ClassTMDbTV.GetTMDbTV(item("id"), DropDownListLanguage.SelectedValue)
LabelGetTMDbTVbackdrop_path.Text = objTMDbTV("backdrop_path")
LabelGetTMDbTVfirst_air_date.Text = objTMDbTV("first_air_date")
LabelGetTMDbTVhomepage.Text = objTMDbTV("homepage")
LabelGetTMDbTVid.Text = objTMDbTV("id")
LabelGetTMDbTVin_production.Text = objTMDbTV("production")
LabelGetTMDbTVlast_air_date.Text = objTMDbTV("last_air_date")
LabelGetTMDbTVname.Text = objTMDbTV("name")
LabelGetTMDbTVnumber_of_episodes.Text = ("number_of_episodes")
LabelGetTMDbTVnumber_of_seasons.Text = objTMDbTV("number_of_seasons")
LabelGetTMDbTVoriginal_name.Text = objTMDbTV("original_name")
LabelGetTMDbTVoverview.Text = objTMDbTV("overview")
LabelGetTMDbTVpopularity.Text = objTMDbTV("popularity")
LabelGetTMDbTVposter_path.Text = objTMDbTV("poster_path")
LabelGetTMDbTVstatus.Text = objTMDbTV("status")
LabelGetTMDbTVvote_average.Text = objTMDbTV("vote_average")
LabelGetTMDbTVvote_count.Text = objTMDbTV("vote_count")
End If
Dim rowTVID = tableTVID.NewRow()
rowTVID("TMDbTVID") = item("id")
rowTVID("backdrop_path") = item("backdrop_path")
rowTVID("original_name") = item("original_name")
rowTVID("first_air_date") = item("first_air_date")
rowTVID("poster_path") = item("poster_path")
rowTVID("popularity") = item("popularity")
rowTVID("name") = item("name")
rowTVID("vote_average") = item("vote_average")
rowTVID("vote_count") = item("vote_count")
rowTVID("TVIDPosterPathW150") = ImageURLW150 + item("poster_path")
rowTVID("TVIDBackdropPathW150") = ImageURLW150 + item("backdrop_path")
rowTVID("TVIDPosterPathW300") = ImageURLW300 + item("poster_path")
rowTVID("TVIDBackdropPathW600") = ImageURLW600 + item("backdrop_path")
tableTVID.Rows.Add(rowTVID)
Next
GridViewTVID.DataSource = tableTVID
GridViewTVID.DataBind()
DataListTVID.DataSource = tableTVID
DataListTVID.DataBind()
End If
End Sub
Protected Sub DataListTVID_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListTVID.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
Dim objLabelTVID As Object = item.FindControl("LabelTVID")
LabelTMDbTVIDSearchResult.Text = objLabelTVID.text
Dim objLabeloriginal_name As Object = item.FindControl("Labeloriginal_name")
Labeloriginal_nameSearchResult.Text = objLabeloriginal_name.text
Dim objLabelname As Object = item.FindControl("Labelname")
LabelnameSearchResult.Text = objLabelname.text
Dim objLabelPosterW300 As Object = item.FindControl("LabelPosterW300")
ImagePosterSearchResult.ImageUrl = objLabelPosterW300.text
Dim objLabelBackdropW600 As Object = item.FindControl("LabelBackdropW600")
ImageBackdropSearchResult.ImageUrl = objLabelBackdropW600.text
'
Dim objTMDbTV As Object = ClassTMDbTV.GetTMDbTV(objLabelTVID.text, DropDownListLanguage.SelectedValue)
LabelGetTMDbTVbackdrop_path.Text = objTMDbTV("backdrop_path")
LabelGetTMDbTVfirst_air_date.Text = objTMDbTV("first_air_date")
LabelGetTMDbTVhomepage.Text = objTMDbTV("homepage")
LabelGetTMDbTVid.Text = objTMDbTV("id")
LabelGetTMDbTVin_production.Text = objTMDbTV("production")
LabelGetTMDbTVlast_air_date.Text = objTMDbTV("last_air_date")
LabelGetTMDbTVname.Text = objTMDbTV("name")
LabelGetTMDbTVnumber_of_episodes.Text = ("number_of_episodes")
LabelGetTMDbTVnumber_of_seasons.Text = objTMDbTV("number_of_seasons")
LabelGetTMDbTVoriginal_name.Text = objTMDbTV("original_name")
LabelGetTMDbTVoverview.Text = objTMDbTV("overview")
LabelGetTMDbTVpopularity.Text = objTMDbTV("popularity")
LabelGetTMDbTVposter_path.Text = objTMDbTV("poster_path")
LabelGetTMDbTVstatus.Text = objTMDbTV("status")
LabelGetTMDbTVvote_average.Text = objTMDbTV("vote_average")
LabelGetTMDbTVvote_count.Text = objTMDbTV("vote_count")
'
Dim tableTMDbTVGenres As New DataTable
tableTMDbTVGenres.Columns.Add("")
tableTMDbTVGenres.Columns.Add("")
tableTMDbTVGenres.Columns.Add("")
'
Dim objSeasons As Object = objTMDbTV("seasons")
If objSeasons.length <> 0 Then
Dim tableTVSeason As New DataTable
tableTVSeason.Columns.Add("air_date")
tableTVSeason.Columns.Add("TMDbTVSeasonID")
tableTVSeason.Columns.Add("poster_path")
tableTVSeason.Columns.Add("season_number")
tableTVSeason.Columns.Add("TVSeasonPosterPathW150")
tableTVSeason.Columns.Add("TVSeasonPosterPathW300")
For Each season In objSeasons
Dim rowTVSeason = tableTVSeason.NewRow()
rowTVSeason("air_date") = season("air_date")
rowTVSeason("TMDbTVSeasonID") = season("id")
rowTVSeason("poster_path") = season("poster_path")
rowTVSeason("season_number") = season("season_number")
rowTVSeason("TVSeasonPosterPathW150") = ImageURLW150 + season("poster_path")
rowTVSeason("TVSeasonPosterPathW300") = ImageURLW300 + season("poster_path")
tableTVSeason.Rows.Add(rowTVSeason)
Next
DataListSeasons.DataSource = tableTVSeason
DataListSeasons.DataBind()
End If
End Sub
Protected Sub DataListSeasons_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListSeasons.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
Dim objLabelseason_number As Object = item.FindControl("Labelseason_number")
Labelseason_number.Text = objLabelseason_number.text
'
Dim objTMDbTVSeason As Object = ClassTMDbTV.GetTMDbTVSeason(LabelTMDbTVIDSearchResult.Text, objLabelseason_number.text, DropDownListLanguage.SelectedValue)
LabelOverViewSeason.Text = objTMDbTVSeason("overview")
Labelair_dateSeason.Text = objTMDbTVSeason("air_date")
'
Dim objEpisodes As Object = objTMDbTVSeason("episodes")
If objEpisodes.length <> 0 Then
Dim tableTVEpisode As New DataTable
tableTVEpisode.Columns.Add("air_date")
tableTVEpisode.Columns.Add("TMDbTVEpisodeID")
tableTVEpisode.Columns.Add("season_number")
tableTVEpisode.Columns.Add("name")
tableTVEpisode.Columns.Add("Episode_number")
tableTVEpisode.Columns.Add("still_path")
tableTVEpisode.Columns.Add("TVEpisodestill_pathW150")
tableTVEpisode.Columns.Add("TVEpisodestill_pathW300")
For Each Episode In objEpisodes
Dim rowTVEpisode = tableTVEpisode.NewRow()
rowTVEpisode("air_date") = Episode("air_date")
rowTVEpisode("TMDbTVEpisodeID") = Episode("id")
rowTVEpisode("season_number") = Episode("season_number")
rowTVEpisode("name") = Episode("name")
rowTVEpisode("Episode_number") = Episode("episode_number")
rowTVEpisode("still_path") = Episode("still_path")
rowTVEpisode("TVEpisodestill_pathW150") = ImageURLW150 + Episode("still_path")
rowTVEpisode("TVEpisodestill_pathW300") = ImageURLW300 + Episode("still_path")
tableTVEpisode.Rows.Add(rowTVEpisode)
Next
DataListEpisodes.DataSource = tableTVEpisode
DataListEpisodes.DataBind()
End If
End Sub
Protected Sub DataListEpisodes_ItemCommand(source As Object, e As DataListCommandEventArgs) Handles DataListEpisodes.ItemCommand
Dim ImageURLOriginal As String = ConfigurationManager.AppSettings("ImageURLOriginal")
Dim ImageURLW600 As String = ConfigurationManager.AppSettings("ImageURLW600")
Dim ImageURLW300 As String = ConfigurationManager.AppSettings("ImageURLW300")
Dim ImageURLW150 As String = ConfigurationManager.AppSettings("ImageURLW150")
Dim item As DataListItem = e.Item
'
Dim objLabelSeasonNUmber As Object = item.FindControl("LabelSeasonNUmber")
Labelseason_number.Text = objLabelSeasonNUmber.text
'
Dim objLabelEpisode_number As Object = item.FindControl("LabelEpisode_number")
LabelEpisode_number.Text = objLabelEpisode_number.text
'
Dim objTMDbTVSeason As Object = ClassTMDbTV.GetTMDbTVSeason(LabelTMDbTVIDSearchResult.Text, objLabelSeasonNUmber.text, DropDownListLanguage.SelectedValue)
Dim objTMDbTVSeasonEpisode As Object = objTMDbTVSeason("episodes")
For Each episode In objTMDbTVSeasonEpisode
If episode("episode_number") = LabelEpisode_number.Text Then
LabelSeasonNUmber.Text = episode("season_number")
LabelEpisode_number.Text = episode("episode_number")
LabelOverViewSeason.Text = episode("overview")
Labelair_dateSeason.Text = episode("air_date")
LabelEpisodeNmae.Text = episode("name")
Dim objCrew As Object = episode("crew")
Dim objguest_stars As Object = episode("guest_stars")
End If
Next
End Sub
End Class
web.config
<add key="ImageURL" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w150"/>
<add key="ImageURLW150" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w150"/>
<add key="ImageURLW300" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w300"/>
<add key="ImageURLW600" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w600"/>
<add key="ImageURLW1280" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w1280"/>
<add key="ImageURLOriginal" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original"/>
<add key="TMDbURL" value="http://www.themoviedb.org/movie/"/>
<add key="tmdbAPIKey" value="***********************"/>
<add key="TMDbTVAPIGETURL" value="http://api.themoviedb.org/3/tv/"/>
</appSettings>
</configuration>
<add key="ImageURLW150" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w150"/>
<add key="ImageURLW300" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w300"/>
<add key="ImageURLW600" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w600"/>
<add key="ImageURLW1280" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w1280"/>
<add key="ImageURLOriginal" value="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/original"/>
<add key="TMDbURL" value="http://www.themoviedb.org/movie/"/>
<add key="tmdbAPIKey" value="***********************"/>
<add key="TMDbTVAPIGETURL" value="http://api.themoviedb.org/3/tv/"/>
</appSettings>
</configuration>
試作品
検索画面タイトルを「24」で検索すると、24 がつくものが検索される。
タイトルを「24」、最初の公開年を「2001」にして検索すると24 の情報が表示される。
日本語で「ウォーキング・デッド」で検索すると1件だけ。言語を「英語」にして日本語で検索しても検索される。
言語を「日本語」にしてみる。
概要に日本語が表示される。ただし、TMDbには日本語情報がほとんど登録されていないので、日本語はあまり使えないかな。自分も数件しか登録できてないし。
もう一度「24」で検索し、「24 uur met」の基本情報取得をクリックすると 24 uur met
の情報が表示される。
今度は「24」をクリック。
24 の情報が表示される。
シーズン4をクリックするとシーズン4のエピソード一覧が表示される。
今度はウォーキング・デッドのエピソード一覧。こちらはエピソード名まで登録されている。
一応、TMDb から映画情報を取得できた。JSON とかクラスとかリストとかオブジェクトとか、わからないことばかりだった。まだわかっていないけど・・・・
課題
クラスから返却されるオブジェクトの構造を独自に定義する方法がわからない。WatTmdbでは下にあるみたいにオブジェクトを定義してるんだけど(こういう表現が正しいのかわからないけど)。C#だけど。
TmdbTv.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WatTmdb.V3
{
public class TmdbTv
{
public string backdrop_path { get; set; }
public List<TvCreatedBy> created_by { get; set; }
public List<int> episode_run_time { get; set; }
public string first_air_date { get; set; }
public List<MovieGenre> genres { get; set; }
public string homepage { get; set; }
public int id { get; set; }
public bool in_production { get; set; }
public List<string> languages { get; set; }
public string last_air_date { get; set; }
public string name { get; set; }
public List<TvNetwork> networks { get; set; }
public int number_of_episodes { get; set; }
public int number_of_seasons { get; set; }
public string original_name { get; set; }
public List<string> origin_country { get; set; }
public string overview { get; set; }
public double popularity { get; set; }
public string poster_path { get; set; }
public List<TvSeason> seasons { get; set; }
public string status { get; set; }
public double vote_average { get; set; }
public int vote_count { get; set; }
}
public class TvCreatedBy
{
public int id { get; set; }
public string name { get; set; }
public string profile_path { get; set; }
}
public class TvNetwork
{
public int id { get; set; }
public string name { get; set; }
}
public class TvSeason
{
public int season_number { get; set; }
public string air_date { get; set; }
public string poster_path { get; set; }
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WatTmdb.V3
{
public class TmdbTv
{
public string backdrop_path { get; set; }
public List<TvCreatedBy> created_by { get; set; }
public List<int> episode_run_time { get; set; }
public string first_air_date { get; set; }
public List<MovieGenre> genres { get; set; }
public string homepage { get; set; }
public int id { get; set; }
public bool in_production { get; set; }
public List<string> languages { get; set; }
public string last_air_date { get; set; }
public string name { get; set; }
public List<TvNetwork> networks { get; set; }
public int number_of_episodes { get; set; }
public int number_of_seasons { get; set; }
public string original_name { get; set; }
public List<string> origin_country { get; set; }
public string overview { get; set; }
public double popularity { get; set; }
public string poster_path { get; set; }
public List<TvSeason> seasons { get; set; }
public string status { get; set; }
public double vote_average { get; set; }
public int vote_count { get; set; }
}
public class TvCreatedBy
{
public int id { get; set; }
public string name { get; set; }
public string profile_path { get; set; }
}
public class TvNetwork
{
public int id { get; set; }
public string name { get; set; }
}
public class TvSeason
{
public int season_number { get; set; }
public string air_date { get; set; }
public string poster_path { get; set; }
}
}
今後
- 先にあげた課題をもう少しやってみる。
- DBに保存されている情報からTV情報を取得する。
- 取得した情報をDBに保存する。DB設計もやる。
- MovieJukeBox に組み込む。
コメント
コメントを投稿