{"id":13466412,"url":"https://github.com/jaruba/stremio-imdb-watchlist","last_synced_at":"2025-06-13T09:40:13.327Z","repository":{"id":86484212,"uuid":"171892667","full_name":"jaruba/stremio-imdb-watchlist","owner":"jaruba","description":"Add-on to create a catalog of your IMDB user watchlist.","archived":false,"fork":false,"pushed_at":"2020-04-21T19:01:22.000Z","size":29,"stargazers_count":16,"open_issues_count":2,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-06T21:21:53.722Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaruba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-02-21T15:04:02.000Z","updated_at":"2024-12-29T21:07:23.000Z","dependencies_parsed_at":"2023-03-02T18:00:29.789Z","dependency_job_id":null,"html_url":"https://github.com/jaruba/stremio-imdb-watchlist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaruba%2Fstremio-imdb-watchlist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaruba%2Fstremio-imdb-watchlist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaruba%2Fstremio-imdb-watchlist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaruba%2Fstremio-imdb-watchlist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaruba","download_url":"https://codeload.github.com/jaruba/stremio-imdb-watchlist/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232944449,"owners_count":18600533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T15:00:43.788Z","updated_at":"2025-01-07T21:59:17.135Z","avatar_url":"https://github.com/jaruba.png","language":"JavaScript","funding_links":[],"categories":["Addon Developer Resources","JavaScript"],"sub_categories":["Catalogs"],"readme":"# Stremio Add-on to Add an IMDB Watchlist as a Catalog\n\nThis is a simple add-on that uses an ajax call to get a list of items from IMDB, then converts those items to Stremio supported Meta Objects.\n\n\n## Using locally\n\n**Pre-requisites: Node.js, Git**\n\n```\ngit clone https://github.com/jaruba/stremio-imdb-watchlist.git\ncd stremio-imdb-watchlist\nnpm i\nnpm start\n```\n\nThis will print `http://127.0.0.1:7505/[imdb-user-id]/manifest.json`. Add a IMDB list id instead of `[imdb-user-id]` in this URL and [load the add-on in Stremio](https://github.com/jaruba/stremio-imdb-watchlist#7-install-add-on-in-stremio).\n\n\n## Using remotely\n\nUse `https://1fe84bc728af-imdb-watchlist.beamup.dev/[imdb-user-id]/manifest.json`. Add a IMDB list id instead of `[imdb-user-id]` in this URL and [load the add-on in Stremio](https://github.com/jaruba/stremio-imdb-watchlist#7-install-add-on-in-stremio).\n\n\n## What is a IMDB List ID\n\nPresuming that the user profile page you want to add is `https://www.imdb.com/user/ur1000000/`, the IMDB user id in this case is `ur1000000`.\n\n\n## How this add-on was made\n\n### 1. Create a `package.json` and add dependencies\n\n```json\n{\n  \"name\": \"stremio-imdb-watchlist\",\n  \"version\": \"0.0.1\",\n  \"description\": \"Add-on to create a catalog of your IMDB user watchlist.\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"node index.js\"\n  },\n  \"dependencies\": {\n    \"needle\": \"^2.2.4\",\n    \"cheerio\": \"1.0.0-rc.2\",\n    \"express\": \"^4.16.4\",\n    \"cors\": \"^2.8.5\",\n    \"named-queue\": \"^2.2.1\"\n  }\n}\n```\n\nWe will use `needle` to make the html page request, `cheerio` to create a jQuery instance of the HTML content, `express` to create the add-on http server, `cors` to easily add CORS to our http server responses and `named-queue` because although we'll get two catalog requests (one for movies and one for series), we only need to do one ajax request as IMDB lists include both. That's where `named-queue` comes in, as it merges tasks by `id`, so we only do one ajax request to respond to both catalog requests.\n\n### 2. Add-on manifest\n\nIn this step, we define the add-on name, description and purpose.\n\nCreate an `index.js` file:\n\n```javascript\nconst manifest = {\n\n  // set add-on id, any string unique between add-ons\n  id: 'org.imdbwatchlist',\n\n  // setting a semver add-on version is mandatory\n  version: '0.0.1',\n\n  // human readable add-on name\n  name: 'IMDB Watchlist Add-on',\n\n  // description of the add-on\n  description: 'Add-on to create a catalog of your IMDB user watchlist.',\n\n  // we only need 'catalog' for this add-on, can also be 'meta', 'stream' and 'subtitles'\n  resources: ['catalog'],\n\n  // we set the add-on types, can also be 'tv', 'channel' and 'other'\n  types: ['movie', 'series'],\n\n  // we define our catalogs, we'll make one for 'movies' and one for 'series'\n  catalogs: [\n    {\n      // id of catalog, any string unique between this add-ons catalogs\n      id: 'imdb-movie-watchlist',\n\n      // human readable catalog name\n      name: 'IMDB Movie Watchlist',\n\n      // the type of this catalog provides\n      type: 'movie'\n    }, {\n      id: 'imdb-series-watchlist',\n      name: 'IMDB Series Watchlist',\n      type: 'series'\n    }\n  ]\n}\n\n\n// create add-on server\nconst express = require('express')\nconst app = express()\nconst cors = require('cors')\n\n// add CORS to server responses\napp.use(cors())\n\n// respond to the manifest request\napp.get('/:imdbUser/manifest.json', (req, res) =\u003e {\n  res.setHeader('Cache-Control', 'max-age=604800') // one week\n  res.setHeader('Content-Type', 'application/json')\n  res.send(manifest)\n})\n```\n\n\n### 3. Get Watchlist ID from User ID\n\nNow we need to get the watchlist ID based on the user ID the add-on user provides.\n\n```javascript\n// we'll use needle to request the HTML page\nconst needle = require('needle')\n\n// we'll use cheerio to create a jQuery instance from the HTML page\nconst cheerio = require('cheerio')\n\n// set request headers to have Chrome Android user agent\nconst headers = {\n  'User-Agent': 'Mozilla/5.0 (Linux; Android 8.0.0; TA-1053 Build/OPR1.170623.026) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3368.0 Mobile Safari/537.36',\n}\n\n// object to cache our watchlist ID based on user ID\nconst cacheLists = {}\n\n// function to get list id from user id\nfunction getListId(userId, cb) {\n\n  // check if it's in cache first\n  if (cacheLists[userId]) {\n    cb(false, cacheLists[userId])\n    return\n  }\n\n  // set request referer to the user page of the user id\n  headers.referer = 'https://m.imdb.com/user/'+userId+'/'\n\n  // set request url, in this case, the watchlist page of the user\n  const getUrl = 'https://m.imdb.com/user/'+userId+'/watchlist/'\n\n  // send request\n  needle.get(getUrl, { headers }, (err, resp) =\u003e {\n    if (!err \u0026\u0026 resp \u0026\u0026 resp.body) {\n\n      // load jQuery instance from the HTML page\n      const $ = cheerio.load(resp.body)\n\n      const listMeta = $('meta[property=\"pageId\"]')\n\n      // check to see if the needed HTML element exists\n      if (!listMeta || listMeta.length != 1) {\n        cb('Error parsing page #1')\n        return\n      }\n\n      // get list id from page\n      const listId = listMeta.attr('content')\n\n      // check list id for sanity\n      if (!listId || !listId.startsWith('ls')) {\n        cb('Error parsing page #2')\n        return\n      }\n\n      // cache list id\n      cacheLists[userId] = listId\n\n      // respond with the list id\n      cb(false, listId)\n\n    } else {\n      // respond with error\n      cb(err || 'Empty html body when requesting list id')\n    }\n  })\n}\n```\n\n### 4. Proxy a Different Add-on to get List Responses Based on List ID\n\nWe won't handle converting IMDB items to Stremio Meta Objects in this guide, we will proxy a different add-on that does this. The secondary add-on will be `stremio-imdb-list`, the source code for it and a guide on how it was made can [found here](https://github.com/jaruba/stremio-imdb-list).\n\n```javascript\n\n// we use `named-queue` to merge more tasks\n// with the same user id\nconst namedQueue = require('named-queue')\n\nconst queue = new namedQueue((task, cb) =\u003e {\n  // get the list id from user id with the\n  // function from the previous step\n  getListId(task.id, cb)\n}, Infinity)\n\n// where the secondary add-on is hosted\nconst listEndpoint = 'https://1fe84bc728af-imdb-list.beamup.dev/'\n\nfunction getList(type, userId, cb) {\n  queue.push({ id: userId }, (listErr, listId) =\u003e {\n    if (listId) {\n      // list id is correct, let's request the\n      // list contents from the secondary add-on\n      const getUrl = listEndpoint + listId + '/date_added/catalog/' + type + '/imdb-' + type + '-list.json'\n      needle.get(getUrl, { headers }, (err, resp) =\u003e {\n        if (err) {\n          // failed, send error\n          cb(err)\n        } else if (!resp || !resp.body) {\n          // failed, send error\n          cb('Empty list response from endpoint')\n        }\n        else {\n          // success, return result\n          cb(false, resp.body)\n        }\n      })\n    } else {\n      // request failed, send error\n      cb(listErr || 'Could not get watchlist id')\n    }\n  })\n}\n```\n\n### 5. Catalog Handler\n\nWe create the catalog handler, get the user id from the user as it's part of the add-on url and merge http requests for the same user id.\n\n```javascript\n// users pass the user id in the add-on url\n// this will be available as `req.params.imdbUser`\napp.get('/:imdbUser/catalog/:type/:id.json', (req, res) =\u003e {\n\n  // handle failures\n  function fail(err) {\n    console.error(err)\n    res.writeHead(500)\n    res.end(JSON.stringify({ err: 'handler error' }))\n  }\n\n  // ensure request parameters are known\n  if (req.params.imdbUser \u0026\u0026 ['movie','series'].indexOf(req.params.type) \u003e -1) {\n    // use function from previous step\n    // to get list items from user id\n    getList(req.params.type, req.params.imdbUser, (err, resp) =\u003e {\n      if (resp) {\n        res.setHeader('Cache-Control', 'max-age=86400') // one day\n        res.setHeader('Content-Type', 'application/json')\n        res.send(resp)\n      } else \n        fail(err)\n    })\n  } else\n    fail('Unknown request parameters')\n})\n\n```\n\n### 6. Run the Add-on Server\n\n```javascript\napp.listen(7505, () =\u003e {\n    console.log('http://127.0.0.1:7505/[imdb-user-id]/manifest.json')\n})\n```\n\n### 7. Install Add-on in Stremio\n\n![addlink](https://user-images.githubusercontent.com/1777923/43146711-65a33ccc-8f6a-11e8-978e-4c69640e63e3.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaruba%2Fstremio-imdb-watchlist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaruba%2Fstremio-imdb-watchlist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaruba%2Fstremio-imdb-watchlist/lists"}