BT Tracker // BEP 0036 – Torrent RSS Feed
本文最后更新于 375 天前,其中的信息可能已经有所发展或是发生改变。

BEP 0036 指定了有关使用发布种子 RSS 订阅的相关规范,也就是 qBittorrent 等软件中的 “RSS阅读器” 功能。

实现了此规范的 Tracker 能够通过 RSS 发布订阅,客户端将会从订阅中自动下载 .torrent 文件。

Feed 类型

由于支持 Atom 的客户端非常稀少,因此推荐使用 RSS2.0 规范来发布 Feed。

标签

enclosure

RSS 订阅中每个 Item 必须有一个 enclosure 标签,且 type 字段必须为 application/x-bittorrent,如果 Tracker 支持,还可以携带一个 length 字段代表 .torrent 文件本身的大小,最后一个 url 字段为下载此 .torrent 文件的 URL 地址。

<enclosure type="application/x-bittorrent" length="12216" url="http://featuredcontent.utorrent.com/torrents/WillisEarlBeal-BitTorrent.torrent"/>

media:content(可选)

包含了一个 url 字段和一个 fileSize 字段,分别表示 .torrent 文件下载地址和 .torrent 文件内的所有文件内容的大小。

<media:content url="http://featuredcontent.utorrent.com/torrents/WillisEarlBeal-BitTorrent.torrent" fileSize="12216320"/>

media:hash(可选)

表示该 torrent 的 info_hash。

<media:hash algo="sha1"><8c056e06fbc16d2a2be79cefbf3e4ddc15396abe/media:hash>

link(可选)

指向 .torrent 文件的下载链接

<link>http://featuredcontent.utorrent.com/torrents/WillisEarlBeal-BitTorrent.torrent</link>

torrent(可选)

包含一个 infohash 的标签,代表 torrent 的 info_hash,以及一个 contentLength 标签,代表 torrent 文件中的所有内容的总计大小。

<torrent>
        <infohash>8c056e06fbc16d2a2be79cefbf3e4ddc15396abe</infohash>
        <contentlength>600162597</contentlength>
</torrent>

guid(推荐)

torrent 的唯一标识符,对一个 torrent 来说应当保持不变。

<guid>http://featuredcontent.utorrent.com/torrents/WillisEarlBeal-BitTorrent.torrent</guid>

示例

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
        <channel>
                <title> Featured content </title>
                <link> http://featuredcontent.utorrent.com/ </link>
                <item>
                        <title> WillisEarlBeal-BitTorrent </title>
                        <description>
                                The Principles of a Protagonist Bundle

                                Chicago native Willis Earl Beal came from humble musical beginnings- he
                                began as a street performer of sorts that was prone to leaving homemade
                                novels, artwork and CD-Rs across America to promote his work, suggesting
                                a desire to be heard. Thereafter, he relocated to Albuquerque, NM where
                                he continued his practice of 'gifting' as he simultaneously recorded a
                                set of songs on a discarded karaoke machine that would become Acousmatic
                                Sorcery, his Hot Charity/XL Recordings debut.
                        </description>
                        <guid> e380a6c5ae0fb15f296d29964a56250780b05ad7 </guid>
                        <enclosure
                                url="http://featuredcontent.utorrent.com/torrents/WillisEarlBeal-BitTorrent.torrent"
                                type="application/x-bittorrent" />
                </item>
        </channel>
</rss>

增强的 torrent 属性

<torrent>
        <filename> WillisEarlBeal-BitTorrent </filename>
        <contentlength> 28571661 </contentlength>
        <magneturi> magnet:?xt=urn:btih:e380a6c5ae0fb15f296d29964a56250780b05ad7&dn=WillisEarlBean </magneturi>
        <trackers>
                <group order="ordered">
                        <tracker seeds="359" peers="3961">
                                udp://tracker.openbittorrent.com:80/announce
                        </tracker>
                </group>
                <group order="random">
                        <tracker seeds="365" peers="4451">
                                http://tracker.publicbt.com/announce
                        </tracker>
                        <tracker seeds="367" peers="4434">
                                udp://tracker.publicbt.com:80/announce
                        </tracker>
                        <tracker seeds="565" peers="6406">
                                udp://tracker.istole.it:80/announce
                        </tracker>
                        <tracker seeds="0" peers="0">
                                http://tracker.hexagon.cc:2710/announce
                        </tracker>
                </group>
        </trackers>
</torrent>

Java 示例代码

以下代码使用 ROME 库生成 RSS Feed,使用 qBittorrent 4.5.0 测试通过:

    private String makeFeed(List<Torrent> torrentList) throws FeedException {
        Channel channel = new Channel("rss_2.0");
        channel.setTitle(basicConfig.getSiteName() + " - " + basicConfig.getSiteSubName());
        channel.setGenerator("My RSS Generator - v1.0");
        channel.setEncoding("UTF-8");
        channel.setPubDate(new Date());
        channel.setDescription(siteDescription);
        channel.setLink(siteUrl);
        List<Item> items = new ArrayList<>();
        for (Torrent torrent : torrentList) {
            try {
                Item item = new Item();
                item.setAuthor(torrent.getUser().getUsername());
                item.setTitle(torrent.getTitle());
                item.setPubDate(torrent.getCreatedAt());
                item.setLink(siteUrl + "/torrent/" + torrent.getInfoHash());
                Guid guid = new Guid();
                guid.setValue(torrent.getInfoHash());
                item.setGuid(guid);
                Category category = new Category();
                category.setValue(torrent.getCategory().getName());
                item.setCategories(List.of(category));
                Enclosure torrentClosure = new Enclosure();
                torrentClosure.setType("application/x-bittorrent");
                torrentClosure.setUrl(siteUrl + "/torrent/download/" + torrent.getInfoHash());
                item.setEnclosures(List.of(torrentClosure));
                Description description = new Description();
                item.setDescription(description);
                items.add(item);
            } catch (Exception e) {
                log.error("Error when generating RSS item for torrent: {}", torrent, e);
            }
        }
        channel.setItems(items);
        WireFeedOutput out = new WireFeedOutput();
        return out.outputString(channel);
    }

查看其他同系列文章

本文采用 知识共享 署名-非商业性使用 4.0 许可。转载时请注明来源,以及原文链接
文章中的示例代码来自 BitSapling/Sapling 项目,授权协议为 GNU General Public License v3.0
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
呼呼
派蒙
巴巴托斯
上一篇
下一篇