refactor(netflix): subflows for Netflix Auth

This commit is contained in:
HugoPoi 2021-02-28 20:02:38 +01:00
parent a35e0d00bc
commit 88d90ba2d7

View File

@ -13,6 +13,38 @@
"disabled": false, "disabled": false,
"info": "" "info": ""
}, },
{
"id": "fdd2168a.835ab8",
"type": "subflow",
"name": "Netflix HTTP Auth",
"info": "",
"category": "",
"in": [
{
"x": 20,
"y": 80,
"wires": [
{
"id": "bf25f228.3c6a5"
}
]
}
],
"out": [
{
"x": 600,
"y": 80,
"wires": [
{
"id": "6d4fb2bd.73cc2c",
"port": 0
}
]
}
],
"env": [],
"color": "#DDAA99"
},
{ {
"id": "f120e3b1.f67b38", "id": "f120e3b1.f67b38",
"type": "inject", "type": "inject",
@ -38,7 +70,7 @@
"y": 40, "y": 40,
"wires": [ "wires": [
[ [
"bf25f228.3c6a5" "2d46da6b.8dc806"
] ]
] ]
}, },
@ -55,11 +87,11 @@
"persist": false, "persist": false,
"proxy": "", "proxy": "",
"authType": "", "authType": "",
"x": 730, "x": 350,
"y": 100, "y": 100,
"wires": [ "wires": [
[ [
"e03ca39e.a9af28" "41d7704e.4f4a48"
] ]
], ],
"info": "Get invoice page from Netflix" "info": "Get invoice page from Netflix"
@ -67,25 +99,23 @@
{ {
"id": "6d4fb2bd.73cc2c", "id": "6d4fb2bd.73cc2c",
"type": "function", "type": "function",
"z": "e79fd0e1.60f55", "z": "fdd2168a.835ab8",
"name": "HTTP Headers for Netflix", "name": "HTTP Headers for Netflix",
"func": "msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.headers['Cookie'] = [\n 'SecureNetflixId=' + msg.secureNetflixId,\n 'NetflixId=' + msg.netflixId,\n].join(';');\nreturn msg;", "func": "msg.headers = {};\nmsg.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0';\nmsg.headers['Accept-Language'] = 'fr-FR,fr;q=0.5';\nmsg.headers['Cookie'] = [\n 'SecureNetflixId=' + msg.secureNetflixId,\n 'NetflixId=' + msg.netflixId,\n].join(';');\nreturn msg;",
"outputs": 1, "outputs": 1,
"noerr": 0, "noerr": 0,
"initialize": "", "initialize": "",
"finalize": "", "finalize": "",
"x": 390, "x": 410,
"y": 100, "y": 80,
"wires": [ "wires": [
[ []
"4c67f40c.bede9c"
]
] ]
}, },
{ {
"id": "bf25f228.3c6a5", "id": "bf25f228.3c6a5",
"type": "credentials", "type": "credentials",
"z": "e79fd0e1.60f55", "z": "fdd2168a.835ab8",
"name": "Netflix Credentials", "name": "Netflix Credentials",
"props": [ "props": [
{ {
@ -97,33 +127,14 @@
"type": "msg" "type": "msg"
} }
], ],
"x": 170, "x": 190,
"y": 100, "y": 80,
"wires": [ "wires": [
[ [
"6d4fb2bd.73cc2c" "6d4fb2bd.73cc2c"
] ]
] ]
}, },
{
"id": "e03ca39e.a9af28",
"type": "function",
"z": "e79fd0e1.60f55",
"name": "Parse Netflix Billing Page",
"func": "return {\n url: 'https://www.netflix.com' + /\\/invoice\\/print\\/[^\"]*/.exec(msg.payload)\n};",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 390,
"y": 180,
"wires": [
[
"bf25f228.3c6a5",
"8e61a051.3430c8"
]
]
},
{ {
"id": "7ddcb19f.58034", "id": "7ddcb19f.58034",
"type": "http request", "type": "http request",
@ -131,12 +142,14 @@
"name": "", "name": "",
"method": "GET", "method": "GET",
"ret": "txt", "ret": "txt",
"paytoqs": false, "paytoqs": "ignore",
"url": "", "url": "",
"tls": "",
"persist": false, "persist": false,
"proxy": "",
"authType": "", "authType": "",
"x": 730, "x": 350,
"y": 180, "y": 160,
"wires": [ "wires": [
[ [
"b03fda42.1373b", "b03fda42.1373b",
@ -145,35 +158,6 @@
] ]
] ]
}, },
{
"id": "4c67f40c.bede9c",
"type": "switch",
"z": "e79fd0e1.60f55",
"name": "",
"property": "url",
"propertyType": "msg",
"rules": [
{
"t": "null"
},
{
"t": "nnull"
}
],
"checkall": "false",
"repair": false,
"outputs": 2,
"x": 570,
"y": 100,
"wires": [
[
"a9e0512d.6cdd7"
],
[
"7ddcb19f.58034"
]
]
},
{ {
"id": "b03fda42.1373b", "id": "b03fda42.1373b",
"type": "file", "type": "file",
@ -184,8 +168,8 @@
"createDir": false, "createDir": false,
"overwriteFile": "true", "overwriteFile": "true",
"encoding": "utf8", "encoding": "utf8",
"x": 990, "x": 590,
"y": 180, "y": 160,
"wires": [ "wires": [
[] []
] ]
@ -274,9 +258,7 @@
"type": "link out", "type": "link out",
"z": "e79fd0e1.60f55", "z": "e79fd0e1.60f55",
"name": "Last Netflix Invoice as PDF", "name": "Last Netflix Invoice as PDF",
"links": [ "links": [],
"848ba398.23bef8"
],
"x": 455, "x": 455,
"y": 580, "y": 580,
"wires": [] "wires": []
@ -634,9 +616,7 @@
"type": "link in", "type": "link in",
"z": "34256184.7e2b8e", "z": "34256184.7e2b8e",
"name": "Trigged from Netflix Last Invoice", "name": "Trigged from Netflix Last Invoice",
"links": [ "links": [],
"4c6af2dc.2504bc"
],
"x": 195, "x": 195,
"y": 360, "y": 360,
"wires": [ "wires": [
@ -803,7 +783,7 @@
"id": "8e61a051.3430c8", "id": "8e61a051.3430c8",
"type": "debug", "type": "debug",
"z": "e79fd0e1.60f55", "z": "e79fd0e1.60f55",
"name": "", "name": "Last invoice url",
"active": true, "active": true,
"tosidebar": true, "tosidebar": true,
"console": false, "console": false,
@ -812,8 +792,8 @@
"targetType": "msg", "targetType": "msg",
"statusVal": "", "statusVal": "",
"statusType": "auto", "statusType": "auto",
"x": 380, "x": 800,
"y": 220, "y": 100,
"wires": [] "wires": []
}, },
{ {
@ -875,5 +855,61 @@
"4c6af2dc.2504bc" "4c6af2dc.2504bc"
] ]
] ]
},
{
"id": "2d46da6b.8dc806",
"type": "subflow:fdd2168a.835ab8",
"z": "e79fd0e1.60f55",
"name": "Netflix HTTP Auth",
"env": [],
"x": 170,
"y": 100,
"wires": [
[
"a9e0512d.6cdd7"
]
]
},
{
"id": "797b306d.21639",
"type": "subflow:fdd2168a.835ab8",
"z": "e79fd0e1.60f55",
"name": "Netflix HTTP Auth",
"env": [],
"x": 170,
"y": 160,
"wires": [
[
"7ddcb19f.58034"
]
]
},
{
"id": "41d7704e.4f4a48",
"type": "change",
"z": "e79fd0e1.60f55",
"name": "Extract last invoice url",
"rules": [
{
"t": "set",
"p": "url",
"pt": "msg",
"to": "$join([\t 'https://www.netflix.com',\t $lookup($match(payload, /\\/invoice\\/print\\/[^\"]*/), 'match')[0]\t])",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 100,
"wires": [
[
"8e61a051.3430c8",
"797b306d.21639"
]
]
} }
] ]