monnierant / obsidian-simple-rss

GNU General Public License v3.0
27 stars 4 forks source link

No description from Mastodon feed #11

Closed thisisjoshjones closed 8 months ago

thisisjoshjones commented 1 year ago

Hi, I'm attempting to use this neat plugin to archive my Mastodon posts. The plugin loads the feed, and pages are created (I used item.pubdate since Mastodon posts have no item.title), no item descriptions load. I viewed the feed XML, and the Mastodon posts do have my content in the item descriptions. Is this something you can fix easily?

monnierant commented 11 months ago

It's probably because the content is on a baslie not already included in the "default" rss format. Can you provide me a rss exemple where you got the issue ?

I'm working on a future version where everyone can use custom property for the feed so it will be ultimately corrected by this future version if it's not a bug on my part.

thisisjoshjones commented 10 months ago

Thanks for looking into it, here's an example post from my rss feed, I hope it's helpful.

`

https://mas.to/@jjf/111380769244785253
  <link>https://mas.to/@jjf/111380769244785253</link>
  <pubDate>Thu, 09 Nov 2023 13:14:23 +0000</pubDate>
  <description>&lt;p&gt;No good lazy pets! 🐕🐈‍⬛&lt;/p&gt;</description>
  <media:content url="https://media.mas.to/masto-public/media_attachments/files/111/380/768/791/135/900/original/a82d622e7bbf2da0.jpeg" type="image/jpeg" fileSize="1121209" medium="image">
    <media:rating scheme="urn:simple">nonadult</media:rating>
    <media:description type="plain">George the chihuahua struggling to get out from under his blue blanket</media:description>
  </media:content>
  <media:content url="https://media.mas.to/masto-public/media_attachments/files/111/380/768/993/390/399/original/76d2af1a1a48b5e4.jpeg" type="image/jpeg" fileSize="1310798" medium="image">
    <media:rating scheme="urn:simple">nonadult</media:rating>
    <media:description type="plain">Mae the black cat loafing on a seat under the dining table </media:description>
  </media:content>
</item>`
monnierant commented 8 months ago

This issue is the same as for other rss feed. I can't test with your situation as i don't get the rss feed link.

But i'm pretty sure it's fixed in the last release.

You need to create a custom type of field and add the description field to item.

Then you could use {{&item.description}} to get it.

I close the issue but if it still doesn't work don't hesitate to open back the Issue and give me a rss feed url to test.

Penworks commented 8 months ago

Hi. Just commenting bc Im also using the plugin with a Mastodon feed (and also a feed from Grav). For the Mastodon feed I created a feed type with relevant feed and item types. For the Grav feed I used Generic.

I had to add 'description' to the main.js file list that's is in the .obsidian folder for the plugin before any of the Grav feed descriptions would show up. Not sure why that was.

For the Mastodon feed Im having trouble getting any content to show from the media:content item - media:description wont show as text and I cant work out how to pull the url attribute out of the media:content item at all. Any ideas appreciated :)

Aside from these issues its a VERY nice plugin so dont get me wrong - I really appreciate your work.

monnierant commented 8 months ago

Hi, Firstly, the description is a field ignored by the creator of the RSS plugin that I use. That's why you must add it if you want to get it.

For your media, can you give me an extract of the RSS, so I can see what is the format. And if possible, provide me an RSS feed, so I can investigate on it.

Penworks commented 8 months ago

Hey. Thanks for fast response.

Here's an item that has media:content in it, below </description > closing tag.

<item>
      <guid isPermaLink="true">https://mastodon.social/@DrPen/111832201685713509</guid>
      <link>https://mastodon.social/@DrPen/111832201685713509</link>
      <pubDate>Sun, 28 Jan 2024 06:39:35 +0000</pubDate>
      <description>&lt;p&gt;Patterns have featured an opinion piece in their email re Mastodon for research, particularly focused on gathering data and the non equivalency of direct swap comparison between Twitter and Mastodon/Fediverse ethics and privacy. Its a useful read imho. It&amp;#39;s open access.&lt;/p&gt;&lt;p&gt;Shifting your research from X to Mastodon? Here’s what you need to know. &lt;br /&gt;Roel Roscam Abbing, Robert W. Gehl&lt;br /&gt;&lt;a href="https://www.cell.com/patterns/fulltext/S2666-3899(23)00323-9" target="_blank" rel="nofollow noopener noreferrer" translate="no"&gt;&lt;span class="invisible"&gt;https://www.&lt;/span&gt;&lt;span class="ellipsis"&gt;cell.com/patterns/fulltext/S26&lt;/span&gt;&lt;span class="invisible"&gt;66-3899(23)00323-9&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="https://mastodon.social/tags/academicchatter" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;academicchatter&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/academicmastodon" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;academicmastodon&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/research" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;research&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/ethics" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;ethics&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/privacy" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;privacy&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/fediverse" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;fediverse&lt;/span&gt;&lt;/a&gt; &lt;a href="https://mastodon.social/tags/mastodon" class="mention hashtag" rel="tag"&gt;#&lt;span&gt;mastodon&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</description>
      <media:content url="https://files.mastodon.social/media_attachments/files/111/832/170/886/342/281/original/6cae376ed484e250.png" type="image/png" fileSize="165089" medium="image">
        <media:rating scheme="urn:simple">nonadult</media:rating>
        <media:description type="plain">Screenshot of academic opinion piece on Patterns, discussing ethics/privacy differences of data collection between Twitter and Mastodon/Fediverse</media:description>
      </media:content>
      <category>academicchatter</category>
      <category>academicmastodon</category>
      <category>research</category>
      <category>ethics</category>
      <category>privacy</category>
      <category>fediverse</category>
      <category>mastodon</category>
    </item>

You can see the url attribute in the media:content element, not as a separate child of media:content.

Not sure I understand your comment about the description ignored by the creator of the plugin. I thought you were the creator ;) no worries though.

Link to this feed https://mastodon.social/@DrPen.rss

monnierant commented 8 months ago

Hi. I have created the plugin but not the rss library that i rely on.

Can you try to add media:content as a field and in your template try {{$media:content.url}}

Penworks commented 8 months ago

OK I'll do that in the morning as not at my workstation now.

To check -

Add "media:content" to item list in custom feed Add {{$media:content.url}} to the img src html in the template. Not tried the $ prefix before.

FYI I made a post this morning on Obsidian forum about this. It's got some of my earlier code tests in it https://forum.obsidian.md/t/simple-rss-issues-media-content-url-attribute/75937/2

Thanks

monnierant commented 8 months ago

I found the correct way.

In order to access an attribute of a field, you must add a $.

In Item field you must add media:content

And in template :

{{&item.media:content.$.url}}

The & help with handling html chars and the $ allow you to target attributes and not content of a field.

image

Penworks commented 8 months ago

OK that sounds logical. I know about the & tidying up the rendered html, it makes a lot of difference. The $ targeting the attribute I had no idea to try.

Yes I'll add just media:content to the item field.

I'll update you early tmrw FYI.

Thanks again.

monnierant commented 8 months ago

It was not your fault. I was assuming that I have documented it, but I forgot to do it.

I just do it : #76

I have just corrected it, and you can found the new info into the README.

Access attribute

Penworks commented 8 months ago

Actually the item.description didn't work for either feed, not just the mastodon one.

Only mastodon feed had the media:content url problem.

monnierant commented 8 months ago

Description must be added as a custom field, it's not populated by default. Item Field: description,media:content

Template:

{{&item.description}}
---
{{&item.media:content.$.url}}
Penworks commented 8 months ago

Morning monnierant... So, the solution for media:content url works great! Thanks so much for that.

{{&item.description}} works fine in both types of feeds - RSS2 from Grav site and Media RSS from Masto. Im thinking its best to make a new custom feed type for the Grav feed so that description can be added to its item fields. The generic default only works bc I added description to the main.js. That will break if you update the plugin.

I still cannot call the media:description in the Masto feed, which is a child of media:content (its the alt text field). So far I have tried:

{{&item.media:content.media:description}}
{{&item.media:content.$.media:description}}
{{&item.media:description}}
{{&item.$.media:description}}
{{&item.media:content.ma:description}}
{{&item.media:content.$.ma:description}}

These are added as item fields in the custom feed.

Im trying ma.description bc this is how it is identified in the W3C Media RSS spec. Its probably wrong but I wanted to try it. It also does not work in the format Ive tried.

monnierant commented 8 months ago

I found it. It's strange how it is added.

It's listed as an array.

Here is the code to put in template:

{{#item.media:content.media:description}}
- {{_}}
{{/item.media:content.media:description}}
Penworks commented 8 months ago

Hi. Yes that works, I just implemented it. I had to remove the dash ;), so wrote it like this on one line: {{#item.media:content.media:description}}{{_}}{{/item.media:content.media:description}}

I was trying something with a hash but couldnt guess how to do it! lol but I had put these in the item fields:

  "['media:content', 'media:content', {keepArray: true}]",
  "['media:content', 'media:content', { includeSnippet: true }]",

Do they need to be there to make it work? I probably wrote them wrongly.

Any ideas on this: Im trying to pull each mastodon feed category as a list, using "category" in the item field and {{&item.category}} in the template. But it only pulls the first category. Using {{&item.categories}} pulls all the categories but in a comma separated string with no whitespace between words and I can't style them that way. If they came in as separate entries I think Id be able to style them with ul/li etc.

FYI Im building a template with inline css styling. Its beginning to look nice.

Brilliant help btw, a lot of Mastodon people are looking at how to archive their posts. This could be very useful to others.

monnierant commented 8 months ago

For categories, I suggest the following.

{{#item.categories}}
- {{.}}
{{/item.categories}}
Penworks commented 8 months ago

thanks, that works. Really grateful for your help. Im learning stuff about how json works with xml/rss.