feat: add node-red flows as replacement of the bash script

This commit is contained in:
Hugo Poissonnet 2021-02-28 13:58:39 +01:00
parent 5a5bf6161d
commit 0245a8ec73
5 changed files with 34 additions and 5 deletions

10
.gitignore vendored
View File

@ -1,5 +1,5 @@
*.html /*.html
*.pdf /*.pdf
*.json /*.json
config.sh /config.sh
.env.netflix_cookies /.env.netflix_cookies

6
node_red_data/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
node_modules
.*.backup
.*.json
.npm
flows_cred.json
settings.js

1
node_red_data/flows.json Normal file
View File

@ -0,0 +1 @@
[{"id":"e79fd0e1.60f55","type":"tab","label":"Last Netflix invoice to Leeto","disabled":false,"info":""},{"id":"f120e3b1.f67b38","type":"inject","z":"e79fd0e1.60f55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":40,"wires":[["bf25f228.3c6a5"]]},{"id":"a9e0512d.6cdd7","type":"http request","z":"e79fd0e1.60f55","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://www.netflix.com/BillingActivity","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":120,"wires":[["e03ca39e.a9af28"]],"info":"Get invoice page from Netflix"},{"id":"6d4fb2bd.73cc2c","type":"function","z":"e79fd0e1.60f55","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":270,"y":160,"wires":[["4c67f40c.bede9c"]]},{"id":"bf25f228.3c6a5","type":"credentials","z":"e79fd0e1.60f55","name":"Netflix Credentials","props":[{"value":"netflixId","type":"msg"},{"value":"secureNetflixId","type":"msg"}],"x":170,"y":100,"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":430,"y":400,"wires":[["8e61a051.3430c8","bf25f228.3c6a5"]]},{"id":"8e61a051.3430c8","type":"debug","z":"e79fd0e1.60f55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"url","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":700,"wires":[]},{"id":"7ddcb19f.58034","type":"http request","z":"e79fd0e1.60f55","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"","persist":false,"authType":"","x":730,"y":280,"wires":[["b03fda42.1373b"]]},{"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":470,"y":160,"wires":[["a9e0512d.6cdd7"],["7ddcb19f.58034","429cfd10.81d76c"]]},{"id":"429cfd10.81d76c","type":"debug","z":"e79fd0e1.60f55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":400,"wires":[]},{"id":"e9ef9b5c.3d288","type":"screenshot","z":"e79fd0e1.60f55","name":"Screenshot last invoice","url":"https://blog.hugopoi.net/","path":"","x":1170,"y":360,"wires":[["6d08e306.82ab1c"]]},{"id":"b03fda42.1373b","type":"file","z":"e79fd0e1.60f55","name":"Save last invoice","filename":"lastInvoice.html","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"utf8","x":970,"y":200,"wires":[["e9ef9b5c.3d288"]]},{"id":"6d08e306.82ab1c","type":"file","z":"e79fd0e1.60f55","name":"Save last invoice as img","filename":"lastInvoice.base64","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1160,"y":460,"wires":[[]]}]

13
node_red_data/package-lock.json generated Normal file
View File

@ -0,0 +1,13 @@
{
"name": "node-red-project",
"version": "0.0.1",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"node-red-contrib-credentials": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/node-red-contrib-credentials/-/node-red-contrib-credentials-0.2.1.tgz",
"integrity": "sha512-fn82zQ2Tn/tsj/i634s+Oso2hEgMWC61lMU315cfwplURW+UIeZ5+dFCWOPYs4qlI2VUPW5qfzHPHg4OVjV/UQ=="
}
}
}

View File

@ -0,0 +1,9 @@
{
"name": "node-red-project",
"description": "A Node-RED Project",
"version": "0.0.1",
"private": true,
"dependencies": {
"node-red-contrib-credentials": "^0.2.1"
}
}