{
  "id": "qXu0tfPcXDGpUc78",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "New 4k Blurays",
  "tags": [
    {
      "id": "XrTXLWIfdhG5osoz",
      "name": "Discord Bot",
      "createdAt": "2025-07-26T13:00:23.072Z",
      "updatedAt": "2025-07-26T13:00:23.072Z"
    }
  ],
  "nodes": [
    {
      "id": "cd316a5a-80f3-426a-9445-1ef353935606",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -128,
        -176
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "a0904d67-33af-48be-9779-ca3dea0eaf31",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -128,
        16
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 23
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a5af30f0-c089-449e-a507-4875bca3fb62",
      "name": "Filter Todays Items",
      "type": "n8n-nodes-base.code",
      "position": [
        816,
        -80
      ],
      "parameters": {
        "jsCode": "function isValidDate(str) {\n  const date = new Date(str);\n  return !isNaN(date.getTime());\n}\n\nlet activeDate = \"\";\nlet preOrders = [];\nfor (const item of $input.first().json.links) {\n  if (isValidDate(item)) {\n    activeDate = item;\n  } else {  \n    // if the current activeDate is todays date, grab the item\n    if (activeDate === $('Format Todays Date').first().json.formattedDate) {\n      preOrders.push(item.substring(item.indexOf(\"]\")+1));\n    }\n  }\n}\n\nreturn [\n  {\n    json: {\n      items: preOrders\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "022e701c-0396-4cc7-a2cd-d19ca8674ccc",
      "name": "Format Todays Date",
      "type": "n8n-nodes-base.code",
      "position": [
        144,
        -80
      ],
      "parameters": {
        "jsCode": "const today = new Date();\nconst formatted = today.toLocaleDateString('en-US', {\n  year: 'numeric',\n  month: 'long',\n  day: '2-digit',\n  timeZone: 'America/New_York'\n});\n\nreturn [{ json: { formattedDate: formatted } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "5e895cde-5267-4a75-b591-9ef2878f3336",
      "name": "Scrape Page",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        368,
        -80
      ],
      "parameters": {
        "url": "https://www.blu-ray.com/movies/movies.php?show=newpreorders",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "37894741-4b1f-4a83-bd1b-5fb48e223f02",
      "name": "Get Hyperlinks",
      "type": "n8n-nodes-base.html",
      "position": [
        592,
        -80
      ],
      "parameters": {
        "options": {},
        "operation": "extractHtmlContent",
        "extractionValues": {
          "values": [
            {
              "key": "links",
              "cssSelector": "td[width=728]>h3, td[width=728]>div div",
              "returnArray": true,
              "returnValue": "html"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "4f621c43-bdc5-45c4-b9d4-185c1ae2c7cd",
      "name": "Format Message",
      "type": "n8n-nodes-base.code",
      "position": [
        1040,
        -80
      ],
      "parameters": {
        "jsCode": "function extractTitleAndHref(htmlString) {\n  const hrefStart = htmlString.indexOf('href=\"') + 6;\n  const hrefEnd = htmlString.indexOf('\"', hrefStart);\n  const href = htmlString.substring(hrefStart, hrefEnd);\n\n  const titleStart = htmlString.indexOf('title=\"') + 7;\n  const titleEnd = htmlString.indexOf('\"', titleStart);\n  const title = htmlString.substring(titleStart, titleEnd);\n\n  return { title, href };\n}\n\nlet message = \"*New 4k Preorders Today!*\\n\"\n\nfor (const link of $input.first().json.items) {\n  let anchor = extractTitleAndHref(link);\n  \n  message += \"[\" + anchor.title + \"](\" + anchor.href + \")\\n\";\n}\n\nreturn [{json: { message: message.substring(0,2000) }}];"
      },
      "typeVersion": 2
    },
    {
      "id": "4a183f69-e7c8-4dec-9539-c06aa54403b4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -192
      ],
      "parameters": {
        "color": 3,
        "width": 192,
        "height": 256,
        "content": "### To Do:\nUpdate this to be set to your correct TimeZone."
      },
      "typeVersion": 1
    },
    {
      "id": "65f6e537-25a4-4172-95b1-f00ce88ba963",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -208
      ],
      "parameters": {
        "color": 3,
        "width": 208,
        "height": 272,
        "content": "### To Do:\nConnect to your Discord channel webhook here:"
      },
      "typeVersion": 1
    },
    {
      "id": "cce9e2db-c782-42e8-be70-2b6fc284526a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        -208
      ],
      "parameters": {
        "color": 5,
        "width": 192,
        "height": 272,
        "content": "### Optional:\nAdjust the formatting of the message that gets posted to Discord:"
      },
      "typeVersion": 1
    },
    {
      "id": "608c52a5-f4c8-494f-97d7-6e2781cede4d",
      "name": "Post to Discord",
      "type": "n8n-nodes-base.discord",
      "position": [
        1264,
        -80
      ],
      "parameters": {
        "content": "={{ $json.message }}",
        "options": {},
        "authentication": "webhook"
      },
      "credentials": {
        "discordWebhookApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "4493320f-25af-4e7e-83cd-36e59a46ed49",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -16
      ],
      "parameters": {
        "width": 192,
        "height": 256,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n### Note:\nThis is scheduled to run every day at 11pm.\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8c88d280-3fc6-452e-b0d6-b6168c6f6bb2",
  "connections": {
    "Scrape Page": {
      "main": [
        [
          {
            "node": "Get Hyperlinks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Message": {
      "main": [
        [
          {
            "node": "Post to Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Hyperlinks": {
      "main": [
        [
          {
            "node": "Filter Todays Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Format Todays Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Todays Date": {
      "main": [
        [
          {
            "node": "Scrape Page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Todays Items": {
      "main": [
        [
          {
            "node": "Format Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Format Todays Date",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}