Skip to content

Commit

Permalink
fix: mteam rss
Browse files Browse the repository at this point in the history
  • Loading branch information
vertex-app committed Mar 22, 2024
1 parent 0483f72 commit 885e056
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/libs/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,33 @@ const _getTorrents = async function (rssUrl) {
return torrents;
};

const _getTorrentsMTeam = async function (rssUrl) {
const rss = await parseXml(await _getRssContent(rssUrl, false));
const torrents = [];
const items = rss.rss.channel[0].item;
for (let i = 0; i < items.length; ++i) {
const torrent = {
size: 0,
name: '',
hash: '',
id: 0,
url: '',
link: ''
};
torrent.size = items[i].enclosure[0].$.length;
torrent.name = items[i].title[0];
const link = items[i].link[0];
torrent.link = link;
torrent.description = items[i].description ? items[i].description[0] : '';
torrent.id = link.match(/\/(\d+)/)[1];
torrent.url = items[i].enclosure[0].$.url;
torrent.hash = items[i].guid[0]._ || items[i].guid[0];
torrent.pubTime = moment(items[i].pubDate[0]).unix();
torrents.push(torrent);
}
return torrents;
};

const _getTorrentsPuTao = async function (rssUrl) {
const rss = await parseXml(await _getRssContent(rssUrl));
const torrents = [];
Expand Down Expand Up @@ -745,6 +772,9 @@ const _getTorrentsWrapper = {
exports.getTorrents = async function (rssUrl) {
const host = new URL(rssUrl).host;
try {
if (host.indexOf('m-team') !== -1) {
return await _getTorrentsMTeam(rssUrl);
}
if (_getTorrentsWrapper[host]) {
return await _getTorrentsWrapper[host](rssUrl);
}
Expand Down

0 comments on commit 885e056

Please sign in to comment.