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,
"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",
"type": "inject",
@ -38,7 +70,7 @@
"y": 40,
"wires": [
[
"bf25f228.3c6a5"
"2d46da6b.8dc806"
]
]
},
@ -55,11 +87,11 @@
"persist": false,
"proxy": "",
"authType": "",
"x": 730,
"x": 350,
"y": 100,
"wires": [
[
"e03ca39e.a9af28"
"41d7704e.4f4a48"
]
],
"info": "Get invoice page from Netflix"
@ -67,25 +99,23 @@
{
"id": "6d4fb2bd.73cc2c",
"type": "function",
"z": "e79fd0e1.60f55",
"z": "fdd2168a.835ab8",
"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;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 390,
"y": 100,
"x": 410,
"y": 80,
"wires": [
[
"4c67f40c.bede9c"
]
[]
]
},
{
"id": "bf25f228.3c6a5",
"type": "credentials",
"z": "e79fd0e1.60f55",
"z": "fdd2168a.835ab8",
"name": "Netflix Credentials",
"props": [
{
@ -97,33 +127,14 @@
"type": "msg"
}
],
"x": 170,
"y": 100,
"x": 190,
"y": 80,
"wires": [
[
"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",
"type": "http request",
@ -131,12 +142,14 @@
"name": "",
"method": "GET",
"ret": "txt",
"paytoqs": false,
"paytoqs": "ignore",
"url": "",
"tls": "",
"persist": false,
"proxy": "",
"authType": "",
"x": 730,
"y": 180,
"x": 350,
"y": 160,
"wires": [
[
"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",
"type": "file",
@ -184,8 +168,8 @@
"createDir": false,
"overwriteFile": "true",
"encoding": "utf8",
"x": 990,
"y": 180,
"x": 590,
"y": 160,
"wires": [
[]
]
@ -274,9 +258,7 @@
"type": "link out",
"z": "e79fd0e1.60f55",
"name": "Last Netflix Invoice as PDF",
"links": [
"848ba398.23bef8"
],
"links": [],
"x": 455,
"y": 580,
"wires": []
@ -634,9 +616,7 @@
"type": "link in",
"z": "34256184.7e2b8e",
"name": "Trigged from Netflix Last Invoice",
"links": [
"4c6af2dc.2504bc"
],
"links": [],
"x": 195,
"y": 360,
"wires": [
@ -803,7 +783,7 @@
"id": "8e61a051.3430c8",
"type": "debug",
"z": "e79fd0e1.60f55",
"name": "",
"name": "Last invoice url",
"active": true,
"tosidebar": true,
"console": false,
@ -812,8 +792,8 @@
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 380,
"y": 220,
"x": 800,
"y": 100,
"wires": []
},
{
@ -875,5 +855,61 @@
"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"
]
]
}
]