问题标签 [last.fm]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2167 浏览

http - 在 Chrome 中使用 HTTP 302 重定向的 HTML5 音频

我正在尝试使用流行的 jPlayer jQuery 插件 ( http://jplayer.org ) 编写基于 HTML 5 的 last.fm 播放器。该播放器在 Firefox 中运行良好。但是我遇到了一个问题:从 last.fm API ( http://last.fm/api ) 我得到一个带有文件 URL 的播放列表。当请求其中一个时,last.fm 会从 play.last.fm 重定向到类似“ http://s03.last.fm/someurl/128.mp3 ”的HTTP 302。

看起来 html 5 标签有一些相同的来源策略,因为 jPlayer 无法在 Chrome 和 Chromium 中播放文件。如果 jPlayer 使用 flash 解决方案(使用“flash, html”而不是“html, flash”),一切正常。

我在我的 Ubuntu 上安装了额外的编解码器,mp3 播放非常适合 jPlayer 演示。

流服务器不支持 HEAD 请求。我已经尝试执行正常的 GET 请求,然后尝试获取 xmlhttprequest 的“Location”标头,但由于安全错误而失败。

您可以在https://github.com/tburny/html5-lastfm-player找到我的(概念证明)项目的来源

这个问题有什么提示/解决方案吗?

0 投票
1 回答
9266 浏览

c# - .NET4.5 中异步 POST 方法的 HttpResponseMessage 异常

我正在用 C# 开发适用于 Windows 8(Consumer Preview)的应用程序。它对 Last.fm API 进行简单的 REST 调用。

有一个异常困扰着我很多天了。我正在尝试向 Last.fm API 方法发送 POST 调用。但是每当我拨打电话时,我都会收到以下消息 -

“在 mscorlib.dll 中发生了 'System.Net.Http.HttpRequestException' 类型的异常,但未在用户代码中处理”。附加信息:发送请求时出错。

如果我打印出它说的异常 -

System.Net.Http.HttpRequestException:发送请求时出错。---> System.Net.WebException:底层连接已关闭:连接意外关闭。

在 System.Net.HttpWebRequest.EndGeetResponse(IAsyncResult asyncResult)

在 System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)

我对 last.fm 的身份验证 API 的 GET 调用工作正常。

我附上一个代码片段:

请让我知道是否需要堆栈跟踪。

-萨加尔

0 投票
1 回答
2662 浏览

last.fm - 从 last.fm xml (api artist.getinfo) 获取大型艺术家图像

这是上一个 fm 的 xml 响应:

我试图回显那个大图像,但它没有返回任何东西......

如果我只是把 $largeimg = $xml->artist->image; 它只是抓取第一个图像(小图像)。知道如何解决这个问题吗?

0 投票
1 回答
584 浏览

jquery - How to Prevent Chrome fetching the last 128 bytes of an MP3 file

I am having a problem with this for a while now, so I thought I'd ask for your help.

For a proof of concept project, I created a HTML 5 only last.fm player using jPlayer . It works fine with Firefox, but does not play using the html solution when using Chrome(Chromium).

First, Chrome tries to fetch the mp3 file via the stream url. After it has pre-buffered a bit, it always tries to read the last 128 bytes by making another HTTP request. The problem now is that the last.fm streaming servers only seem allow one connection per file at a time, which causes both http connections to fail. It seems Chrome/Chromium is ignoring the preload="none" property of the audio tag. As far as I could find out the tag is only a recommendation to the browser.

Normal mp3 files work like a charm. Also, when entering the redirected streaming url in the browser, it starts playing. It seems last.fm is using the original urls as kind of one-time access token/access control filter, whereas the resolved stream url is valid for a while.

For the full HTTP headers (cookies censored), see http://pastebin.com/rBAdL4X8. (Copied from Chromium element inspector).

Is there any way to circumvent this problem from within the browser?

0 投票
2 回答
2503 浏览

java - 将光标与 AsyncTask 一起使用

我正在尝试为每个在我的手机上有音乐的艺术家下载图像,然后将这些图像显示在GridView. 我正在使用 Last.fm 推荐使用的lastfm-java 库。您调用获取艺术家图像的方法是getImageURL(ImageSize size),但在执行此操作之前,您需要通过String参数告诉它您要引用哪个艺术家。所以,完全是这样的:

获取我手机上的所有艺术家不是问题,您只需参考MediaStore. 你会做这样的事情:

Adapterfor myGridView没什么特别的,它只是扩展了BaseAdapter.

注意 AQuery是我正在使用的一个库,它可以帮助缓存和加载Bitmap来自 URL 的 a。

完整的,我AsyncTask的如下:

当我调用 myAsyncTask时,我在我的getArtists()方法中调用它,如下所示:

new LastfmArtistGetImageURL(c.getString(ARTIST_IDX), mGridView, getActivity()) .execute();

问题

当我调用这个时,所有艺术家的图像都会下载,但他们会一个接一个地下载position 0我的GridViewAdapter. 换句话说,一个图像加载,然后是下一个,等等,position当我需要将它们放入每个可用positionGridView. 当我返回我的测试String[]时,我的AsyncTask一切都正常工作。所有图像都按顺序放置在GridView.

问题

我的问题是,如何GridView正确返回我下载到我的每个艺术家图像,为什么图像目前只position在我的第一个加载GridViewAdapter

编辑 - Shubhayu 的回答 我将我的设置移动GridViewAdapter到我的getArtists()方法中。这会导致所有图像都被下载(如 LogCat 所说),但只有最后一个图像被设置在我的GridView.

smoak 的回答 这导致只有最后一个艺术家图像(默认顺序)被下载并应用到我的GridView.

0 投票
1 回答
180 浏览

tags - Normalize LastFM Tags

I have this set of music data crawled from LastFM, Now, I would like to normalize and classify the songs based on one tag per track. I got this master Genre list, https://spreadsheets.google.com/pub?key=psnjFY3R2itsqjinSs9hkZw

But again, how will I identify, J-pop, JPop and Jap Pop all are same as Japanese Pop? Is there a web api or database which will be useful to get normalized genre?

Thanks for helping.

0 投票
1 回答
534 浏览

ruby - 为 last.fm api ruby​​ 创建 authToken

我正在尝试使用 auth.getMobileSession 方法向我的 last.fm 应用程序验证用户身份,该应用程序是使用 last.fm REST api 构建的。

Last.fm 说对于移动应用我们需要发送AuthToken

这就是我在 ruby​​ 中尝试做的事情:

我得到的输出是:

谁能告诉我我做错了什么?

0 投票
1 回答
256 浏览

jsf - 如何在 JSF 中使用 dataTable 访问对象方法?

我正在使用 LastFM api,假设我有一个名为的类Artist,我在此调用dataTable

Artit 有一个字段引用他的图片:

哪个工作正常,但是如何使用 dataTable 在我的 jsf 页面中调用此方法?

0 投票
2 回答
588 浏览

php - json_decode 中的 PHP 额外字符

last.fm API 返回一个 JSON 字符串,我使用它转换为数组

当响应被转储时,它给了我以下 json 字符串:

(注意最后的1)

由于这个额外的字符,json 字符串无法转换为关联数组,因此是我的问题。

我发现一些讨论指出 1 是 BOM(字节顺序掩码)字符,但提供的所有解决方案都不适用于我的 json 字符串。

这个角色是什么?为什么它在那里,为什么当我在本地开发时不会发生这种情况?解决方案是什么?

在两个不同的网络服务器上试过这个,给出了相同的结果

0 投票
1 回答
490 浏览

php - 如果 XML 元素不存在,则通过 PHP 回显消息

在对这个主题进行了一些实质性的研究之后,很遗憾我没有找到答案。我想这对于这里的很多人来说是一个非常简单的问题。

我通过他们的 API(使用 PHP)连接到 Last.fm 的 XML 数据库。在输入存在的艺术家或空白字段时,我可以毫无问题地回显正确的信息。但是,如果用户输入不存在的艺术家,我无法回应任何内容。

我的问题是这个;如果该 XML 元素不存在,我如何回显我想要的任何消息?我的思路如下:

经过一些试验和错误,我得到的最好的结果是回显上述内容,但无论搜索什么,它都会被回显。仅当 XML 数据库中不存在艺术家时,我才需要显示上述内容。

非常感谢任何能给我一个关于如何在这个方面取得进展的想法的人。

谢谢你。