demo.mov
Based on the work of Elaws.
This script allows you to easily insert a video game note into your Obsidian vault using Quickadd plugin by @chhoumann. Now also works on Mobile (make sure you use latest QuickAdd) !
We use IGDB api to get the game information.
This script needs a client id and client secret for IGDB API that you can get here. Steps to obtain client id and client secret are detailed below.
The script and this tutorial are based on Macro_MovieAndSeriesScript.md by @chhoumann.
Please never run a script that you don't understand. I cannot and will not be liable for any damage caused by the use of this script. Regularly make a backup of your Obsidian's vault !
- Sign-in to this website : https://dev.twitch.tv/login.
- Click on "Applications" :
- Click on "Register your application" :
- In "Name", choose a name you want. In "OAuth Redirect URLs", write
http://localhost
. In "category", choose "Application Integration". Finally, click on "Create" :
- Click on manage :
- Here are your
client id
andclient secret
! To generateclient secret
, click onnew secret
(and copy it, it will disappear !) :
- Keep your
client id
andclient secret
, they will be needed in the steps below.
- Make sure you use latest QuickAdd version (at least 0.5.1) !
- Save the script to your vault somewhere. Make sure it is saved as a JavaScript file, meaning that it has the
.js
at the end. - Create a new template in your designated templates folder. Example template is provided below.
- Open the Macro Manager by opening the QuickAdd plugin settings and clicking
Manage Macros
. - Create a new Macro - you decide what to name it.
- Add the user script to the command list.
- Add a new Template step to the macro. This will be what creates the note in your vault. Settings are as follows:
- Set the template path to the template you created.
- Enable File Name Format and use
{{VALUE:fileName}}
as the file name format. You can specify this however you like. ThefileName
value is the name of game without illegal file name characters. - The remaining settings are for you to specify depending on your needs.
- Click on the cog icon to the right of the script step to configure the script settings. This should allow you to enter the API client id and client secret you got from IGDB. Please make sure no accidental spaces are inserted before or after API
client id
orclient secret
! - You can also set the path where game posters will be downloaded (the default is the vault root) and toggle clipboard data being used for game search.
- Go back out to your QuickAdd main menu and add a new Macro choice. Again, you decide the name. This is what activates the macro.
- Attach the Macro to the Macro Choice you just created. Do so by clicking the cog ⚙ icon and selecting it.
You can now use the macro to create notes with game information in your vault !
Please also find a definition of the variables used in this template below (see : Template variable definitions).
---
title: {{VALUE:title}}
platforms: {{VALUE:platforms}}
developer: {{VALUE:developer}}
developerLogo: {{VALUE:developerLogoUrl}}
genre: {{VALUE:genres}}
modes: {{VALUE:gameModes}}
keywords: {{VALUE:keywords}}
aliases: {{VALUE:aliases}}
franchises: {{VALUE:franchises}}
poster: {{VALUE:posterPath}}
year: {{VALUE:year}}
releaseDate: {{VALUE:releaseDate}}
createdAt: {{DATE}}
igdbId: {{VALUE:igdbId}}
igdbUrl: {{VALUE:igdbUrl}}
igdbPoster: {{VALUE:posterUrl}}
websites: {{VALUE:websites}}
---
# {{VALUE:templateTitle}}
{{VALUE:templateDeveloper}}
{{VALUE:templatePoster}}
## Storyline
{{VALUE:templateStoryline}}
Here is the dataview query used in the demo. Replace from #gamedb
with whatever source is relevant to you:
table without id
choice(poster, embed(link(poster)), "![](" + igdbPoster + ")") as Poster,
link(file.link, title) as Title,
choice(year, string(year), "N/A") as Year,
choice(developer, "by " + developer, "N/A") as Developer
from #gamedb
where poster != null or igdbPoster != null
Please find here a definition of the possible variables to be used in your template. Simply write {{VALUE:name}}
in your template, and replace name
by the desired video game data, including :
Name | Description |
---|---|
fileName |
The title of the game followed by release year in parentheses without illegal characters. Can be used in template configuration to name your file. |
title |
The title of the game, single-quoted for use in properties. |
templateTitle |
The title of the game without any quoting or escaping, for use in the note body. |
posterUrl |
The poster url of the game (if available). |
igdbUrl |
The igdb url of the game. |
igdbId |
The igdb id of the game. |
platforms |
A list of platforms the game appeared on (if available). Single quoted and using the [[Link]] syntax, for use in properties. |
genres |
A list of genres the game conforms to (if available). Single quoted and using the [[Link]] syntax, for use in properties. |
keywords |
A list of keywords that apply to the game (if available). Single quoted and using the [[Link]] syntax, for use in properties. |
franchises |
A list of franchises the game belongs to (if available). Single quoted and using the [[Link]] syntax, for use in properties. |
aliases |
A list of aliases for the game's title (if available). Single quoted and using the [[Link]] syntax, constructed from the alternative_names and name fields from the igdb response. For use in properties. |
gameModes |
A list of modes the game supports (if available). Single quoted and using the [[Link]] syntax, for use in properties. |
developer |
The game's developer (if available), single-quoted and using the [[Link]] syntax for use in properties. |
templateDeveloper |
The game's developer (if available), without any quoting or escaping, for use in the note body. |
developerLogoUrl |
The game's developer logo URL. |
year |
The game's release year (if available). |
releaseDate |
The game's release date in YYYY-MM-DD format (if available). |
websites |
A list of websites related to the game (if available). For use in properties. |
templateStoryline |
The game's storyline (if available), newlines removed for use in the note body. |
posterPath |
The vault path where the game's poster was downloaded (if successful). |
templatePoster |
Either an embed using the downloaded poster path or an inline link with the poster url if the former failed, for use in the note body. |