Skip to content

spacewitches/Obsidian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

Manga Script for Obsidian QuickAdd Plugin

Download

Download Script

Description

This is a script based off of the movies script @chhoumann made for the QuickAdd plugin for Obsidian. It does not require an API key, thanks to @jikan-me/the Jikan MyAnimeList API which is publicly accessible.

Disclaimer

This is provided as-is specifically for use with Obsidian and the QuickAdd Plugin. Feel free to modify it for other purposes, but coding is not my day job and I probably won't be able to walk you through it.

This script WILL NOT work for anime or anything outside the manga category on MyAnimeList. It also will not retrieve user information/profiles/lists.

Testing and Debugging

I've only tested this on my machine, which is running macOS Sonoma 14.2, version 1.5.3 of Obsidian, and 1.6.1 of QuickAdd. Please let me know if you encounter any issues.

Installation

This documentation for the movie script is an excellent reference for getting scripts like this working and demonstrating how they might be used.

To just get the script working:
  1. Download the script and put it in your Obsidian Vault. I keep mine in a scripts folder to keep it out of the way and so I don't lose it.
  2. Create your template, or at least the note that will become your template, so you can use it to configure a QuickAdd macro. I've found it's best practice to keep all my templates in the same folder, just like scripts.
  3. Open QuickAdd settings image
  4. Click 'Manage Macros'
  5. Type a name for your macro, mine is 'Add Manga', and click the 'Add Macro' button. Then when its name appears, click the 'Configure' button underneath it.
  6. Click the text field under 'User Scripts', and select the 'manga' script. Click 'Add'. image
  7. In the same window, click on the 'Template' button near the top, this will add an 'Untitled Template Choice'. Click on the cog icon next to it.
  8. Add the template that you made earlier, in the 'Template Path' field. image
  9. Click the button on the 'File Name Format' option and enter {{VALUE:FileName}}. When QuickAdd creates a new note using the script and the template, it's this setting that automatically names it with the title of the book you're adding.
  10. OPTIONAL:
  • As you can see, I have mine set up so that notes created with this template will be placed in a specific folder. This is achieved by using the 'Create in folder' option, typing the folder path into the text box and clicking 'Add'.
  • The 'Choose folder when creating a new note' option means that every time a note is created with this template, there will be a prompt asking you which folder you'd like it to be created in.
  • The 'Include subfolders' option also results in a prompt. For my movie script, I have it set up so that I have a 'Media' folder as my 'Create in Folder', and inside the 'Media' folder, I have a 'Movies' folder and a 'TV' folder. So when I create a new note with that script, I get a prompt asking if I want the new note created in the 'Movies' folder or the 'TV' folder.
  • There's also (not pictured in the screenshots above) an 'Open' option that you can toggle, that will open the new note when it's created.
  • All of these settings can be adjusted later if you're not sure. The only ones that are mandatory for the script to function as intended is the 'Template Path' and the 'File Name Format'.
  1. Close the window, which will bring you back to the previous one, with the macro setttings and the script and the template listed at the top. Close this window as well.
  2. You should be back at the QuickAdd Settings page. Click the dropdown menu next to the 'Add Choice' button, and select 'Macro'. Type the name of your macro in the text field, then click 'Add Choice'. It does not have to be the same name as the macro you just created. This is the command that you'll be able to choose from the command console to run the script. image
  3. Click the cog icon on the same line as the macro that you just created. Select the name of the macro you created earlier from the dropdown list. Close the window then click the lightning bolt icon next to the cog icon. This adds the command to the Obsidian command console.
  4. You can run the script from the console if you've already set up a template. Otherwise it's not going to do much yet.

Templates

Download Sample Template

The sample template includes variables that I've either customized to display correctly with the script, or work fine without modification.

Additional fields would be any variable that is listed on the sidebar under the 'getMangaSearch' heading on the Jikan API documentation. Anything that has subarrays (denoted by the plus signs) is probably not going to display correctly, if at all. While I intend to keep working on this script, I'm not planning on formatting every last field of information available. That being said, I'm open to requests. I just don't want to spend much time on formatting fields that no one's going to use.

Variables

Variables that have been tested:

Variable Contains Property Type
title Default display title on MAL Text
title_english English title Text
japaneseTitle Adds non-English title if there is one. Text
alternateTitles Returns list of all titles available List
authorsReversed All authors/creators, formatted as Firstname Lastname and separated by commas Text
authorsOriginal All authors/creators, formatted as Lastname, Firstname and separated by commas Text
genreList List of genres List
themeList List of themes List
type Type of publication. Manga, manhwa, doujinshi, light novels, etc. Text
cover URL for cover image Text
synopsis Full length description from MAL Text
chapters Number of chapters (this is not always available) Number
volumes Number of volumes (this is not always available) Number

Property Type refers specifically to Frontmatter properties. Frontmatter is very particular about how lists are formatted and they are not interchangeable with text.

Variables that probably work in some capacity but I haven't tested yet:

Variable Contains Type
status Whether or not the title is finished or ongoing String
publishing Whether or not the title is currently being published Boolean
score Average user score on MAL Integer
rank Rank on MAL Integer
popularity Popularity list position on MAL Integer
members Number of membbers that have given the title a score Integer
favorites Number of members that have favorited the title Integer
background Background information on the title, its publication, awards etc. String

Anything that's an integer in the untested list is a bit iffy - if the value is zero or unlisted then it returns a NULL, and what'll happen is that you'll be prompted for that value when the note is being made. You can provide that value or just click enter, but if you click cancel then the note will not be created.

Screenshot

image

Changelog

Version 2:

  • Reworked chapterNumber and volumeNumber so that they will either return a number or 0. Templater is weird about zeros. The fix has the script returning the zero as a string but Frontmatter will recognize it as a number. Users should no longer be prompted for values.
  • Reworked genreList and themeList so that they are formatted as lists in a way that Frontmatter recognizes. They will also now return a value of N/A if none are listed. Users should no longer be prompted for values.
  • summary is now available as a variable. There were formatting issues with the previous version that Frontmatter didn't like, namely parentheses and quotation marks. This variable removes those characters, as (as far as I know) escape characters don't work in Frontmatter.
  • japaneseTitle is now available as a variable. This isn't always Japanese, as some original titles are in Korean. I haven't had issues with characters displaying correctly so far, but if anyone has issues with it please let me know.
  • alternateTitles is now a variable. This is formatted as a list. Some of the titles it returns may be duplicates of others. Because it's a list, it's easy to remove unwanted titles with the Properties View. Each list item should have an x that you can click to remove it.
  • Updated the example template provided. New fields have been added. The way some fields are formatted has changed. Lists do not work correctly if the variable is inside quotation marks. Text/Strings work better with quotation marks.

Additional Documentation/Resources:

Planned Improvements

  • formatting the list of genres so that it can be used as tags
  • formatting the list of themes so it can be used as tags
  • testing other variables like satus & publishing dates

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published