Yify torrent api返回未定义的值(Yify torrent api returning undefined value)

编程入门 行业动态 更新时间:2024-10-23 04:35:25
Yify torrent api返回未定义的值(Yify torrent api returning undefined value)

我最近在YifyTorrentAPI遇到了Yify-torrents api,只是想让我们试一试jquery并创建一个自己的应用程序。 我使用以下代码来检索有效的upcomming电影列表。

$.getJSON("https://yts.re/api/upcoming.json", function(data) { $.each(data, function(item, value) { console.log(value.MovieTitle + ' ' + value.ImdbLink); }); });

另一方面,当我尝试使用以下请求获取所有电影列表时,我刚刚在控制台中未定义。

$.getJSON("https://yts.re/api/list.json", function (data) { $.each(data, function (item, value) { console.log(value.MovieTitleClean + ' ' + value.ImdbLink); }); });

我正在分享我编写代码的小提琴 。 任何帮助将不胜感激。 谢谢

I recently came across the Yify-torrents api at YifyTorrentAPI and just thought let's give it a try with jquery and create a little own application. I used the following code to retrieve the upcomming movies list which worked.

$.getJSON("https://yts.re/api/upcoming.json", function(data) { $.each(data, function(item, value) { console.log(value.MovieTitle + ' ' + value.ImdbLink); }); });

on the other side when I tried to get all the movies list using the following request I just got undefined in the console.

$.getJSON("https://yts.re/api/list.json", function (data) { $.each(data, function (item, value) { console.log(value.MovieTitleClean + ' ' + value.ImdbLink); }); });

I am sharing the Fiddle in which I have wrote the code. Any help will be appreciated. Thanks

最满意答案

第二个ajax调用是在MoviesList对象中返回电影,因此您需要迭代data.MovieList而不是data 。

JSON:

{ "MovieCount":4921, "MovieList": [{ "MovieID":"5372", "State":"OK", "MovieUrl":"https:\/\/yts.re\/movie\/Gun_Woman_2014_1080p", "MovieTitle":"Gun Woman (2014) 1080p","MovieTitleClean":"Gun Woman", "MovieYear":"2014", "DateUploaded":"2014-06-30 00:10:03", "DateUploadedEpoch":1404043803, "Quality":"1080p", "CoverImage":"https:\/\/static.yts.re\/attachments\/Gun_Woman_2014_1080p\/poster_med.jpg", "ImdbCode":"tt3141912", "ImdbLink":"http:\/\/www.imdb.com\/title\/tt3141912\/", "Size":"1.24 GB", "SizeByte":"1335275815", "MovieRating":"8.2", "Genre":"Action", "Uploader":"OTTO", "UploaderUID":"310615", "Downloaded":"35173", "TorrentSeeds":"20", "TorrentPeers":"24497", "TorrentUrl":"https:\/\/yts.re\/download\/start\/777FD07DAD285CB06846CAFD97600B07F2CC88B3.torrent", "TorrentHash":"777fd07dad285cb06846cafd97600b07f2cc88b3", "TorrentMagnetUrl":"magnet:?xt=urn:btih:777fd07dad285cb06846cafd97600b07f2cc88b3&dn=Gun+Woman&tr=http:\/\/exodus.desync.com:6969\/announce&tr=udp:\/\/tracker.openbittorrent.com:80\/announce&tr=udp:\/\/open.demonii.com:1337\/announce&tr=udp:\/\/exodus.desync.com:6969\/announce&tr=udp:\/\/tracker.yify-torrents.com\/announce" }] }

这样做:

$.getJSON("https://yts.re/api/list.json", function (data) { console.log("Getting all the movies"); // console.log(data) $.each(data.MovieList, function (item, value) { console.log(value.MovieTitleClean + ' ' + value.ImdbLink); }); });

更新的FIDDLE

The second ajax call is returning movies in a MoviesList object so you need to iterate on data.MovieList not data.

JSON:

{ "MovieCount":4921, "MovieList": [{ "MovieID":"5372", "State":"OK", "MovieUrl":"https:\/\/yts.re\/movie\/Gun_Woman_2014_1080p", "MovieTitle":"Gun Woman (2014) 1080p","MovieTitleClean":"Gun Woman", "MovieYear":"2014", "DateUploaded":"2014-06-30 00:10:03", "DateUploadedEpoch":1404043803, "Quality":"1080p", "CoverImage":"https:\/\/static.yts.re\/attachments\/Gun_Woman_2014_1080p\/poster_med.jpg", "ImdbCode":"tt3141912", "ImdbLink":"http:\/\/www.imdb.com\/title\/tt3141912\/", "Size":"1.24 GB", "SizeByte":"1335275815", "MovieRating":"8.2", "Genre":"Action", "Uploader":"OTTO", "UploaderUID":"310615", "Downloaded":"35173", "TorrentSeeds":"20", "TorrentPeers":"24497", "TorrentUrl":"https:\/\/yts.re\/download\/start\/777FD07DAD285CB06846CAFD97600B07F2CC88B3.torrent", "TorrentHash":"777fd07dad285cb06846cafd97600b07f2cc88b3", "TorrentMagnetUrl":"magnet:?xt=urn:btih:777fd07dad285cb06846cafd97600b07f2cc88b3&dn=Gun+Woman&tr=http:\/\/exodus.desync.com:6969\/announce&tr=udp:\/\/tracker.openbittorrent.com:80\/announce&tr=udp:\/\/open.demonii.com:1337\/announce&tr=udp:\/\/exodus.desync.com:6969\/announce&tr=udp:\/\/tracker.yify-torrents.com\/announce" }] }

do like this:

$.getJSON("https://yts.re/api/list.json", function (data) { console.log("Getting all the movies"); // console.log(data) $.each(data.MovieList, function (item, value) { console.log(value.MovieTitleClean + ' ' + value.ImdbLink); }); });

UPDATED FIDDLE

更多推荐

本文发布于:2023-04-29 03:53:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1334552.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未定义   torrent   Yify   api   undefined

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!