diff --git a/n8n/FileBot_Cover_Backfill.json b/n8n/FileBot_Cover_Backfill.json new file mode 100644 index 0000000..167e2af --- /dev/null +++ b/n8n/FileBot_Cover_Backfill.json @@ -0,0 +1,2402 @@ +{ + "name": "FileBot Cover Backfill", + "nodes": [ + { + "parameters": { + "httpMethod": "POST", + "path": "b7c3b93a-1a93-47ad-afdf-ea54a131c064", + "options": {} + }, + "type": "n8n-nodes-base.webhook", + "typeVersion": 2.1, + "position": [ + -752, + -320 + ], + "id": "f5b64bb7-8ba5-4c0b-bba0-45961748afd3", + "name": "Webhook", + "webhookId": "b7c3b93a-1a93-47ad-afdf-ea54a131c064", + "disabled": true + }, + { + "parameters": { + "content": "## FileBot Binding\n[Link](https://www.filebot.net/naming.html#bindings)", + "height": 80, + "width": 208 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -784, + -512 + ], + "id": "feb198cd-4c0c-43f0-9458-e7a2445a057e", + "name": "Sticky Note" + }, + { + "parameters": { + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "movie_rating": "={{ $json.body.movie_rating }}", + "file_name_original": "={{ $json.body.FileNameOriginal }}", + "file_name_new": "={{ $json.body.FileNameNew }}", + "movie_votes": "={{ $json.body.movie_votes }}", + "video_compression_format": "={{ $json.body.video_compression_format }}", + "container_format": "={{ $json.body.container_format }}", + "audio_codec": "={{ $json.body.audio_codec }}", + "video_codec_library": "={{ $json.body.video_codec_library }}", + "standard_video_format": "={{ $json.body.standard_video_format }}", + "fourk_resolution": "={{ $json.body.fourk_resolution }}", + "exact_video_format": "={{ $json.body.exact_video_format }}", + "audio_bitrate": "={{ $json.body.audio_bitrate }}", + "video_bitrate": "={{ $json.body.video_bitrate }}", + "overall_bitrate": "={{ $json.body.overall_bitrate }}", + "dolby_vision": "={{ $json.body.dolby_vision }}", + "high_dynamic_range": "={{ $json.body.high_dynamic_range }}", + "video_bitdepth": "={{ $json.body.video_bitdepth }}", + "video_height": "={{ $json.body.video_height }}", + "video_width": "={{ $json.body.video_width }}", + "video_resolution": "={{ $json.body.video_resolution }}", + "audio_channel_layout": "={{ $json.body.audio_channel_layout }}", + "audio_channel_count": "={{ $json.body.audio_channel_count }}", + "audio_channel_format": "={{ $json.body.audio_channel_format }}", + "audio_codec_profile": "={{ $json.body.audio_codec_profile }}", + "themoviedb_id": "={{ $json.body.themoviedb_id }}", + "imdb_id": "={{ $json.body.imdb_id }}", + "thetvdb_id": "={{ $json.body.thetvdb_id }}", + "object_type": "={{ $json.body.object_type }}" + }, + "matchingColumns": [ + "id" + ], + "schema": [ + { + "id": "id", + "displayName": "id", + "required": false, + "defaultMatch": true, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "file_name_original", + "displayName": "file_name_original", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "file_name_new", + "displayName": "file_name_new", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "movie_rating", + "displayName": "movie_rating", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "movie_votes", + "displayName": "movie_votes", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_compression_format", + "displayName": "video_compression_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_codec_library", + "displayName": "video_codec_library", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec", + "displayName": "audio_codec", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "container_format", + "displayName": "container_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "standard_video_format", + "displayName": "standard_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "exact_video_format", + "displayName": "exact_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "fourk_resolution", + "displayName": "fourk_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec_profile", + "displayName": "audio_codec_profile", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_format", + "displayName": "audio_channel_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_count", + "displayName": "audio_channel_count", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_layout", + "displayName": "audio_channel_layout", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_resolution", + "displayName": "video_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_width", + "displayName": "video_width", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_height", + "displayName": "video_height", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_bitdepth", + "displayName": "video_bitdepth", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "high_dynamic_range", + "displayName": "high_dynamic_range", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "dolby_vision", + "displayName": "dolby_vision", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "overall_bitrate", + "displayName": "overall_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_bitrate", + "displayName": "video_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_bitrate", + "displayName": "audio_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "created_at", + "displayName": "created_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "seen_at", + "displayName": "seen_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "themoviedb_id", + "displayName": "themoviedb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "thetvdb_id", + "displayName": "thetvdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "imdb_id", + "displayName": "imdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "cover_url", + "displayName": "cover_url", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "object_type", + "displayName": "object_type", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -496, + -320 + ], + "id": "3fc2a5b5-e4fd-4a01-bbf2-cfc24d94299b", + "name": "Insert rows in a table", + "disabled": true + }, + { + "parameters": { + "operation": "select", + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "returnAll": true, + "where": { + "values": [ + { + "column": "cover_url", + "condition": "IS NULL" + }, + { + "column": "thetvdb_id", + "condition": "IS NOT NULL" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -560, + -96 + ], + "id": "4a1dd71e-43ea-4eb2-8f12-cfc60263296c", + "name": "Select rows from a table", + "disabled": true + }, + { + "parameters": { + "batchSize": 10, + "options": {} + }, + "type": "n8n-nodes-base.splitInBatches", + "typeVersion": 3, + "position": [ + -352, + -96 + ], + "id": "7c36ddb0-c817-451b-adff-6b496c2673d2", + "name": "Loop Over Items", + "disabled": true + }, + { + "parameters": { + "operation": "update", + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "id": "={{ $('Loop Over Items').item.json.id }}", + "cover_url": "={{ $json.image.poster }}" + }, + "matchingColumns": [ + "id" + ], + "schema": [ + { + "id": "id", + "displayName": "id", + "required": false, + "defaultMatch": true, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "file_name_original", + "displayName": "file_name_original", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "file_name_new", + "displayName": "file_name_new", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "movie_rating", + "displayName": "movie_rating", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "movie_votes", + "displayName": "movie_votes", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_compression_format", + "displayName": "video_compression_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_codec_library", + "displayName": "video_codec_library", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_codec", + "displayName": "audio_codec", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "container_format", + "displayName": "container_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "standard_video_format", + "displayName": "standard_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "exact_video_format", + "displayName": "exact_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "fourk_resolution", + "displayName": "fourk_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_codec_profile", + "displayName": "audio_codec_profile", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_channel_format", + "displayName": "audio_channel_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_channel_count", + "displayName": "audio_channel_count", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_channel_layout", + "displayName": "audio_channel_layout", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_resolution", + "displayName": "video_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_width", + "displayName": "video_width", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_height", + "displayName": "video_height", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_bitdepth", + "displayName": "video_bitdepth", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "high_dynamic_range", + "displayName": "high_dynamic_range", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "dolby_vision", + "displayName": "dolby_vision", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "overall_bitrate", + "displayName": "overall_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "video_bitrate", + "displayName": "video_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "audio_bitrate", + "displayName": "audio_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "created_at", + "displayName": "created_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "seen_at", + "displayName": "seen_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "themoviedb_id", + "displayName": "themoviedb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "thetvdb_id", + "displayName": "thetvdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "imdb_id", + "displayName": "imdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "cover_url", + "displayName": "cover_url", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + 912, + -80 + ], + "id": "004f6ce3-6963-4607-a5f8-43ce04df3454", + "name": "Update rows in a table", + "disabled": true + }, + { + "parameters": { + "rule": { + "interval": [ + { + "field": "minutes", + "minutesInterval": 2 + } + ] + } + }, + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.3, + "position": [ + -752, + -96 + ], + "id": "881a69cb-1bab-4dd4-8fb1-b0864f9563e7", + "name": "Schedule Trigger", + "disabled": true + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $json.object_type }}", + "rightValue": "Movie", + "operator": { + "type": "string", + "operation": "equals" + }, + "id": "ac38a6e6-583b-4f75-a86c-85b611cbdccc" + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "696a3cdb-33d8-4a87-947a-79df6b932b4f", + "leftValue": "={{ $json.object_type }}", + "rightValue": "Episode", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "6df9991d-5be9-46b4-beb5-cfbed6931e85", + "leftValue": "={{ $json.object_type }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "empty", + "singleValue": true + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -32, + -96 + ], + "id": "c7b75fce-baa0-4de6-9077-c6dc8423bccb", + "name": "Switch", + "disabled": true + }, + { + "parameters": { + "url": "=https://api.tvmaze.com/lookup/shows?thetvdb={{ $('Select rows from a table').item.json.thetvdb_id }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + -80 + ], + "id": "7345fb54-37f4-41c3-8c71-c54d906efc9a", + "name": "HTTP Request tvmaze", + "disabled": true + }, + { + "parameters": { + "url": "=https://www.omdbapi.com/?i={{ $json.imdb_id }}&apikey=dfd46af2", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + -224 + ], + "id": "bcb95aa0-2eb4-4b4c-933d-4391b68efc4c", + "name": "HTTP Request omdbapi", + "disabled": true + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "3516a7d0-ae39-4fc3-be1f-e984f9d3e8d6", + "name": "image.poster", + "value": "={{ $json.Poster }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + -224 + ], + "id": "f459dd59-6261-446b-9b2b-382a9bed43af", + "name": "Edit Fields", + "disabled": true + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "28227e53-46c1-48a1-ad16-d197aa7398bf", + "name": "image.poster", + "value": "={{ $json.image.medium }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + -80 + ], + "id": "5292cef8-4a4d-4e71-b1b9-6a9f240df994", + "name": "Edit Fields1", + "disabled": true + }, + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [ + -752, + 64 + ], + "id": "efdd8a4b-2768-481b-9df6-2db0adae92d5", + "name": "When clicking ‘Execute workflow’", + "disabled": true + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "7cbb1b8f-2cad-438f-948c-6664b86c8a87", + "leftValue": "={{ $('Select rows from a table').item.json.thetvdb_id }}", + "rightValue": 0, + "operator": { + "type": "number", + "operation": "gt" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + 240, + -80 + ], + "id": "ce9b2259-3743-4e7d-b29f-839ac3115070", + "name": "If", + "disabled": true + }, + { + "parameters": { + "operation": "executeQuery", + "query": "-- SCHEMA: n8n\n\n-- DROP SCHEMA IF EXISTS n8n ;\n\nCREATE SCHEMA IF NOT EXISTS n8n\n AUTHORIZATION n8n_filebot;\n\nGRANT ALL ON SCHEMA n8n TO n8n_filebot WITH GRANT OPTION;\n\n-- Table: n8n.movie_files\n\n-- DROP TABLE IF EXISTS n8n.movie_files;\n\nCREATE TABLE IF NOT EXISTS n8n.movie_files\n(\n id bigint NOT NULL DEFAULT nextval('n8n.movie_files_id_seq'::regclass),\n file_name_original text COLLATE pg_catalog.\"default\" NOT NULL,\n file_name_new text COLLATE pg_catalog.\"default\" NOT NULL,\n movie_rating numeric(3,1),\n movie_votes integer,\n video_compression_format text COLLATE pg_catalog.\"default\",\n video_codec_library text COLLATE pg_catalog.\"default\",\n audio_codec text COLLATE pg_catalog.\"default\",\n container_format text COLLATE pg_catalog.\"default\",\n standard_video_format text COLLATE pg_catalog.\"default\",\n exact_video_format text COLLATE pg_catalog.\"default\",\n fourk_resolution text COLLATE pg_catalog.\"default\",\n audio_codec_profile text COLLATE pg_catalog.\"default\",\n audio_channel_format text COLLATE pg_catalog.\"default\",\n audio_channel_count text COLLATE pg_catalog.\"default\",\n audio_channel_layout text COLLATE pg_catalog.\"default\",\n video_resolution text COLLATE pg_catalog.\"default\",\n video_width integer,\n video_height integer,\n video_bitdepth integer,\n high_dynamic_range text COLLATE pg_catalog.\"default\",\n dolby_vision text COLLATE pg_catalog.\"default\",\n overall_bitrate text COLLATE pg_catalog.\"default\",\n video_bitrate text COLLATE pg_catalog.\"default\",\n audio_bitrate text COLLATE pg_catalog.\"default\",\n created_at timestamp with time zone DEFAULT now(),\n seen_at timestamp with time zone,\n themoviedb_id integer,\n thetvdb_id integer,\n imdb_id text COLLATE pg_catalog.\"default\",\n cover_url text COLLATE pg_catalog.\"default\",\n object_type text COLLATE pg_catalog.\"default\",\n CONSTRAINT movie_files_pkey PRIMARY KEY (id)\n)\n\nTABLESPACE pg_default;\n\nALTER TABLE IF EXISTS n8n.movie_files\n OWNER to postgres;\n\nGRANT ALL ON TABLE n8n.movie_files TO n8n_filebot WITH GRANT OPTION;\n\nGRANT ALL ON TABLE n8n.movie_files TO postgres;\n\nCOMMENT ON COLUMN n8n.movie_files.seen_at\n IS 'NULL = noch nicht gesehen; gesetzt = Zeitpunkt der Ansicht in der Web-UI';\n-- Index: idx_movie_files_seen_at\n\n-- DROP INDEX IF EXISTS n8n.idx_movie_files_seen_at;\n\nCREATE INDEX IF NOT EXISTS idx_movie_files_seen_at\n ON n8n.movie_files USING btree\n (seen_at ASC NULLS LAST)\n TABLESPACE pg_default;\n-- Index: idx_movie_files_unseen\n\n-- DROP INDEX IF EXISTS n8n.idx_movie_files_unseen;\n\nCREATE INDEX IF NOT EXISTS idx_movie_files_unseen\n ON n8n.movie_files USING btree\n (created_at DESC NULLS FIRST)\n TABLESPACE pg_default\n WHERE seen_at IS NULL;", + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -496, + -512 + ], + "id": "ed4d623a-5783-4baf-a7ea-747d65b66aac", + "name": "SQL query CREATE", + "disabled": true + }, + { + "parameters": { + "url": "={{ $json['image']['poster'] }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 880, + 784 + ], + "id": "a10b5217-2bc0-4cc1-9b00-53921bde15ec", + "name": "Download Cover (Movie)", + "continueOnFail": true + }, + { + "parameters": { + "jsCode": "const item = $input.first();\nlet coverBase64 = null;\nlet coverMimeType = null;\n\nif (item.binary && item.binary.data) {\n coverMimeType = item.binary.data.mimeType || 'image/jpeg';\n const buffer = await this.helpers.getBinaryDataBuffer(0, 'data');\n coverBase64 = buffer.toString('base64');\n}\n\nreturn [{\n json: {\n cover_url: $('Edit Fields2').item.json['image']['poster'] || null,\n cover_base64: coverBase64,\n cover_mime_type: coverMimeType,\n record_id: $('Loop Over Items1').item.json.id,\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1088, + 784 + ], + "id": "0d0f6b44-7589-4b6f-b542-1a5aa2741ea9", + "name": "Prepare Cover Data (Movie)" + }, + { + "parameters": { + "url": "={{ $json['image']['poster'] }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 880, + 928 + ], + "id": "3038ee25-fcbc-4e31-816b-5e26b28a9bfe", + "name": "Download Cover (Episode)", + "continueOnFail": true + }, + { + "parameters": { + "jsCode": "const item = $input.first();\nlet coverBase64 = null;\nlet coverMimeType = null;\n\nif (item.binary && item.binary.data) {\n coverMimeType = item.binary.data.mimeType || 'image/jpeg';\n const buffer = await this.helpers.getBinaryDataBuffer(0, 'data');\n coverBase64 = buffer.toString('base64');\n}\n\nreturn [{\n json: {\n cover_url: $('Edit Fields3').item.json['image']['poster'] || null,\n cover_base64: coverBase64,\n cover_mime_type: coverMimeType,\n record_id: $('Loop Over Items1').item.json.id,\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1088, + 928 + ], + "id": "51d21c85-cff7-4932-9ba9-6bcd9d91a7d7", + "name": "Prepare Cover Data (Episode)" + }, + { + "parameters": { + "operation": "executeQuery", + "query": "UPDATE n8n.movie_files\nSET\n cover_url = $1,\n cover_image = CASE WHEN $2::text IS NOT NULL THEN decode($2, 'base64') ELSE NULL END,\n cover_mime_type = $3\nWHERE id = $4", + "options": { + "queryReplacement": "={{ [$json.cover_url, $json.cover_base64, $json.cover_mime_type, $json.record_id] }}" + } + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + 1296, + 864 + ], + "id": "930c9173-71fb-48c8-86fd-68d0a5af9b90", + "name": "Speichere Cover in DB" + }, + { + "parameters": { + "httpMethod": "POST", + "path": "b7c3b93a-1a93-47ad-afdf-ea54a131c064", + "options": {} + }, + "type": "n8n-nodes-base.webhook", + "typeVersion": 2.1, + "position": [ + -752, + 576 + ], + "id": "d614f62f-7d07-4c51-b861-f110d32f87db", + "name": "Webhook1", + "webhookId": "b7c3b93a-1a93-47ad-afdf-ea54a131c064" + }, + { + "parameters": { + "content": "## FileBot Binding\n[Link](https://www.filebot.net/naming.html#bindings)", + "height": 80, + "width": 208 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -784, + 352 + ], + "id": "8a6d2682-0d06-4a55-888f-fdf45bba05b4", + "name": "Sticky Note1" + }, + { + "parameters": { + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "movie_rating": "={{ $json.body.movie_rating }}", + "file_name_original": "={{ $json.body.FileNameOriginal }}", + "file_name_new": "={{ $json.body.FileNameNew }}", + "movie_votes": "={{ $json.body.movie_votes }}", + "video_compression_format": "={{ $json.body.video_compression_format }}", + "container_format": "={{ $json.body.container_format }}", + "audio_codec": "={{ $json.body.audio_codec }}", + "video_codec_library": "={{ $json.body.video_codec_library }}", + "standard_video_format": "={{ $json.body.standard_video_format }}", + "fourk_resolution": "={{ $json.body.fourk_resolution }}", + "exact_video_format": "={{ $json.body.exact_video_format }}", + "audio_bitrate": "={{ $json.body.audio_bitrate }}", + "video_bitrate": "={{ $json.body.video_bitrate }}", + "overall_bitrate": "={{ $json.body.overall_bitrate }}", + "dolby_vision": "={{ $json.body.dolby_vision }}", + "high_dynamic_range": "={{ $json.body.high_dynamic_range }}", + "video_bitdepth": "={{ $json.body.video_bitdepth }}", + "video_height": "={{ $json.body.video_height }}", + "video_width": "={{ $json.body.video_width }}", + "video_resolution": "={{ $json.body.video_resolution }}", + "audio_channel_layout": "={{ $json.body.audio_channel_layout }}", + "audio_channel_count": "={{ $json.body.audio_channel_count }}", + "audio_channel_format": "={{ $json.body.audio_channel_format }}", + "audio_codec_profile": "={{ $json.body.audio_codec_profile }}", + "themoviedb_id": "={{ $json.body.themoviedb_id }}", + "imdb_id": "={{ $json.body.imdb_id }}", + "thetvdb_id": "={{ $json.body.thetvdb_id }}", + "object_type": "={{ $json.body.object_type }}" + }, + "matchingColumns": [ + "id" + ], + "schema": [ + { + "id": "id", + "displayName": "id", + "required": false, + "defaultMatch": true, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "file_name_original", + "displayName": "file_name_original", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "file_name_new", + "displayName": "file_name_new", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "movie_rating", + "displayName": "movie_rating", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "movie_votes", + "displayName": "movie_votes", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_compression_format", + "displayName": "video_compression_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_codec_library", + "displayName": "video_codec_library", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec", + "displayName": "audio_codec", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "container_format", + "displayName": "container_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "standard_video_format", + "displayName": "standard_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "exact_video_format", + "displayName": "exact_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "fourk_resolution", + "displayName": "fourk_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec_profile", + "displayName": "audio_codec_profile", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_format", + "displayName": "audio_channel_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_count", + "displayName": "audio_channel_count", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_layout", + "displayName": "audio_channel_layout", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_resolution", + "displayName": "video_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_width", + "displayName": "video_width", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_height", + "displayName": "video_height", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_bitdepth", + "displayName": "video_bitdepth", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "high_dynamic_range", + "displayName": "high_dynamic_range", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "dolby_vision", + "displayName": "dolby_vision", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "overall_bitrate", + "displayName": "overall_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_bitrate", + "displayName": "video_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_bitrate", + "displayName": "audio_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "created_at", + "displayName": "created_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "seen_at", + "displayName": "seen_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "themoviedb_id", + "displayName": "themoviedb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "thetvdb_id", + "displayName": "thetvdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "imdb_id", + "displayName": "imdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "cover_url", + "displayName": "cover_url", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "object_type", + "displayName": "object_type", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -496, + 576 + ], + "id": "7f7624f6-e3fa-4c00-a025-99391813dbe4", + "name": "Insert rows in a table1" + }, + { + "parameters": { + "operation": "select", + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "returnAll": true, + "where": { + "values": [ + { + "column": "cover_url", + "condition": "IS NULL" + }, + { + "column": "thetvdb_id", + "condition": "IS NOT NULL" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -560, + 912 + ], + "id": "1154c504-5cb3-493f-8f58-93efc0fb3d7e", + "name": "Select rows from a table1" + }, + { + "parameters": { + "batchSize": 10, + "options": {} + }, + "type": "n8n-nodes-base.splitInBatches", + "typeVersion": 3, + "position": [ + -352, + 912 + ], + "id": "79222ad2-245a-4217-97c3-7755fa1d1edd", + "name": "Loop Over Items1" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $json.object_type }}", + "rightValue": "Movie", + "operator": { + "type": "string", + "operation": "equals" + }, + "id": "ac38a6e6-583b-4f75-a86c-85b611cbdccc" + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "696a3cdb-33d8-4a87-947a-79df6b932b4f", + "leftValue": "={{ $json.object_type }}", + "rightValue": "Episode", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "6df9991d-5be9-46b4-beb5-cfbed6931e85", + "leftValue": "={{ $json.object_type }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "empty", + "singleValue": true + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -32, + 912 + ], + "id": "7cf50e16-d870-4170-a71b-d36f53589135", + "name": "Switch1" + }, + { + "parameters": { + "url": "=https://api.tvmaze.com/lookup/shows?thetvdb={{ $('Select rows from a table1').item.json.thetvdb_id }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + 928 + ], + "id": "d00062c5-8def-44f6-8a3e-6ee333dc2893", + "name": "HTTP Request tvmaze1" + }, + { + "parameters": { + "url": "=https://www.omdbapi.com/?i={{ $json.imdb_id }}&apikey=dfd46af2", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + 784 + ], + "id": "b1a7f1e7-f733-4d40-b1c7-dd8aabddb900", + "name": "HTTP Request omdbapi1" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "3516a7d0-ae39-4fc3-be1f-e984f9d3e8d6", + "name": "image.poster", + "value": "={{ $json.Poster }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + 784 + ], + "id": "b2eccc42-17be-4f1d-9aca-d1db48b81042", + "name": "Edit Fields2" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "28227e53-46c1-48a1-ad16-d197aa7398bf", + "name": "image.poster", + "value": "={{ $json.image.medium }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + 928 + ], + "id": "63ccad9e-4461-4b7b-a221-0aa6976c80df", + "name": "Edit Fields3" + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "7cbb1b8f-2cad-438f-948c-6664b86c8a87", + "leftValue": "={{ $('Select rows from a table1').item.json.thetvdb_id }}", + "rightValue": 0, + "operator": { + "type": "number", + "operation": "gt" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + 240, + 928 + ], + "id": "f411ee16-60fa-4eb8-ad44-71bedd6ff835", + "name": "If1" + }, + { + "parameters": { + "operation": "executeQuery", + "query": "-- SCHEMA: n8n\n\nCREATE SCHEMA IF NOT EXISTS n8n AUTHORIZATION n8n_filebot;\nGRANT ALL ON SCHEMA n8n TO n8n_filebot WITH GRANT OPTION;\n\nCREATE SEQUENCE IF NOT EXISTS n8n.movie_files_id_seq;\n\nCREATE TABLE IF NOT EXISTS n8n.movie_files\n(\n id bigint NOT NULL DEFAULT nextval('n8n.movie_files_id_seq'::regclass),\n file_name_original text NOT NULL,\n file_name_new text NOT NULL,\n movie_rating numeric(3,1),\n movie_votes integer,\n video_compression_format text,\n video_codec_library text,\n audio_codec text,\n container_format text,\n standard_video_format text,\n exact_video_format text,\n fourk_resolution text,\n audio_codec_profile text,\n audio_channel_format text,\n audio_channel_count text,\n audio_channel_layout text,\n video_resolution text,\n video_width integer,\n video_height integer,\n video_bitdepth integer,\n high_dynamic_range text,\n dolby_vision text,\n overall_bitrate text,\n video_bitrate text,\n audio_bitrate text,\n created_at timestamp with time zone DEFAULT now(),\n seen_at timestamp with time zone,\n themoviedb_id integer,\n thetvdb_id integer,\n imdb_id text,\n cover_url text,\n object_type text,\n cover_image bytea COMPRESSION lz4,\n cover_mime_type text,\n CONSTRAINT movie_files_pkey PRIMARY KEY (id)\n)\nTABLESPACE pg_default;\n\nALTER TABLE IF EXISTS n8n.movie_files OWNER TO postgres;\nGRANT ALL ON TABLE n8n.movie_files TO n8n_filebot WITH GRANT OPTION;\nGRANT ALL ON TABLE n8n.movie_files TO postgres;\nGRANT ALL ON SEQUENCE n8n.movie_files_id_seq TO n8n_filebot WITH GRANT OPTION;\n\nCOMMENT ON COLUMN n8n.movie_files.seen_at\n IS 'NULL = noch nicht gesehen; gesetzt = Zeitpunkt der Ansicht in der Web-UI';\n\nCOMMENT ON COLUMN n8n.movie_files.cover_image\n IS 'Cover-Bild als BYTEA (LZ4-komprimiert); NULL wenn noch nicht geladen';\n\nCREATE INDEX IF NOT EXISTS idx_movie_files_seen_at\n ON n8n.movie_files USING btree (seen_at ASC NULLS LAST)\n TABLESPACE pg_default;\n\nCREATE INDEX IF NOT EXISTS idx_movie_files_unseen\n ON n8n.movie_files USING btree (created_at DESC NULLS FIRST)\n TABLESPACE pg_default\n WHERE seen_at IS NULL;\n\nCREATE INDEX IF NOT EXISTS idx_movie_files_cover_missing\n ON n8n.movie_files USING btree (id)\n TABLESPACE pg_default\n WHERE cover_image IS NULL AND cover_url IS NOT NULL;", + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -480, + 352 + ], + "id": "3742ab4a-4eb6-423b-94c8-79ae0c267bc3", + "name": "SQL query CREATE1", + "disabled": true + }, + { + "parameters": { + "rule": { + "interval": [ + { + "field": "hours" + } + ] + } + }, + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.3, + "position": [ + -752, + 1264 + ], + "id": "f47b3345-c0cf-4ba9-a8ce-4da74b2a2f67", + "name": "Stündlich" + }, + { + "parameters": { + "operation": "select", + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "returnAll": true, + "where": { + "values": [ + { + "column": "cover_image", + "condition": "IS NULL" + }, + { + "column": "cover_url", + "condition": "IS NOT NULL" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -528, + 1264 + ], + "id": "73e98917-8bad-4dfb-b701-ce4a8893b0ac", + "name": "Einträge ohne Bild laden" + }, + { + "parameters": { + "url": "={{ $json.cover_url }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + -48, + 1264 + ], + "id": "2862d440-446a-4782-a543-72180484c149", + "name": "Bild herunterladen", + "continueOnFail": true + }, + { + "parameters": { + "jsCode": "const item = $input.first();\nlet coverBase64 = null;\nlet coverMimeType = null;\n\nif (item.binary && item.binary.data) {\n coverMimeType = item.binary.data.mimeType || 'image/jpeg';\n const buffer = await this.helpers.getBinaryDataBuffer(0, 'data');\n coverBase64 = buffer.toString('base64');\n}\n\nreturn [{\n json: {\n record_id: $('Loop Over Items2').item.json.id,\n cover_url: $('Loop Over Items2').item.json.cover_url,\n cover_base64: coverBase64,\n cover_mime_type: coverMimeType,\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 192, + 1264 + ], + "id": "acdab9ef-0fd1-4e6b-9583-e448373d41ad", + "name": "Base64 extrahieren" + }, + { + "parameters": { + "operation": "executeQuery", + "query": "UPDATE n8n.movie_files\nSET\n cover_image = CASE WHEN $1::text IS NOT NULL THEN decode($1, 'base64') ELSE NULL END,\n cover_mime_type = $2\nWHERE id = $3", + "options": { + "queryReplacement": "={{ [$json.cover_base64, $json.cover_mime_type, $json.record_id] }}" + } + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + 432, + 1264 + ], + "id": "9b12dc99-14b5-4b14-9179-e8d415b6a524", + "name": "Bild in DB speichern" + }, + { + "parameters": { + "batchSize": 5, + "options": {} + }, + "type": "n8n-nodes-base.splitInBatches", + "typeVersion": 3, + "position": [ + -288, + 1264 + ], + "id": "926ce370-3061-4c8a-a5b1-00488f085e7a", + "name": "Loop Over Items2" + }, + { + "parameters": { + "content": "## Downloader if value NULL in binary data", + "height": 384, + "width": 1840 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -816, + 1136 + ], + "id": "9b0facf2-5814-46d5-8a96-ad9c4a553032", + "name": "Sticky Note2" + }, + { + "parameters": { + "content": "## Import data from WebHook", + "height": 224, + "width": 544, + "color": 3 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -816, + 512 + ], + "id": "a5d439f8-a09b-4b65-987e-9a003eb47682", + "name": "Sticky Note3" + }, + { + "parameters": { + "content": "## Data Processing ", + "height": 368, + "width": 2304, + "color": 4 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -816, + 752 + ], + "id": "3821929a-e1fc-47a5-b142-68308cfb4f79", + "name": "Sticky Note4" + }, + { + "parameters": { + "rule": { + "interval": [ + { + "field": "minutes", + "minutesInterval": 2 + } + ] + } + }, + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.3, + "position": [ + -752, + 912 + ], + "id": "89c5f3cb-916a-4f67-a836-8fa45207e257", + "name": "every 2 minutes" + }, + { + "parameters": { + "amount": 1 + }, + "type": "n8n-nodes-base.wait", + "typeVersion": 1.1, + "position": [ + 640, + 1264 + ], + "id": "7be9d7a0-d9ef-4923-b1f8-30700aa07e2b", + "name": "Wait", + "webhookId": "7e51ed5b-1814-46d3-8d10-0d2405a53cf2" + } + ], + "pinData": {}, + "connections": { + "Webhook": { + "main": [ + [ + { + "node": "Insert rows in a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insert rows in a table": { + "main": [ + [] + ] + }, + "Select rows from a table": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "Loop Over Items": { + "main": [ + [], + [ + { + "node": "Switch", + "type": "main", + "index": 0 + } + ] + ] + }, + "Update rows in a table": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "Schedule Trigger": { + "main": [ + [ + { + "node": "Select rows from a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch": { + "main": [ + [ + { + "node": "HTTP Request omdbapi", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "If", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request tvmaze": { + "main": [ + [ + { + "node": "Edit Fields1", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request omdbapi": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields1": { + "main": [ + [ + { + "node": "Update rows in a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields": { + "main": [ + [ + { + "node": "Update rows in a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "When clicking ‘Execute workflow’": { + "main": [ + [ + { + "node": "Select rows from a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "If": { + "main": [ + [ + { + "node": "HTTP Request tvmaze", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "HTTP Request omdbapi", + "type": "main", + "index": 0 + } + ] + ] + }, + "Speichere Cover in DB": { + "main": [ + [ + { + "node": "Loop Over Items1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Download Cover (Movie)": { + "main": [ + [ + { + "node": "Prepare Cover Data (Movie)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Prepare Cover Data (Movie)": { + "main": [ + [ + { + "node": "Speichere Cover in DB", + "type": "main", + "index": 0 + } + ] + ] + }, + "Download Cover (Episode)": { + "main": [ + [ + { + "node": "Prepare Cover Data (Episode)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Prepare Cover Data (Episode)": { + "main": [ + [ + { + "node": "Speichere Cover in DB", + "type": "main", + "index": 0 + } + ] + ] + }, + "Webhook1": { + "main": [ + [ + { + "node": "Insert rows in a table1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Select rows from a table1": { + "main": [ + [ + { + "node": "Loop Over Items1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Loop Over Items1": { + "main": [ + [], + [ + { + "node": "Switch1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch1": { + "main": [ + [ + { + "node": "HTTP Request omdbapi1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "If1", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request tvmaze1": { + "main": [ + [ + { + "node": "Edit Fields3", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request omdbapi1": { + "main": [ + [ + { + "node": "Edit Fields2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields2": { + "main": [ + [ + { + "node": "Download Cover (Movie)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields3": { + "main": [ + [ + { + "node": "Download Cover (Episode)", + "type": "main", + "index": 0 + } + ] + ] + }, + "If1": { + "main": [ + [ + { + "node": "HTTP Request tvmaze1", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "HTTP Request omdbapi1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Stündlich": { + "main": [ + [ + { + "node": "Einträge ohne Bild laden", + "type": "main", + "index": 0 + } + ] + ] + }, + "Einträge ohne Bild laden": { + "main": [ + [ + { + "node": "Loop Over Items2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Bild herunterladen": { + "main": [ + [ + { + "node": "Base64 extrahieren", + "type": "main", + "index": 0 + } + ] + ] + }, + "Base64 extrahieren": { + "main": [ + [ + { + "node": "Bild in DB speichern", + "type": "main", + "index": 0 + } + ] + ] + }, + "Bild in DB speichern": { + "main": [ + [ + { + "node": "Wait", + "type": "main", + "index": 0 + } + ] + ] + }, + "Loop Over Items2": { + "main": [ + [], + [ + { + "node": "Bild herunterladen", + "type": "main", + "index": 0 + } + ] + ] + }, + "every 2 minutes": { + "main": [ + [ + { + "node": "Select rows from a table1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Wait": { + "main": [ + [ + { + "node": "Loop Over Items2", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1", + "binaryMode": "separate", + "timeSavedMode": "fixed", + "errorWorkflow": "ZNiaoGjMqDVGoOZY", + "callerPolicy": "workflowsFromSameOwner", + "availableInMCP": false + }, + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "47bbd8360afe40aa749b16dd6fb21c252c1eda50abb8518eb5f288a976f3c55f" + }, + "tags": [] +} \ No newline at end of file diff --git a/n8n/FileBot_Main.json b/n8n/FileBot_Main.json new file mode 100644 index 0000000..06d77f2 --- /dev/null +++ b/n8n/FileBot_Main.json @@ -0,0 +1,977 @@ +{ + "name": "FileBot", + "nodes": [ + { + "parameters": { + "httpMethod": "POST", + "path": "b7c3b93a-1a93-47ad-afdf-ea54a131c064", + "options": {} + }, + "type": "n8n-nodes-base.webhook", + "typeVersion": 2.1, + "position": [ + -752, + -320 + ], + "id": "f5b64bb7-8ba5-4c0b-bba0-45961748afd3", + "name": "Webhook", + "webhookId": "b7c3b93a-1a93-47ad-afdf-ea54a131c064" + }, + { + "parameters": { + "content": "## FileBot Binding\n[Link](https://www.filebot.net/naming.html#bindings)", + "height": 80, + "width": 208 + }, + "type": "n8n-nodes-base.stickyNote", + "typeVersion": 1, + "position": [ + -784, + -512 + ], + "id": "feb198cd-4c0c-43f0-9458-e7a2445a057e", + "name": "Sticky Note" + }, + { + "parameters": { + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "columns": { + "mappingMode": "defineBelow", + "value": { + "movie_rating": "={{ $json.body.movie_rating }}", + "file_name_original": "={{ $json.body.FileNameOriginal }}", + "file_name_new": "={{ $json.body.FileNameNew }}", + "movie_votes": "={{ $json.body.movie_votes }}", + "video_compression_format": "={{ $json.body.video_compression_format }}", + "container_format": "={{ $json.body.container_format }}", + "audio_codec": "={{ $json.body.audio_codec }}", + "video_codec_library": "={{ $json.body.video_codec_library }}", + "standard_video_format": "={{ $json.body.standard_video_format }}", + "fourk_resolution": "={{ $json.body.fourk_resolution }}", + "exact_video_format": "={{ $json.body.exact_video_format }}", + "audio_bitrate": "={{ $json.body.audio_bitrate }}", + "video_bitrate": "={{ $json.body.video_bitrate }}", + "overall_bitrate": "={{ $json.body.overall_bitrate }}", + "dolby_vision": "={{ $json.body.dolby_vision }}", + "high_dynamic_range": "={{ $json.body.high_dynamic_range }}", + "video_bitdepth": "={{ $json.body.video_bitdepth }}", + "video_height": "={{ $json.body.video_height }}", + "video_width": "={{ $json.body.video_width }}", + "video_resolution": "={{ $json.body.video_resolution }}", + "audio_channel_layout": "={{ $json.body.audio_channel_layout }}", + "audio_channel_count": "={{ $json.body.audio_channel_count }}", + "audio_channel_format": "={{ $json.body.audio_channel_format }}", + "audio_codec_profile": "={{ $json.body.audio_codec_profile }}", + "themoviedb_id": "={{ $json.body.themoviedb_id }}", + "imdb_id": "={{ $json.body.imdb_id }}", + "thetvdb_id": "={{ $json.body.thetvdb_id }}", + "object_type": "={{ $json.body.object_type }}" + }, + "matchingColumns": [ + "id" + ], + "schema": [ + { + "id": "id", + "displayName": "id", + "required": false, + "defaultMatch": true, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "file_name_original", + "displayName": "file_name_original", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "file_name_new", + "displayName": "file_name_new", + "required": true, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "movie_rating", + "displayName": "movie_rating", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "movie_votes", + "displayName": "movie_votes", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_compression_format", + "displayName": "video_compression_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_codec_library", + "displayName": "video_codec_library", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec", + "displayName": "audio_codec", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "container_format", + "displayName": "container_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "standard_video_format", + "displayName": "standard_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "exact_video_format", + "displayName": "exact_video_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "fourk_resolution", + "displayName": "fourk_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_codec_profile", + "displayName": "audio_codec_profile", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_format", + "displayName": "audio_channel_format", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_count", + "displayName": "audio_channel_count", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_channel_layout", + "displayName": "audio_channel_layout", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_resolution", + "displayName": "video_resolution", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_width", + "displayName": "video_width", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_height", + "displayName": "video_height", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "video_bitdepth", + "displayName": "video_bitdepth", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true + }, + { + "id": "high_dynamic_range", + "displayName": "high_dynamic_range", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "dolby_vision", + "displayName": "dolby_vision", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "overall_bitrate", + "displayName": "overall_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "video_bitrate", + "displayName": "video_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "audio_bitrate", + "displayName": "audio_bitrate", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true + }, + { + "id": "created_at", + "displayName": "created_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "seen_at", + "displayName": "seen_at", + "required": false, + "defaultMatch": false, + "display": true, + "type": "dateTime", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "themoviedb_id", + "displayName": "themoviedb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "thetvdb_id", + "displayName": "thetvdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "number", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "imdb_id", + "displayName": "imdb_id", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + }, + { + "id": "cover_url", + "displayName": "cover_url", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": true + }, + { + "id": "object_type", + "displayName": "object_type", + "required": false, + "defaultMatch": false, + "display": true, + "type": "string", + "canBeUsedToMatch": true, + "removed": false + } + ], + "attemptToConvertTypes": false, + "convertFieldsToString": false + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -496, + -320 + ], + "id": "3fc2a5b5-e4fd-4a01-bbf2-cfc24d94299b", + "name": "Insert rows in a table" + }, + { + "parameters": { + "operation": "select", + "schema": { + "__rl": true, + "value": "n8n", + "mode": "list", + "cachedResultName": "n8n" + }, + "table": { + "__rl": true, + "value": "movie_files", + "mode": "list", + "cachedResultName": "movie_files" + }, + "returnAll": true, + "where": { + "values": [ + { + "column": "cover_url", + "condition": "IS NULL" + }, + { + "column": "thetvdb_id", + "condition": "IS NOT NULL" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -560, + -96 + ], + "id": "4a1dd71e-43ea-4eb2-8f12-cfc60263296c", + "name": "Select rows from a table" + }, + { + "parameters": { + "batchSize": 10, + "options": {} + }, + "type": "n8n-nodes-base.splitInBatches", + "typeVersion": 3, + "position": [ + -352, + -96 + ], + "id": "7c36ddb0-c817-451b-adff-6b496c2673d2", + "name": "Loop Over Items" + }, + { + "parameters": { + "rule": { + "interval": [ + { + "field": "minutes", + "minutesInterval": 2 + } + ] + } + }, + "type": "n8n-nodes-base.scheduleTrigger", + "typeVersion": 1.3, + "position": [ + -752, + -96 + ], + "id": "881a69cb-1bab-4dd4-8fb1-b0864f9563e7", + "name": "Schedule Trigger" + }, + { + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $json.object_type }}", + "rightValue": "Movie", + "operator": { + "type": "string", + "operation": "equals" + }, + "id": "ac38a6e6-583b-4f75-a86c-85b611cbdccc" + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "696a3cdb-33d8-4a87-947a-79df6b932b4f", + "leftValue": "={{ $json.object_type }}", + "rightValue": "Episode", + "operator": { + "type": "string", + "operation": "equals", + "name": "filter.operator.equals" + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "6df9991d-5be9-46b4-beb5-cfbed6931e85", + "leftValue": "={{ $json.object_type }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "empty", + "singleValue": true + } + } + ], + "combinator": "and" + } + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, + "position": [ + -32, + -96 + ], + "id": "c7b75fce-baa0-4de6-9077-c6dc8423bccb", + "name": "Switch" + }, + { + "parameters": { + "url": "=https://api.tvmaze.com/lookup/shows?thetvdb={{ $('Select rows from a table').item.json.thetvdb_id }}", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + -80 + ], + "id": "7345fb54-37f4-41c3-8c71-c54d906efc9a", + "name": "HTTP Request tvmaze" + }, + { + "parameters": { + "url": "=https://www.omdbapi.com/?i={{ $json.imdb_id }}&apikey=dfd46af2", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "position": [ + 464, + -224 + ], + "id": "bcb95aa0-2eb4-4b4c-933d-4391b68efc4c", + "name": "HTTP Request omdbapi" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "3516a7d0-ae39-4fc3-be1f-e984f9d3e8d6", + "name": "image.poster", + "value": "={{ $json.Poster }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + -224 + ], + "id": "f459dd59-6261-446b-9b2b-382a9bed43af", + "name": "Edit Fields" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "28227e53-46c1-48a1-ad16-d197aa7398bf", + "name": "image.poster", + "value": "={{ $json.image.medium }}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 672, + -80 + ], + "id": "5292cef8-4a4d-4e71-b1b9-6a9f240df994", + "name": "Edit Fields1" + }, + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [ + -752, + 64 + ], + "id": "efdd8a4b-2768-481b-9df6-2db0adae92d5", + "name": "When clicking 'Execute workflow'" + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "7cbb1b8f-2cad-438f-948c-6664b86c8a87", + "leftValue": "={{ $('Select rows from a table').item.json.thetvdb_id }}", + "rightValue": 0, + "operator": { + "type": "number", + "operation": "gt" + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.3, + "position": [ + 240, + -80 + ], + "id": "ce9b2259-3743-4e7d-b29f-839ac3115070", + "name": "If" + }, + { + "parameters": { + "operation": "executeQuery", + "query": "-- SCHEMA: n8n\n\nCREATE SCHEMA IF NOT EXISTS n8n AUTHORIZATION n8n_filebot;\nGRANT ALL ON SCHEMA n8n TO n8n_filebot WITH GRANT OPTION;\n\nCREATE TABLE IF NOT EXISTS n8n.movie_files\n(\n id bigint NOT NULL DEFAULT nextval('n8n.movie_files_id_seq'::regclass),\n file_name_original text NOT NULL,\n file_name_new text NOT NULL,\n movie_rating numeric(3,1),\n movie_votes integer,\n video_compression_format text,\n video_codec_library text,\n audio_codec text,\n container_format text,\n standard_video_format text,\n exact_video_format text,\n fourk_resolution text,\n audio_codec_profile text,\n audio_channel_format text,\n audio_channel_count text,\n audio_channel_layout text,\n video_resolution text,\n video_width integer,\n video_height integer,\n video_bitdepth integer,\n high_dynamic_range text,\n dolby_vision text,\n overall_bitrate text,\n video_bitrate text,\n audio_bitrate text,\n created_at timestamp with time zone DEFAULT now(),\n seen_at timestamp with time zone,\n themoviedb_id integer,\n thetvdb_id integer,\n imdb_id text,\n cover_url text,\n object_type text,\n cover_image bytea,\n cover_mime_type text,\n CONSTRAINT movie_files_pkey PRIMARY KEY (id)\n)\nTABLESPACE pg_default;", + "options": {} + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + -496, + -512 + ], + "id": "ed4d623a-5783-4baf-a7ea-747d65b66aac", + "name": "SQL query CREATE", + "disabled": true + }, + { + "parameters": { + "url": "={{ $json['image']['poster'] }}", + "responseFormat": "file", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "continueOnFail": true, + "position": [ + 880, + -224 + ], + "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567801", + "name": "Download Cover (Movie)" + }, + { + "parameters": { + "jsCode": "const item = $input.first();\nlet coverBase64 = null;\nlet coverMimeType = null;\n\nif (item.binary && item.binary.data) {\n coverMimeType = item.binary.data.mimeType || 'image/jpeg';\n const buffer = await this.helpers.getBinaryDataBuffer(0, 'data');\n coverBase64 = buffer.toString('base64');\n}\n\nreturn [{\n json: {\n cover_url: $('Edit Fields').item.json['image']['poster'] || null,\n cover_base64: coverBase64,\n cover_mime_type: coverMimeType,\n record_id: $('Loop Over Items').item.json.id,\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1088, + -224 + ], + "id": "b2c3d4e5-f6a7-8901-bcde-f12345678902", + "name": "Prepare Cover Data (Movie)" + }, + { + "parameters": { + "url": "={{ $json['image']['poster'] }}", + "responseFormat": "file", + "options": {} + }, + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.4, + "continueOnFail": true, + "position": [ + 880, + -80 + ], + "id": "c3d4e5f6-a7b8-9012-cdef-012345678903", + "name": "Download Cover (Episode)" + }, + { + "parameters": { + "jsCode": "const item = $input.first();\nlet coverBase64 = null;\nlet coverMimeType = null;\n\nif (item.binary && item.binary.data) {\n coverMimeType = item.binary.data.mimeType || 'image/jpeg';\n const buffer = await this.helpers.getBinaryDataBuffer(0, 'data');\n coverBase64 = buffer.toString('base64');\n}\n\nreturn [{\n json: {\n cover_url: $('Edit Fields1').item.json['image']['poster'] || null,\n cover_base64: coverBase64,\n cover_mime_type: coverMimeType,\n record_id: $('Loop Over Items').item.json.id,\n }\n}];" + }, + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 1088, + -80 + ], + "id": "d4e5f6a7-b8c9-0123-defa-123456789004", + "name": "Prepare Cover Data (Episode)" + }, + { + "parameters": { + "operation": "executeQuery", + "query": "UPDATE n8n.movie_files\nSET\n cover_url = $1,\n cover_image = CASE WHEN $2::text IS NOT NULL THEN decode($2, 'base64') ELSE NULL END,\n cover_mime_type = $3\nWHERE id = $4", + "options": { + "queryReplacement": "={{ [$json.cover_url, $json.cover_base64, $json.cover_mime_type, $json.record_id] }}" + } + }, + "type": "n8n-nodes-base.postgres", + "typeVersion": 2.6, + "position": [ + 1296, + -152 + ], + "id": "e5f6a7b8-c9d0-1234-efab-234567890105", + "name": "Speichere Cover in DB" + } + ], + "pinData": {}, + "connections": { + "Webhook": { + "main": [ + [ + { + "node": "Insert rows in a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "Insert rows in a table": { + "main": [ + [] + ] + }, + "Select rows from a table": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "Loop Over Items": { + "main": [ + [], + [ + { + "node": "Switch", + "type": "main", + "index": 0 + } + ] + ] + }, + "Speichere Cover in DB": { + "main": [ + [ + { + "node": "Loop Over Items", + "type": "main", + "index": 0 + } + ] + ] + }, + "Schedule Trigger": { + "main": [ + [ + { + "node": "Select rows from a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "Switch": { + "main": [ + [ + { + "node": "HTTP Request omdbapi", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "If", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request tvmaze": { + "main": [ + [ + { + "node": "Edit Fields1", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP Request omdbapi": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields": { + "main": [ + [ + { + "node": "Download Cover (Movie)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields1": { + "main": [ + [ + { + "node": "Download Cover (Episode)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Download Cover (Movie)": { + "main": [ + [ + { + "node": "Prepare Cover Data (Movie)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Prepare Cover Data (Movie)": { + "main": [ + [ + { + "node": "Speichere Cover in DB", + "type": "main", + "index": 0 + } + ] + ] + }, + "Download Cover (Episode)": { + "main": [ + [ + { + "node": "Prepare Cover Data (Episode)", + "type": "main", + "index": 0 + } + ] + ] + }, + "Prepare Cover Data (Episode)": { + "main": [ + [ + { + "node": "Speichere Cover in DB", + "type": "main", + "index": 0 + } + ] + ] + }, + "When clicking 'Execute workflow'": { + "main": [ + [ + { + "node": "Select rows from a table", + "type": "main", + "index": 0 + } + ] + ] + }, + "If": { + "main": [ + [ + { + "node": "HTTP Request tvmaze", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "HTTP Request omdbapi", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": true, + "settings": { + "executionOrder": "v1", + "binaryMode": "separate", + "timeSavedMode": "fixed", + "errorWorkflow": "ZNiaoGjMqDVGoOZY", + "callerPolicy": "workflowsFromSameOwner", + "availableInMCP": false + }, + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "47bbd8360afe40aa749b16dd6fb21c252c1eda50abb8518eb5f288a976f3c55f" + }, + "tags": [] +} \ No newline at end of file