Shorten the RSS URL
This will be backward compatible with existing format that uses the full claim_id.
This commit is contained in:
parent
f6641ee045
commit
e7bed19391
2 changed files with 12 additions and 10 deletions
|
@ -150,6 +150,6 @@ export const generateShareUrl = (
|
|||
|
||||
export const generateRssUrl = (domain, lbryUrl) => {
|
||||
const { channelName, channelClaimId } = parseURI(lbryUrl);
|
||||
const url = `${domain}/$/rss/@${channelName}/${channelClaimId}`;
|
||||
const url = `${domain}/$/rss/@${channelName}/${channelClaimId.slice(0, 2)}`;
|
||||
return url;
|
||||
};
|
||||
|
|
|
@ -16,15 +16,17 @@ async function doClaimSearch(options) {
|
|||
return results ? results.items : undefined;
|
||||
}
|
||||
|
||||
async function getChannelClaim(claimId) {
|
||||
const options = {
|
||||
claim_ids: [claimId],
|
||||
page_size: 1,
|
||||
no_totals: true,
|
||||
};
|
||||
async function getChannelClaim(name, claimId) {
|
||||
let claim;
|
||||
try {
|
||||
const url = `lbry://${name}#${claimId}`;
|
||||
const response = await Lbry.resolve({ urls: [url] });
|
||||
|
||||
const claims = await doClaimSearch(options);
|
||||
return claims ? claims[0] : undefined;
|
||||
if (response && response[url] && !response[url].error) {
|
||||
claim = response && response[url];
|
||||
}
|
||||
} catch {}
|
||||
return claim || 'The RSS URL is invalid or is not associated with any channel.';
|
||||
}
|
||||
|
||||
async function getClaimsFromChannel(claimId, count) {
|
||||
|
@ -86,7 +88,7 @@ async function getRss(ctx) {
|
|||
return 'Invalid URL';
|
||||
}
|
||||
|
||||
const channelClaim = await getChannelClaim(ctx.params.claimId);
|
||||
const channelClaim = await getChannelClaim(ctx.params.claimName, ctx.params.claimId);
|
||||
if (typeof channelClaim === 'string' || !channelClaim) {
|
||||
return channelClaim;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue