Closed creativefibro closed 6 months ago
I just published 1.1.14, wich introduces Regex Transfomations. You can read on how they work in the readme, but if you want to use them as you described above you can use the template tag:
{{Actors|"[[|]]"|<$\w+$$>, <$^\w+$>\|@<$^\w+$> <$\w+$$>}}
The Regex Transformation doesn't work for me.
I used the regex you provided:
{{Actors|"[[|]]"|<$\w+$$>, <$^\w+$>\|@<$^\w+$> <$\w+$$>}}
but I get this:
"[[John Cusack]]", "[[Thandiwe Newton]]", "[[Chiwetel Ejiofor]]"
I also tried to transform the Actors list using the Regex Transformation into this format:
actors:
- "[[John Cusack]]"
- "[[Thandiwe Newton]]"
- "[[Chiwetel Ejiofor]]"
but it obviously didn't work either.
I would appreciate any help.
Are you sure you are using the newest Version? the regex Transform works for me. also make sure to Wrap the expression inside a list []
.
Tnx for the quick answer.
I had updated the plugin using the Obsidian's standard procedure. After I read your post, I did it again just to be sure, yet Obsidian was showing I have the latest version of the plugin 1.1.13 I checked the git repo, and noticed there is 1.1.16 version. After I manually updated to that version the regex transform works.
I still can't manage to get the actors in a valid Obsidian list property format, though. The proper list formatting would be as follow:
actors:
- "[[John Cusack]]"
- "[[Thandiwe Newton]]"
- "[[Chiwetel Ejiofor]]"
Can you please help?
Oh i see, i will look into why obsidian does not show the newest Version. You can use the transform i showed before, you just need to add a list modifier (square brackets) around it. So having
actors: [{{Actors|"[[|]]"|<$\w+$$>, <$^\w+$>\|@<$^\w+$> <$\w+$$>}}]
should work. Sadly i dont think it is currently possible to include linebreaks so a list modifier like you proposed might not be possible.
here is the template I ended up using. It requires Templater & Moviegrabber plugins;
---
title: "{{Title}} ({{Year}})"
year: {{Year}}
aliases: {{Title|"|"}}
rating:
<%*
let genreMatch = "{{Genre}}";
if (genreMatch && genreMatch.length > 1) {
let genreArray = genreMatch.split(', ');
let markdownGenre = genreArray.map(genre => ` - "[[${genre}]]"`).join('\n');
tR += `genre:\n${markdownGenre}`;
} else {
tR += 'genre: \n - "Genre not found or invalid format"';
}
%>
tags:
- entertainment/movie
- entertainment/movie/to-watch
- entertainment/movie/watched
country: {{Country}}
<%*
let directorMatch = "{{Director}}";
if (directorMatch && directorMatch.length > 1) {
let directorArray = directorMatch.split(', ');
let markdownDirector = directorArray.map(director => ` - "[[${director}]]"`).join('\n');
tR += `director:\n${markdownDirector}`;
} else {
tR += 'director: \n - "Actors not found or invalid format"';
}
%>
<%*
// Capture the actors string; assumes the line starts with 'actors: ' and the actors are enclosed in double quotes.
let actorsMatch = "{{Actors}}";
if (actorsMatch && actorsMatch.length > 1) {
// Split the captured string by '", "' to get an array of actor names.
let actorsArray = actorsMatch.split(', ');
// Map each actor name into a markdown list item, maintaining the double brackets.
let markdownActors = actorsArray.map(actor => ` - "[[${actor}]]"`).join('\n');
// Output the markdown list of actors.
tR += `actors:\n${markdownActors}`;
} else {
// If the actors string wasn't found, output an error or a placeholder.
tR += 'actors: \n - "Actors not found or invalid format"';
}
%>
length: {{Runtime}}
status:
- watched
- did not finish
- currently watching
- to watch
type:
- Movie
related:
created: <% tp.date.now("YYYY-MM-DD") %>T<% tp.date.now("HH:mm:ss") %>
updated: <% tp.date.now("YYYY-MM-DD") %>T<% tp.date.now("HH:mm:ss") %>
---
# {{Title}} ({{Year}})
![{{Title}}|300]({{Poster}})
{{Plot}}
Nice, thanks for sharing.
Btw, because there might have been sone confusion, the properties also accept lists in the format property: [item1, item2, item3]
so to just get a list of actors or genres you could do:
actors: [{{Actors|"[[|]]"}}]
Thanks for the templating improvements they have made a big difference.
This may be a long shot but the person fields (actor, director) are being brought in as:
FirstName Surname
In my vault I have people set as
[[Surname, Firstname|@FirstName Surname]]
I am currently editing each name once they are imported.Is there anyway I can alter
["{ Actors }":null}]|
to bring the names in like this? When I was using readwise for books someone showed me some code to put in to change how the names appeared to match my method. Unfortunately I no longer use Readwise so don't have access to the template to see how this was done.Thanks