使用 shell 脚本读取 RSS feed

发布于 2024-12-23 00:08:26 字数 551 浏览 2 评论 0原文

编辑:已翻译

我有一个 RSS 源想要解析。这是一个播客,我只想要 MP3-url 来使用 wget 下载它们。

这是播客:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast

标题应包含 (de) 以仅获取德语剧集。 发布日期应该是今天。

如果有人能帮助我,那就太好了——我已经走到这一步了:

wget -q -O- view-source:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml| awk 'BEGIN{RS=""}
/(date +'%d %M %Y')/{
gsub(/.*|.*/,"")
print
}

但它不起作用。

提前致谢, 阿内布3rt

Edit: Translated

I have a RSS-feed that i want to parse. It's a podcast and I want just the MP3-urls to download them with wget.

This is the podcast: http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast

The title should include an (de) to get just the german episodes.
The publish-date should be today.

Would be great if someone could help me – I came this far:

wget -q -O- view-source:http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml| awk 'BEGIN{RS=""}
/(date +'%d %M %Y')/{
gsub(/.*|.*/,"")
print
}

But it doesn't work.

Thanks in advance,
arneb3rt

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画▽骨i 2024-12-30 00:08:26

您需要从 wget 命令中删除“view-source:”,并在 awk 命令之外执行 date 命令(使用 %b 来打印缩写月份而不是 %M)。以下 bash 脚本使用 grep 而不是 awk 来生成 wget 可以获取播客的 URL。

请注意,可能是由于假期的原因,自 2011 年 12 月 24 日起,Feed 中就没有播客了,因此我对最后一个播客的日期进行了硬编码以进行测试:

url='http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml'
d=$(date +'%d %b %Y')
d="24 Dec 2011"
echo "Checking podcasts for date: ${d}"
wget -q -O- ${url} |\
 grep -A6 "(de)" |\
 grep -A1 "${d}" |\
 egrep -o 'http[^ ]*de.mp4' |\
 sort | uniq

上述 bash 脚本的输出列出了两个 URL(一个是 feedburner,另一个是 feedburner)。另一个 iTunes):

Checking podcasts for date: 24 Dec 2011
http://feedproxy.google.com/~r/Film-UndKino-trailerVideopodcast/~5/pzeSvkVK-3A/trailer01_de.mp4
http://www.moviemaze-trailer.de/ipod/6841/trailer01_de.mp4

因此,您可以从上述任一 URL 获取 2011 年 12 月 24 日的播客。

You need to drop the "view-source:" from the wget command and execute the date command (with %b to print the abbreviated month instead of %M) outside of the awk command. The following bash script uses grep instead of awk to produce the URLs of where wget can fetch the podcasts.

Note that, probably due to the holidays, there have been no podcasts since 24 Dec 2011 at the feed, so I hard-coded the date of the last podcast for testing:

url='http://feeds.feedburner.com/Film-UndKino-trailerVideopodcast?format=xml'
d=$(date +'%d %b %Y')
d="24 Dec 2011"
echo "Checking podcasts for date: ${d}"
wget -q -O- ${url} |\
 grep -A6 "(de)" |\
 grep -A1 "${d}" |\
 egrep -o 'http[^ ]*de.mp4' |\
 sort | uniq

The output of the above bash script lists two URLs (one feedburner and the other iTunes):

Checking podcasts for date: 24 Dec 2011
http://feedproxy.google.com/~r/Film-UndKino-trailerVideopodcast/~5/pzeSvkVK-3A/trailer01_de.mp4
http://www.moviemaze-trailer.de/ipod/6841/trailer01_de.mp4

Therefore, you could wget the 24 Dec 2011 podcast from either of the above URLs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文