script_videogames_quickAdd icon indicating copy to clipboard operation
script_videogames_quickAdd copied to clipboard

A script for Obsidian's QuickAdd plugin, to fetch video game data from IGDB API.

Videogames Script for Obsidian's Quickadd plugin

Demo

igdbDemo

If this script helped you and you wish to contribute :)

Buy Me A Coffee

Description

This script allows you to easily insert a videogame 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 videogame 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.

Disclaimer

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 !

How to obtain client ID and secret.

  1. Sign-in to this website : https://dev.twitch.tv/login.
  2. Click on "Applications" :

1

  1. Click on "Register your application" :

2

  1. In "Name", choose a name you want. In "OAuth Redirect URLs", write http://localhost. In "category", choose "Application Integration". Finally, click on "Create" :

3

  1. Click on manage :

4

  1. Here are your client id and client secret ! To generate client secret, click on new secret (and copy it, it will disappear !) :

5

  1. Keep your client id and client secret, they will be needed in the steps below.

Installation

igdbInstall

  1. Make sure you use latest QuickAdd version (at least 0.5.1) !
  2. 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.
  3. Create a new template in your designated templates folder. Example template is provided below.
  4. Open the Macro Manager by opening the QuickAdd plugin settings and clicking Manage Macros.
  5. Create a new Macro - you decide what to name it.
  6. Add the user script to the command list.
  7. Add a new Template step to the macro. This will be what creates the note in your vault. Settings are as follows:
    1. Set the template path to the template you created.
    2. Enable File Name Format and use {{VALUE:fileName}} as the file name format. You can specify this however you like. The fileName value is the name of videogame without illegal file name characters.
    3. The remaining settings are for you to specify depending on your needs.
  8. 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 or client secret !
  9. 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.
  10. 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 videogame information in your vault !

Example template

Please also find a definition of the variables used in this template below (see : Template variables definitions).

# {{VALUE:name}}

Title:: {{VALUE:name}}
linking:: [[% Videogames]]
Tags:: #📥/🎮/{{VALUE:tag}}
Developer:: {{VALUE:developerName}}
DeveloperLogo:: {{VALUE:developerLogo}}
Genre:: {{VALUE:genresFormatted}} 
Modes:: {{VALUE:gameModesFormatted}}
Thumbnail:: {{VALUE:thumbnail}}
Release:: {{VALUE:release}}
URL:: [IGDB]({{VALUE:url}})
Date:: {{DATE}}
Recommender:: {{VALUE:recommender}}
Comment:: {{VALUE:comment}}
Rating:: {{VALUE:rating}}
Played:: {{VALUE:played}}

---

# Storyline

> {{VALUE:storylineFormatted}}

Dataview rendering

Here is the dataview query used in the demo (replace PATH by your videogames notes path) :

TABLE WITHOUT ID

("[[" + file.name + "|" + Title + "]]") AS Title,
Date,
Genre,
Modes,
("![coverImg|100](" + Thumbnail + ")") AS Cover,
("![DeveloperLogo|100](" + DeveloperLogo + ")") AS Developer,
Release,
URL,
Recommender,
Comment,
Rating

from "PATH"

The banner at the top of the document is rendered using Obsidian-banners plugin.

Template variables definitions

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 :

fileName: Title of the game without illegal characters. Possibly used in template configuration to name your file.

name: The title of the game.

tag: A colored square that is orange if game has been played, red if not.

developerName: Name of the developer.

developerLogo: Logo of the developer (if available).

genresFormatted: A list of genres for this game, formatted as "genre1", "genre2", etc...

gameModesFormatted: A list of game modes for this game, formatted as "gameMode1", "gameMode2", etc...

thumbnail: A poster of the videogame (if available)

release: The year the game was released (if available)

url: URL to the IGDB page of the game.

recommender: The person (or organization, etc...) that recommended the book to you.

comment: A small personal comment on the videogame.

rating: Your videogame rating, /10.

played: If you played the game, this equals 1, otherwise 0 (this helps to filter dataview query).