阅读的MP3文件的大小和它的长度没有什么,但一个网址?
问题描述:
我想创建我自己的播客iOS应用程序。阅读的MP3文件的大小和它的长度没有什么,但一个网址?
首先,我从iTunes获取了一个示例Podcast rss feed并尝试解析它。而且,我无法找到RSS源中的mp3文件的直接链接。
在每个项目中,只有一个链接,让我们说“http://allearsenglish.libsyn.com/aee-785-efficient-or-effective-how-to-use-both-words-in-english”
为了提供在iOS应用的直接链接到MP3文件,我想我需要以某种方式获得源代码的网站,并找到mp3文件链接。
我的问题是
1是否有任何的iOS框架,让我来分析给定的URL的HTML文件?
2您如何知道音频文件的大小及其长度,但没有给出url链接?
答
答案:
-
是。 Objective-C和Swift中都有很多HTML解析器。列出其中的大部分:https://github.com/vsouza/awesome-ios#xml--html。由 “最明星” 排序:
无需下载文件:只能获得文件大小(如果服务器支持,则使用HEAD请求Answer with more details available here)但不是轨道长度。
如果您确实要创建podcast应用程序,请考虑拥有包含所有必要元数据的后端。
iTunes Podcast的RSS提要包含您正在查找的所有详细信息。现场样品(使用http://itunes.so-nik.com/提取):
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>The Morning Stream</title>
<link>http://frogpants.com/morningstream</link>
<description>
The Morning Stream, Mon thru Thurs, every morning, with Scott Johnson and the Frogpants Network. News, culture, politices and talk each and every day!
</description>
<generator>
Feeder 2.5.12(2294); Mac OS X Version 10.12.5 (Build 16F73) http://reinventedsoftware.com/feeder/
</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<language>en</language>
<pubDate>Thu, 10 Aug 2017 17:16:58 -0600</pubDate>
<lastBuildDate>Thu, 10 Aug 2017 17:16:58 -0600</lastBuildDate>
<itunes:author>Scott Johnson</itunes:author>
<itunes:image href="http://feeds.frogpants.com/morningstream_cover.jpg"/>
<itunes:explicit>no</itunes:explicit>
<itunes:owner>
<itunes:name>Scott Johnson</itunes:name>
<itunes:email>[email protected]</itunes:email>
</itunes:owner>
<itunes:new-feed-url>http://feeds.frogpants.com/morningstream_feed.xml</itunes:new-feed-url>
<itunes:block>no</itunes:block>
<itunes:category text="Comedy"/>
<itunes:category text="News & Politics"/>
<item>
<title>TMS PM 1318: Don't Blink</title>
<link>
http://feeds.soundcloud.com/stream/xxxxxxxxxxxxxx.mp3
</link>
<description>
<![CDATA[
Lasered and feelin fine! Warmart is sorry about that. You look like big foot! That truck smells good. Even porn news. Dan Dan the Table Top Man! Your Twitter questions and more on this episode of TMSPM.
]]>
</description>
<pubDate>Thu, 10 Aug 2017 17:16:54 -0600</pubDate>
<enclosure url="http://feeds.soundcloud.com/stream/xxxxxxxxxxxxxxxx.mp3" length="72444555" type="audio/mpeg"/>
<guid isPermaLink="false">1CF58DA3-57BB-437A-BD00-229CA2CD29E6</guid>
<itunes:author>Scott Johnson</itunes:author>
<itunes:subtitle>
Lasered and feelin fine! Warmart is sorry about that. You look like big foot! That truck smells good. Even porn news. Dan Dan the Table Top Man! Your Twitter questions and more on this episode of TMSPM.
</itunes:subtitle>
<itunes:summary>
<![CDATA[
Lasered and feelin fine! Warmart is sorry about that. You look like big foot! That truck smells good. Even porn news. Dan Dan the Table Top Man! Your Twitter questions and more on this episode of TMSPM.
]]>
</itunes:summary>
<itunes:explicit>no</itunes:explicit>
<itunes:duration>1:15:00</itunes:duration>
</item>
...
正如你所看到的,每个项目都有一个duration
,link
(以MP3文件)和length
。
非常感谢! – pearl7721