readwiseio / obsidian-readwise

Official Readwise plugin for Obsidian
GNU General Public License v3.0
239 stars 23 forks source link

Feature Request: Selectively Import into Obsidian by Tag #44

Open JunaidAGit opened 11 months ago

JunaidAGit commented 11 months ago

When Readwise is used for research, it can be useful to separate imports by tag. This would fit well with how Obsidian is separated by vault. If I'm a banker whose hobby is bodybuilding, I'd like to be able to separate the things I read. One tag ("finance") may contain information that I'm using to improve in my career, and the other tag ("health") may be used for my hobby. Having both health and finance muddled into the same "articles" or "books" folder with Readwise-Obsidian sync would be cumbersome.

writtenfool commented 11 months ago

Does the code, below, address your need. There is a good stash of jinja termplates in the readwise-export-integration channel on the Readwise Reader discord server. https://discord.com/channels/886992134505398314/1130687464865005570/1130799793812295840

JunaidAGit commented 11 months ago

Interesting idea, thank you for sharing! I was looking for something more automated. Rather than having to tag each note by #inbox then processing it, I could just import all of my "health" notes and ignore all the "finance" ones. However, this inbox idea is something I'll consider adding to my YAML frontmatter :)

writtenfool commented 11 months ago

My inbox functionality has changed in this regard. I've started applying the inbox tag in Readwise but in nested fashion. In Readwise or Reader, if the note is valid and destined for the vault, I'll apply a yaml tag of inbox/new. Once in my vault, when I do process it, I"ll change that tag to inbox/processed. This way I can keep history (it was once in the inbox) and also whether or not I've added value to it.

The inbox concept, in my workflow, is for stuff that arrives in the vault via some "formal" workflow (i.e. Readwise), but some of it does not (i.e. daily note content. What distinguishes the two is use of links. So I use tags for status processing and links for cross note analysis. Both are easily and effectively analyzed via the core search plugin.

Saskia-vA commented 11 months ago

I don't want all of my highlights to end up in my Obsidian automatically, I would also like to use tags to selectively import into Obsidian instead.

I've now turned off the automatic export in Readwise, but this means I have to go to the Readwise settings to individually select what files I do want to send to Obsidian. I much prefer to use a tag system where articles/books/etc. with certain tags are send to appropriate folders in Obsidian, while articles/books/etc. lacking those tag(s) are not synced.

writtenfool commented 11 months ago

@Saskia-vA - have you tried filtering by tags in your Readwise export termplate? By using nested tags in Readwise / Reader and then filtering in the template, you can accomplish what you want.

Saskia-vA commented 11 months ago

@writtenfool - I'm no expert in jinja2, how would you do this?

I've been able to include only parts of the template depending on the presence of a specific tag using an if statement, but I have not managed to specify which articles/books/etc. to include in the export using tags in the template.

writtenfool commented 11 months ago

@Saskia-vA - humble apologies; dove into this and there is no obvious way to filter via jinja what docs go into Obsidian.

What we need is an option in the Include content: dropdown list at the bottom of the export page "Filter By Tag".

Or, functionality in the plugin to allow us to filter by document tag (or other element, source for example). Since we have collections of tags and highlights, we should also have document collection object we can iterate thru and filter.

Edit - there is a books collection that is referenced in the Sync Notification section. I can iterate thru it, but not finding how to skip or filter files; need a skip or next or exit routine.

Need to find some passionate saavy developers to engage in this interface. Much has changed in the last 18 months since this plugin was created.

I do want to thank you for asking the question however, I learned a great deal this morning and am revamping my template to accommodate the recent Obsidian properties functionality. Cheers!

tyler-dot-earth commented 3 weeks ago

This is a pretty specific use-case and I'm not sure I agree with the proposed solution. Hear me out.

If what you want is categorization, here's a solution from my own configuration: edit the YAML frontmatter configuration to include something like this:

aliases:
  - "{{title}}"
{% if author %}author: "{{author}}"{% endif %}
{% if document_tags %}related to: {% for tag in document_tags %}
  - "[[{{tag}}]]"{% endfor %}{% endif %}
tags:
  - artifact/readwise{% if category %}/{{category}}{% endif %}

:point_up: This configuration will create a backlink to the any document tags that you add. You could modify it to do backlinks. Either way, you'll be able to find a list of articles by category.

I'd also generally recommend that you treat readwise exports as read-only.

That said, @JunaidAGit how would you imagine your underlying request to work given that documents can have multiple tags? Like, would you want multiple copies if it has multiple tags? Seems like it would harm referencability (as you only want 1 copy of any given file).

Either way, I suspect this is something that would probably need to be tackled by the archive service in the backend more than the plugin, so not much I can do to help :man_shrugging: