Skip to content

Script for QuickAdd to add links for watching movies to your Obsidian Vault notes.

License

Notifications You must be signed in to change notification settings

lemachinarbo/tmdb-obsidian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

TMDb connection for Obsidian and QuickAdd

tmdb-obsidian is a script for QuickAdd that allows you to add links for watching movies to your Obsidian Vault notes.

By typing the movie's name, it returns the movie details from The Movie Database (TMDb) API and a link to watch the movie on Movie-Web.

This script is a modified version of movies.js by chhoumann.

How to create a list of movies to watch

I use this script to mantain a simple note with my watchlist. While, there are other amazing approaches that you can try to create a personal movie database, where each movie is a note, I prefer not to replicate what's already available on websites as TMDb, IMDB, etc. That's the magic of Obsidian ―you can have it your way.

Demo

demo.webm

Requirements

Step 1: Setup the files

The first step is to copy the script that will help us fetch movie information and create a note to store our movies:

  • Download the tmdb.js and copy it into your vault (e.g. create a /scripts folder and paste it there).
  • Create a new note in your Vault to store the movies (e.g: Movies to watch, Watchlist)

Step 2: Create a macro in QuickAdd

Now, we need to set up a series of actions—searching for the movie, pulling its information, and pasting the details into our watchlist. For this, we can leverage on the Macros feature of QuickAdd. Let's create one:

  • Open the QuickAdd plugin settings (Click on the settings icon or Ctrl + , and then scroll to QuickAdd under Communnity Plugins on the left).
  • Click on Manage Macros button.
  • In the Macro Manager window choose a name for you macro (e.g. movies) and click Add Macro.
  • To setup the Macro click on configure.
  • In the User Scripts option choose the tmdb script and click add.
  • Click on the settings icon ⚙️ to the right of the tmdb script and paste the API Key provided by TMDb (If you don't have one, refer to the requirements section above).

Step 3: Capturing movies data

  • Click the Capture button to add a Capture choice and then click the settings icon ⚙️ besides the new Untitled Capture Choice.

  • Double click the title to rename the choice and add a name (e.g. add movie).

  • Under File Name choose the note you created before to store the movies (e.g. Movies to watch.md).

  • Toggle on the Write to bottom of file option.

  • Toggle on the Capture format option.

  • Copy and paste this format:

    - [{{VALUE:original_title}}]({{VALUE:movieLink}}) ({{VALUE:releaseYear}}) - {{VALUE:directorNames}} - {{VALUE:genre}} -  {{VALUE:rating}}
    

    This will generate

    - [Forrest Gump](https://movie-web.app/media/tmdb-movie-13) (1994) - Robert Zemeckis - Comedy - 8.5
    

To create your own query, check all the variables available.

Step 4: Creating a choice.

Now we need to create a choice to activate the macro:

  • Go back to the QuickAdd Settings menu.
  • Add a name for the macro (e.g: Movie), select Macro in the dropdown and click Add choice.
  • Click on the settings icon ⚙️ besides the new macro and select the macro we created before movies (or the name you choosed). And That's it! Close all the menus and let's add some movies.

Step 5: Testing, adding a movie

  • Open the command palette (Ctrl + p).
  • Type QuickAdd and select QuickAdd: Run QuickAdd and press Enter.
  • Select Movie and press Enter.
  • Type the name of a movie Forrest Gump and press Enter.
  • Select the movie that you want to add, and thats it!

Variables

You can access any of the TMDb variables by using {{VALUE:<variable>}} tag (e.g. {{VALUE:original_title}}). For more information check the TMDb API documentation Here's an example for the movie Forrest Gump:

{
  "adult": false,
  "backdrop_path": "/qdIMHd4sEfJSckfVJfKQvisL02a.jpg",
  "belongs_to_collection": null,
  "budget": 55000000,
  "credits": {
    "cast": [...],  // Array of cast details
    "crew": [...]   // Array of crew details
  },
  "genres": [
    { "id": 35, "name": "Comedy" },
    { "id": 18, "name": "Drama" },
    { "id": 10749, "name": "Romance" }
  ],
  "homepage": "https://www.paramountmovies.com/movies/forrest-gump",
  "id": 13,
  "imdb_id": "tt0109830",
  "original_language": "en",
  "original_title": "Forrest Gump",
  "overview": "A man with a low IQ has accomplished great things in his life...",
  "popularity": 101.714,
  "poster_path": "/arw2vcBveWOVZr6pxd9XTd1TdQa.jpg",
  "production_companies": [...],  // Array of production company details
  "production_countries": [
    { "iso_3166_1": "US", "name": "United States of America" }
  ],
  "release_date": "1994-06-23",
  "revenue": 677387716,
  "runtime": 142,
  "spoken_languages": [
    { "english_name": "English", "iso_639_1": "en", "name": "English" }
  ],
  "status": "Released",
  "tagline": "The world will never be the same once you've seen it through the eyes of Forrest Gump.",
  "title": "Forrest Gump",
  "video": false,
  "vote_average": 8.476,
  "vote_count": 25771
}

Also, you can use any of this custom variables:

{
  "actorLinks": [
    "[[Tom Hanks]]",
    "[[Robin Wright]]",
    "[[Gary Sinise]]",
    "[[Sally Field]]",
    "[[Mykelti Williamson]]",
    // ... (rest of the actor links)
    "[[Bob Hope]]"
  ],
  "actorTopFiveLinks": [
    "[[Tom Hanks]]",
    "[[Robin Wright]]",
    "[[Gary Sinise]]",
    "[[Sally Field]]",
    "[[Mykelti Williamson]]"
  ],
  "directorLinks": [
    "[[Robert Zemeckis]]"
  ],
  "directorNames": "Robert Zemeckis",
  "releaseYear": 1994,
  "genre": "Comedy",
  "genres": [
    "[[Comedy]]",
    "[[Drama]]",
    "[[Romance]]"
  ],
  "movieLink": "https://movie-web.app/media/tmdb-movie-13",
  "fileName": "Forrest Gump",
  "typeLink": "[[Movies]]",
  "poster": "https://image.tmdb.org/t/p/w500/arw2vcBveWOVZr6pxd9XTd1TdQa.jpg",
  "rating": "8.6"
}

About

Script for QuickAdd to add links for watching movies to your Obsidian Vault notes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published