reddit downloader

    Shared 8/11/2025

    256 views

    Visual Workflow

    JSON Code

    {
      "meta": {
        "instanceId": "f41145b0ed0ca785a2544280572131d50c17e21305a491ac87a7816de7f37ece"
      },
      "nodes": [
        {
          "id": "61fe3a12-579c-4515-b733-a5880204b4b6",
          "name": "When clicking ‘Execute workflow’",
          "type": "n8n-nodes-base.manualTrigger",
          "position": [
            -544,
            -128
          ],
          "parameters": {},
          "typeVersion": 1
        },
        {
          "id": "939e20f4-d691-469e-8363-f46a33af7322",
          "name": "HTTP Request",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            -144,
            -48
          ],
          "parameters": {
            "url": "=https://oauth.reddit.com/user/{{$json.username}}/submitted.json",
            "options": {},
            "sendQuery": true,
            "sendHeaders": true,
            "authentication": "predefinedCredentialType",
            "queryParameters": {
              "parameters": [
                {
                  "name": "limit",
                  "value": "100"
                }
              ]
            },
            "headerParameters": {
              "parameters": [
                {
                  "name": "User-Agent",
                  "value": "n8n:n8n media downloader:v1.0 (by /u/BrotherPristine9284)"
                }
              ]
            },
            "nodeCredentialType": "redditOAuth2Api"
          },
          "credentials": {
            "redditOAuth2Api": {
              "id": "18e6M8azwzJxWQwx",
              "name": "Reddit account"
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "1568452c-4c11-4222-a1b7-b5a89023ce52",
          "name": "Code",
          "type": "n8n-nodes-base.code",
          "position": [
            80,
            -48
          ],
          "parameters": {
            "jsCode": "const posts = items[0].json.data.children;\nconst afterToken = items[0].json.data.after;\n\nreturn [{\n    json: {\n        posts: posts,\n        after_token: afterToken\n    }\n}];"
          },
          "typeVersion": 2
        },
        {
          "id": "140fd951-a948-4c53-a10a-44a4e9a0bd19",
          "name": "If",
          "type": "n8n-nodes-base.if",
          "position": [
            288,
            -48
          ],
          "parameters": {
            "options": {},
            "conditions": {
              "options": {
                "version": 2,
                "leftValue": "",
                "caseSensitive": true,
                "typeValidation": "strict"
              },
              "combinator": "and",
              "conditions": [
                {
                  "id": "ef2d0d51-0d1a-4cf4-83ca-f4745e279d52",
                  "operator": {
                    "type": "string",
                    "operation": "notEmpty",
                    "singleValue": true
                  },
                  "leftValue": "={{$json.after_token}}",
                  "rightValue": ""
                }
              ]
            }
          },
          "typeVersion": 2.2
        },
        {
          "id": "10f8b1e2-3f9e-47a4-b19f-f8578984f292",
          "name": "HTTP Request1",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            800,
            -288
          ],
          "parameters": {
            "url": "=https://oauth.reddit.com/user/{{$node[\"Edit Fields\"].json[\"username\"]}}/submitted.json",
            "options": {},
            "sendQuery": true,
            "sendHeaders": true,
            "authentication": "predefinedCredentialType",
            "queryParameters": {
              "parameters": [
                {
                  "name": "limit",
                  "value": "100"
                },
                {
                  "name": "after",
                  "value": "={{ $json.after_token }}"
                }
              ]
            },
            "headerParameters": {
              "parameters": [
                {
                  "name": "User-Agent",
                  "value": "n8n:n8n media downloader:v1.0 (by /u/BrotherPristine9284)"
                }
              ]
            },
            "nodeCredentialType": "redditOAuth2Api"
          },
          "credentials": {
            "redditOAuth2Api": {
              "id": "18e6M8azwzJxWQwx",
              "name": "Reddit account"
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "f7e18f76-9bb8-4109-bff5-e747437c3f3c",
          "name": "Code1",
          "type": "n8n-nodes-base.code",
          "position": [
            592,
            32
          ],
          "parameters": {
            "jsCode": "const posts = items[0].json.posts;\nconst mediaPosts = [];\n\nfor (const post of posts) {\n    const postData = post.data;\n    if (postData.url && (postData.url.includes('.jpg') || postData.url.includes('.jpeg') || postData.url.includes('.png') || postData.url.includes('.gif'))) {\n        mediaPosts.push({\n            json: {\n                title: postData.title,\n                url: postData.url\n            }\n        });\n    } else if (postData.is_video && postData.media) {\n        mediaPosts.push({\n            json: {\n                title: postData.title,\n                url: postData.media.reddit_video.fallback_url\n            }\n        });\n    }\n}\nreturn mediaPosts;"
          },
          "typeVersion": 2
        },
        {
          "id": "60917780-3b27-44df-867e-ca650676b316",
          "name": "HTTP Request2",
          "type": "n8n-nodes-base.httpRequest",
          "position": [
            1120,
            16
          ],
          "parameters": {
            "url": "={{$json.url}}",
            "options": {
              "response": {
                "response": {
                  "responseFormat": "file"
                }
              }
            },
            "sendHeaders": true,
            "headerParameters": {
              "parameters": [
                {
                  "name": "User-Agent",
                  "value": "n8n media downloader:v1.0 (by /u/BrotherPristine9284)"
                },
                {
                  "name": "Accept",
                  "value": "image/webp,image/*"
                }
              ]
            }
          },
          "typeVersion": 4.2
        },
        {
          "id": "74b6c25b-c2a7-4888-900b-30696c2e0b7a",
          "name": "Read/Write Files from Disk",
          "type": "n8n-nodes-base.readWriteFile",
          "position": [
            1328,
            16
          ],
          "parameters": {
            "options": {},
            "fileName": "=/Users/pritamdey47/Documents/reddit_downloads/CharlotteHeaven/{{$json.title.replace(/\\\\|\\/|\\?|:|\\||<|>|\\*|\"/g, \"-\") }}.{{$json.url.split('.').pop()}}",
            "operation": "write"
          },
          "typeVersion": 1
        },
        {
          "id": "4caea15f-1103-4c21-99bb-0d6f45837d8f",
          "name": "Edit Fields",
          "type": "n8n-nodes-base.set",
          "position": [
            -336,
            -144
          ],
          "parameters": {
            "options": {},
            "assignments": {
              "assignments": [
                {
                  "id": "9abecc9f-7118-48ff-8afb-d1b1737e8ae6",
                  "name": "username",
                  "type": "string",
                  "value": "CharlotteHeaven"
                }
              ]
            }
          },
          "typeVersion": 3.4
        },
        {
          "id": "020cb8af-2fb4-47bb-9d3a-2e05d1a5d29b",
          "name": "Loop Over Items",
          "type": "n8n-nodes-base.splitInBatches",
          "position": [
            864,
            0
          ],
          "parameters": {
            "options": {},
            "batchSize": 10
          },
          "typeVersion": 3
        },
        {
          "id": "86d6433e-277c-49db-97bf-79c074e206d8",
          "name": "No Operation, do nothing",
          "type": "n8n-nodes-base.noOp",
          "position": [
            1552,
            16
          ],
          "parameters": {},
          "typeVersion": 1
        }
      ],
      "pinData": {},
      "connections": {
        "If": {
          "main": [
            [
              {
                "node": "HTTP Request1",
                "type": "main",
                "index": 0
              }
            ],
            [
              {
                "node": "Code1",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Code": {
          "main": [
            [
              {
                "node": "If",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Code1": {
          "main": [
            [
              {
                "node": "Loop Over Items",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Edit Fields": {
          "main": [
            [
              {
                "node": "HTTP Request",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "HTTP Request": {
          "main": [
            [
              {
                "node": "Code",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "HTTP Request1": {
          "main": [
            [
              {
                "node": "Code",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "HTTP Request2": {
          "main": [
            [
              {
                "node": "Read/Write Files from Disk",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Loop Over Items": {
          "main": [
            [],
            [
              {
                "node": "HTTP Request2",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "No Operation, do nothing": {
          "main": [
            [
              {
                "node": "Loop Over Items",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "Read/Write Files from Disk": {
          "main": [
            [
              {
                "node": "No Operation, do nothing",
                "type": "main",
                "index": 0
              }
            ]
          ]
        },
        "When clicking ‘Execute workflow’": {
          "main": [
            [
              {
                "node": "Edit Fields",
                "type": "main",
                "index": 0
              }
            ]
          ]
        }
      }
    }