I created my first advanced macro for scraping Allmusic for certain data and then add it to a markdown file saved in Obsidian. I am trying to create a database in Obsidian, and wan't to easily grab data from music and movie webpages. So first off is Allmusic and this one is done by the help and inspiration of JMichaelTX's example "Extract Data from Web Page and Display".
If we take an example like: Ghost Song - Cécile McLorin Salvant | Songs, Reviews, Credits | AllMusic, the Macro will then scrape the site for album title, year, artist, genre, styles, duration and finally cover (and this is where I need some guidance). Unfortunately, I can't seem to manage to grab images and add as a variable. Any help would be appreciated!
Thank you again @tiffle! I managed to use named clipboards instead, but what I need some help with now is how to grab an image from the html. I tried copying the path in the console and also tried with xpath - nothing works. Does anyone know something about this?
You need to use the KM Get a URL action and load the image into a clipboard. Here's the example for you:
Notice that I've split the image path into the URL and the Parameter for this KM action. You can try to put the whole path into the URL instead as that might work too and also make it slightly easier to use the KM action. I've also specified the system clipboard - well you can use a named clipboard too.
Thank you again for the effort of learning me this!
I understand, but how can I make it into a dynamic variable so that it always can grab the cover no matter what album I'm looking at - your example is based on one specific album.
Your macro works by itself, meaning that the cover is saved to the clipboard.
Now the weird thing, when I try to incorporate into my macro, the .md-file I create only says "No Text in Clipboard". Is there some certain action I need to use in order to add an image-url to the text file?
What I want to do is, for each music album I use the macro on, a .md-file is created that contains the metadata + the image. This is for Obsidian that uses markdown files.
is incorrect markdown. As I understand MD, you need to link to a local file or a URL whereas you're trying to use the image itself.
If you want to keep the image locally, then save the image (as obtained through the use of my example macro) to a file on your Mac and then use that file path to link to in the MD. Otherwise, just link to the URL as also obtained through my example macro.
If you're not familiar with what I'm talking about, then have a look here Basic Syntax | Markdown Guide and scroll down to the Images section.