jindra12 / react-rss

Fast and simple component used for visualizing RSS feeds with possible custom rendering and additional parsers
MIT License
9 stars 0 forks source link

Access RSS tag attributes #1

Closed NewbiZ closed 3 years ago

NewbiZ commented 3 years ago

Some RSS feeds do provide content in the form of tag attributes instead of tag content. The New-York Times RSS feed is a good example, the thumbnail of the article is provided as an url attribute of a media:content tag.

Extract from https://rss.nytimes.com/services/xml/rss/nyt/Business.xml:

[...]
<item>
    <title>Disney to Reveal Plans to Turbocharge Streaming Offerings</title>
    <link>https://www.nytimes.com/2020/12/09/business/media/disney-plus-new-movies.html</link>
    <guid isPermaLink="true">https://www.nytimes.com/2020/12/09/business/media/disney-plus-new-movies.html</guid>
    <atom:link href="https://www.nytimes.com/2020/12/09/business/media/disney-plus-new-movies.html" rel="standout"/>
    <description>Some big-budget movies will first go to theaters. Other offerings will debut online. All will ultimately strengthen Disney+.</description>
    <dc:creator>Brooks Barnes</dc:creator>
    <pubDate>Wed, 09 Dec 2020 23:39:16 +0000</pubDate>
    <category domain="http://www.nytimes.com/namespaces/keywords/des">Movies</category>
    <category domain="http://www.nytimes.com/namespaces/keywords/des">Video Recordings, Downloads and Streaming</category>
    <category domain="http://www.nytimes.com/namespaces/keywords/nyt_org">Disney Plus</category>
    <category domain="http://www.nytimes.com/namespaces/keywords/nyt_org">Walt Disney Company</category>
    <category domain="http://www.nytimes.com/namespaces/keywords/nyt_per">Chapek, Robert A</category>
    <media:content height="151" medium="image" url="https://static01.nyt.com/images/2020/12/09/business/09disney/merlin_179099916_e6ad3dd9-7ebc-42c0-bea7-6a5d0502d278-moth.jpg" width="151"/>
    <media:credit>Disney Plus, via Associated Press</media:credit>
    <media:description>“The Mandalorian” has been a hit for Disney+ and the company is planning more “Star Wars” content for the streaming service.</media:description>
</item>
[...]

An other example from Yahoo news (https://www.yahoo.com/news/rss/world):

[...]
<item>
    <title>Ghana election: Nana Akufo-Addo re-elected as president</title>
    <link>https://news.yahoo.com/ghana-election-nana-akufo-addo-193948047.html</link>
    <pubDate>2020-12-10T11:44:44Z</pubDate>
    <source url="https://www.bbc.com/">BBC</source>
    <guid isPermaLink="false">ghana-election-nana-akufo-addo-193948047.html</guid>
    <media:content height="86" url="https://s.yimg.com/uu/api/res/1.2/ylqrLmCT1nSP.k29RqznFA--~B/aD01NDk7dz05NzY7YXBwaWQ9eXRhY2h5b24-/https://media.zenfs.com/en-gb/bbc_us_articles_995/18949e314d4494fd29d6618b53ce53f5" width="130"/>
    <media:credit role="publishing company"/>
</item>

I do not think react-rss is able to handle that at the moment. Is there any current way to retrieve this information, or should there be additional developments to make it possible?

jindra12 commented 3 years ago

Hello, thank you so much for your interest in my package! react-rss should definitely be able to handle attributes. If you look at the unit tests within the project (parse-to-json.test.ts) you can see how it can be used. Simply access .attributes property within the custom parser.

Best regards, Jindráček

čt 10. 12. 2020 v 9:49 odesílatel Aurélien Vallée notifications@github.com napsal:

Some RSS feeds do provide content in the form of tag attributes instead of tag content. The New-York Times RSS feed is a good example, the thumbnail of the article is provided as an url attribute of a media:content tag.

Extract:

[...]

Disney to Reveal Plans to Turbocharge Streaming Offerings https://www.nytimes.com/2020/12/09/business/media/disney-plus-new-movies.html https://www.nytimes.com/2020/12/09/business/media/disney-plus-new-movies.html Some big-budget movies will first go to theaters. Other offerings will debut online. All will ultimately strengthen Disney+. Brooks Barnes Wed, 09 Dec 2020 23:39:16 +0000 Movies Video Recordings, Downloads and Streaming Disney Plus Walt Disney Company Chapek, Robert A Disney Plus, via Associated Press “The Mandalorian” has been a hit for Disney+ and the company is planning more “Star Wars” content for the streaming service.

[...]

I do not think react-rss is able to handle that at the moment. Is there any current way to retrieve this information, or should there be additional developments to make it possible?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jindra12/react-rss/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNS4VT3QYDN6OYSX3HI5NLSUCDQHANCNFSM4UUV7L3A .

NewbiZ commented 3 years ago

Got it. Thank you so much for the reply, and apologies for the mistaken issue.