『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 21782|回复: 13

[教程系列] 写个教程,给新手们讲解下node-red的信息流机制

[复制链接]

6

主题

71

帖子

840

积分

高级会员

Rank: 4

积分
840
金钱
764
HASS币
30
发表于 2020-5-24 10:48:29 | 显示全部楼层 |阅读模式
本人是个编程小白,各种编程语言基本上都是零基础。想要什么功能也都是百度伺候。当我发现node-red之后发现这个是最适合我们这些小白使用。流程一目了然。但是之前使用时没有弄明白nodered的信息在各个节点之间是怎么传递的,走了很多弯路。等用了一段时间之后发现nodered的信息流真的很好用。所以在这里想把这个机制给新入门的玩家解释一下,能省很多弯路。
一、信息在节点之间传递:
       一开始我以为,在两个节点之间传递的只能是msg.payload。像这样:
1.png
      其实我们可以这样:在两个节点之间传送多个信息:比如同时传递msg.payload    msg.name1   msg.name2等多个信息。
      如图:我们可以用change节点,录入多个信息:
2.png
       这时候,我们把debug节点中的输出选为完整信息:
3.png
       然后我们保存并部署之后,就能把所有的信息都显示出来:
4.png
      或者我们在debug中的输出,填写:msg.name1
5.png
       就能在调试中只看到msg.name1的信息:
6.png
       实际应用:比如,我们想比较name1和name2的大小,可以用switch这么写:
7.png
        还有其他很多的节点都是这样使用的。



评分

参与人数 5金钱 +43 HASS币 +20 收起 理由
775873224 + 5 感谢楼主分享!
潇洒哥er + 10 感谢楼主分享!
newlucas + 2 论坛有你更精彩!
情非殇 + 6 赠人玫瑰,手留余香!
+ 20 + 20 膜拜大神!

查看全部评分

回复

使用道具 举报

6

主题

71

帖子

840

积分

高级会员

Rank: 4

积分
840
金钱
764
HASS币
30
 楼主| 发表于 2020-5-24 10:55:01 | 显示全部楼层
本帖最后由 theraven 于 2020-5-24 11:23 编辑

二、传递的信息类型:我们在change节点更改信息的时候可以选择很多种类:                8.png
文字列是我们常用的,没特殊需求直接用这个就可以,数字是当我们需要比较大小或者进行运算的时候要用到。布尔值就是true和false。时间戳我们都知道了。json可以录入键值对,或者数组,如图,用[]括起来就是数组。
9.png
表达式和环境变量没用到过还不知道有什么用。希望有大大给补充下。

我们再说说使用funtion节点,实现我们需要的一些功能。
说白了,funtion就是一个js程序或者函数。有时候我们有些需求没找到合适的节点处理,可能就会用到funtion,
1.png
这个就是把几个字符串合并在一起。我们也可以进行四则运算。
2.png
这个是用来处理信息流的,从一段文本列:“05月24日 10:04@今日第4笔收款, 共计¥100.00”。中找出合计多少钱,并且判断这条信息是不是当天收到的。

回复

使用道具 举报

6

主题

71

帖子

840

积分

高级会员

Rank: 4

积分
840
金钱
764
HASS币
30
 楼主| 发表于 2020-5-24 11:03:46 | 显示全部楼层
本帖最后由 theraven 于 2020-5-24 11:40 编辑

三、数组的使用,       有时候我们处理数据的时候会出现数组,例如
1.png
这个节点是把某个文件夹下的文件夹和文件名全部列出来,输出的就是一个数组。
2.png
比如,这个就输出了包含21个文件名的数组。
我们可以用split节点将其挨个输出,
3.png
而且最重要的是,每一条信息中除了payload被拆分了之外,其他的比如name1,name2等信息都被保存下来了。


3.png
回复

使用道具 举报

6

主题

71

帖子

840

积分

高级会员

Rank: 4

积分
840
金钱
764
HASS币
30
 楼主| 发表于 2020-5-24 11:06:10 | 显示全部楼层
本帖最后由 theraven 于 2020-5-24 12:39 编辑

最后,以我写的一个用于归档下载后的电影和美剧的应用。几乎每一个节点都写了备注,新手可以参考学习。

[{"id":"2006b4e6.d4439c","type":"tab","label":"自动归档下载内容","disabled":false,"info":""},{"id":"5fc5dd67.f86bb4","type":"inject","z":"2006b4e6.d4439c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":100,"wires":[["bb183d8.09fa0c"]]},{"id":"53803ceb.390df4","type":"fs-ops-dir","z":"2006b4e6.d4439c","name":"","path":"path","pathType":"msg","filter":"*","filterType":"str","dir":"payload","dirType":"msg","x":420,"y":100,"wires":[["79b4f3f1.9224bc"]],"info":"此节点的作用是将某个文件夹中的所有文件夹和文件名字都列出来。文件夹路径来自msg.path。来自于前面的输入信息。"},{"id":"56cf8fa1.9052a","type":"fs-ops-type","z":"2006b4e6.d4439c","name":"","path":"path","pathType":"msg","filename":"payload","filenameType":"msg","filetype":"type","filetypeType":"msg","x":1080,"y":100,"wires":[["33b9f6ff.67ff5a"]],"info":"该节点作用是区分每一个信息流代表是文件夹还是文件。将类型输出到msg.type"},{"id":"480e3ba5.c4ce54","type":"split","z":"2006b4e6.d4439c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":750,"y":100,"wires":[["a3559860.4cd478"]],"inputLabels":["文件名"],"info":"当文件夹不为空时将输出的数组分开,挨个输出。"},{"id":"bb183d8.09fa0c","type":"change","z":"2006b4e6.d4439c","name":"填写文件夹","rules":[{"t":"set","p":"path","pt":"msg","to":"/download/美剧","tot":"str"},{"t":"set","p":"moviepath","pt":"msg","to":"/video/电影/电影","tot":"str"},{"t":"set","p":"tvpath","pt":"msg","to":"/video/剧集/美剧","tot":"str"},{"t":"set","p":"dianshipath","pt":"msg","to":"/video/剧集/国产电视剧","tot":"str"},{"t":"set","p":"mivoe_type","pt":"msg","to":"美剧","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":100,"wires":[["53803ceb.390df4"]],"info":"将初始参数挨个录入,方便以后修改或者代码复用。\nmsg.type是判断该文件夹下电影类型,是电影(不用区分第几季第几集)国产电视剧(不用区分第几季,只用区分第几集),美剧(需要区分第几季第几集),无(该文件夹下有美剧也有电影需要根据文件名判断,该方法有可能判断错误,出现美剧放到电影文件夹下,影响plex或者其他媒体播放器归档)"},{"id":"a3559860.4cd478","type":"delay","z":"2006b4e6.d4439c","name":"闲置速度","pauseType":"rate","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":900,"y":100,"wires":[["56cf8fa1.9052a"]],"info":"限制每条信息的流速,以便留出时间处理每条文件夹或者文件信息。"},{"id":"33b9f6ff.67ff5a","type":"switch","z":"2006b4e6.d4439c","name":"","property":"type","propertyType":"msg","rules":[{"t":"eq","v":"D","vt":"str"},{"t":"eq","v":"F","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":100,"wires":[["a4daa94.f045858"],["91eb737d.589d"]],"info":"根据msg.type内容区分是文件夹还是文件\n1、\"D\"代表是文件夹\n2、\"F\"代表是文件。"},{"id":"a4daa94.f045858","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.path=msg.path+\"/\"+msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":1370,"y":80,"wires":[["f605daa0.ea7c98"]],"info":"将文件夹名字加到文件路径中得到一个新的文件夹路径,下一步返回开头,从新查看该文件夹下的文件或者文件夹内容。"},{"id":"8c49cd13.881eb","type":"switch","z":"2006b4e6.d4439c","name":"判断是否为影片","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"\\.mp4$|\\.mkv$|\\.vsmeta$|\\.nfo$|\\.rmvb$","vt":"str","case":true},{"t":"regex","v":"\\.abcd$","vt":"str","case":true},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":180,"y":180,"wires":[["5adf13f2.a69c0c"],[],["b9405e21.78779"]],"info":"判断该文件(已经没有文件夹名了),是否为媒体文件,\n1,媒体文件(需要复制归档的文件,包括字幕,封面等文件)。目前我列出的仅有MP4,rmvb,mkv,srt等文件。需要添加新的文件后缀,可以在末尾添加|\\.XXX$   其中xxx是文件后缀。\n2.需要保留的文件,比如未下载完成的文件,还有为了不删除某文件夹而专门放进去的后缀为abcd的文件。\n3、其他文件,下一步会删除"},{"id":"91eb737d.589d","type":"link out","z":"2006b4e6.d4439c","name":"","links":["3ca9f504.0cb20a"],"x":1335,"y":120,"wires":[],"info":"进入下一步"},{"id":"3ca9f504.0cb20a","type":"link in","z":"2006b4e6.d4439c","name":"","links":["91eb737d.589d"],"x":65,"y":180,"wires":[["8c49cd13.881eb"]],"info":"承接上一步"},{"id":"89ab4301.08438","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"\\.s[0-9][0-9]e[0-9][0-9]\\.","vt":"str","case":true},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":180,"wires":[["68e3c12d.48f0d"],["a517315e.8267d"]],"info":"判断文件名中是否有类似S01E01这样的内容,以判断是否是美剧"},{"id":"68e3c12d.48f0d","type":"link out","z":"2006b4e6.d4439c","name":"美剧","links":["e53dbe01.78ffd"],"x":675,"y":160,"wires":[]},{"id":"e53dbe01.78ffd","type":"link in","z":"2006b4e6.d4439c","name":"美剧","links":["68e3c12d.48f0d"],"x":55,"y":360,"wires":[["dd810571.70ed48"]]},{"id":"dd810571.70ed48","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.file=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":360,"wires":[["d326c600.2984f8"]],"info":"将msg.payload复制到msg.file中,原msg.payload中内容还在。"},{"id":"d326c600.2984f8","type":"split","z":"2006b4e6.d4439c","name":"","splt":".","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":270,"y":360,"wires":[["3c9c2f9a.925c7"]],"info":"用.拆分文件名。将文件名拆分成信息流"},{"id":"3c9c2f9a.925c7","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"字幕","vt":"str"},{"t":"cont","v":"人人影视","vt":"str"},{"t":"regex","v":"[\\u4E00-\\u9FA5]","vt":"str","case":true},{"t":"regex","v":"^s[0-9][0-9]e[0-9][0-9]$","vt":"str","case":true}],"checkall":"false","repair":false,"outputs":4,"x":410,"y":360,"wires":[[],[],["40dbac6e.86fab4"],["744f1e4f.3d66c"]],"info":"寻找文件名中的中文名字和第几季第几集。\n1、是否包含字幕二字。不是电影中文名舍弃。\n2、包含人人影视,不是电影中文名,舍弃。\n3、包含中文的内容,为电影的中文名。\n4、获取类似:S01E01这样的内容以获取这是第几季第几集。"},{"id":"40dbac6e.86fab4","type":"join","z":"2006b4e6.d4439c","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"-","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":530,"y":300,"wires":[["e0866b08.8081b8"]],"info":"把获取到的中文名合并,考虑到有可能一个中文名被.分隔开,所以需要等待信息流中的所有中文内容,并且合并在一起"},{"id":"e0866b08.8081b8","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.zhname=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":300,"wires":[["72346cd.db0a194"]],"info":"将获取到的中文内容保存到msg.zhname中"},{"id":"744f1e4f.3d66c","type":"function","z":"2006b4e6.d4439c","name":"","func":"var a=msg.payload;\nvar c=a.substring(1,3);\nmsg.season=parseInt(c);\nreturn msg;","outputs":1,"noerr":0,"x":550,"y":360,"wires":[["72346cd.db0a194"]],"info":"获取该文件是第几季,并且保存到msg.season中。"},{"id":"72346cd.db0a194","type":"join","z":"2006b4e6.d4439c","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":360,"wires":[["f6247f85.d4023"]],"info":"合并在一起。"},{"id":"f605daa0.ea7c98","type":"link out","z":"2006b4e6.d4439c","name":"","links":["5c051845.025f88"],"x":1475,"y":80,"wires":[],"info":"返回开始,进行递归。最后将每一层文件夹都搜索到。"},{"id":"5c051845.025f88","type":"link in","z":"2006b4e6.d4439c","name":"","links":["d91d608f.6f8dc","f605daa0.ea7c98"],"x":295,"y":60,"wires":[["53803ceb.390df4"]]},{"id":"e3cc1491.870f78","type":"fs-ops-move","z":"2006b4e6.d4439c","name":"移动文件","sourcePath":"path","sourcePathType":"msg","sourceFilename":"file","sourceFilenameType":"msg","destPath":"tvpath","destPathType":"msg","destFilename":"file","destFilenameType":"msg","link":false,"x":1540,"y":360,"wires":[["481a116b.72051","d1c843a5.f2f6a"]],"info":"将该文件移动到新建文件夹下"},{"id":"4c0e374c.519128","type":"fs-ops-mkdir","z":"2006b4e6.d4439c","name":"创建文件夹","path":"tvpath","pathType":"msg","dirname":"zhname","dirnameType":"msg","mode":"777","fullpath":"payload","fullpathType":"msg","x":990,"y":360,"wires":[["aaaa9877.120138"]],"info":"以中文名在预设的美剧文件夹中新建文件夹"},{"id":"f4e1a993.64d468","type":"fs-ops-mkdir","z":"2006b4e6.d4439c","name":"创建文件夹","path":"tvpath","pathType":"msg","dirname":"season","dirnameType":"msg","mode":"777","fullpath":"payload","fullpathType":"msg","x":1270,"y":360,"wires":[["4ac5eee6.c493d"]],"info":"新建第几季的文件夹。"},{"id":"aaaa9877.120138","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.tvpath=msg.tvpath+\"/\"+msg.zhname;\nmsg.season=\"Season\"+msg.season;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":360,"wires":[["f4e1a993.64d468"]],"info":"将新建文件夹添加到路径中"},{"id":"4ac5eee6.c493d","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.tvpath=msg.tvpath+\"/\"+msg.season;\nreturn msg;","outputs":1,"noerr":0,"x":1410,"y":360,"wires":[["e3cc1491.870f78"]],"info":"将新建文件夹添加到路径中"},{"id":"5adf13f2.a69c0c","type":"switch","z":"2006b4e6.d4439c","name":"判断影片类型","property":"mivoe_type","propertyType":"msg","rules":[{"t":"eq","v":"美剧","vt":"str"},{"t":"eq","v":"无","vt":"str"},{"t":"eq","v":"电影","vt":"str"},{"t":"eq","v":"国产电视剧","vt":"str"}],"checkall":"false","repair":false,"outputs":4,"x":380,"y":180,"wires":[["68e3c12d.48f0d"],["89ab4301.08438"],["a517315e.8267d"],[]],"info":"根据最先填写的影片类型,选择不同的动作。"},{"id":"a517315e.8267d","type":"link out","z":"2006b4e6.d4439c","name":"电影","links":["6b92b01b.df167"],"x":675,"y":200,"wires":[]},{"id":"b9405e21.78779","type":"fs-ops-delete","z":"2006b4e6.d4439c","name":"删除文件","path":"path","pathType":"msg","filename":"payload","filenameType":"msg","x":360,"y":240,"wires":[["d8db01a9.53056","91383374.24e0e"]],"info":"删除文件"},{"id":"79b4f3f1.9224bc","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"msg.payload=[ \"@eaDir\" ]","vt":"jsonata"},{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":3,"x":570,"y":100,"wires":[["3dd5e0b5.e8d6e","920f6825.487bf8"],["3dd5e0b5.e8d6e","920f6825.487bf8"],["480e3ba5.c4ce54"]],"info":"根据文件夹输出内容选择不同的路径,\n1、文件夹下只有一个文件夹名字叫@eaDir(群晖索引文件)\n2、文件夹下什么文件和文件夹都没有,因此输出的为空。\n3、文件下有文件夹或者文件。"},{"id":"3dd5e0b5.e8d6e","type":"func-exec","z":"2006b4e6.d4439c","name":"删除文件夹","func":"var path=msg.path;\nvar exec = child_process.exec(\"rm -rf \"+path, (error, stdout, stderr) => {\nif (error) {\nconsole.error(`exec error: ${error}`);\nreturn;\n}\nconsole.log(`stdout: ${stdout}`);\nconsole.log(`stderr: ${stderr}`);\n});\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":60,"wires":[[]],"info":"如果msg.path中的文件夹只有一个@eaDir文件夹,或者没有任何文件和文件夹,那就把这个文件夹删掉。"},{"id":"dfd7a624.80a098","type":"fs-ops-dir","z":"2006b4e6.d4439c","name":"","path":"path","pathType":"msg","filter":"*","filterType":"str","dir":"payload","dirType":"msg","x":840,"y":200,"wires":[["c03394f1.d20c08"]],"info":"列出文件夹下所有文件名和文件夹名以便判断是否为空文件夹"},{"id":"2acc1c4.3e5e2e4","type":"link in","z":"2006b4e6.d4439c","name":"","links":["481a116b.72051","ba023516.efeb08","d8db01a9.53056","f995e937.a53608"],"x":735,"y":200,"wires":[["dfd7a624.80a098"]],"info":"删除文件后,将需要归档的文件归档后,进入这个流程"},{"id":"d8db01a9.53056","type":"link out","z":"2006b4e6.d4439c","name":"","links":["2acc1c4.3e5e2e4"],"x":455,"y":240,"wires":[],"info":"转到后续动作,目的是判断删除这个文件之后,其所在的文件夹是否变为空文件夹(或者只剩@eaDir文件夹)"},{"id":"481a116b.72051","type":"link out","z":"2006b4e6.d4439c","name":"","links":["2acc1c4.3e5e2e4"],"x":1635,"y":360,"wires":[]},{"id":"8dd16de7.a2623","type":"func-exec","z":"2006b4e6.d4439c","name":"删除文件夹","func":"var path=msg.path;\nvar exec = child_process.exec(\"rm -rf \"+path, (error, stdout, stderr) => {\nif (error) {\nconsole.error(`exec error: ${error}`);\nreturn;\n}\nconsole.log(`stdout: ${stdout}`);\nconsole.log(`stderr: ${stderr}`);\n});\nreturn msg;","outputs":1,"noerr":0,"x":1110,"y":200,"wires":[["e814dbb1.a23448"]],"info":"删除文件夹,内容我也看不懂"},{"id":"e814dbb1.a23448","type":"function","z":"2006b4e6.d4439c","name":"","func":"var path=msg.path;\nvar it = path.lastIndexOf(\"/\");\nvar c=path.substring(0,it);\nmsg.path=c\nreturn msg;","outputs":1,"noerr":0,"x":1250,"y":200,"wires":[["f995e937.a53608"]],"info":"删除该文件夹后,为了判断是否是上级文件夹下最后一个文件夹。我们根据该文件夹路径获取上级文件夹路径。"},{"id":"f995e937.a53608","type":"link out","z":"2006b4e6.d4439c","name":"","links":["2acc1c4.3e5e2e4"],"x":1335,"y":200,"wires":[],"info":"递归空文件夹检查。"},{"id":"a502d4b.7e92a28","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.file=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":480,"wires":[["2810b76b.907328"]],"info":"将msg.payload复制到msg.file中,原msg.payload中内容还在。"},{"id":"2810b76b.907328","type":"split","z":"2006b4e6.d4439c","name":"","splt":".","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":270,"y":480,"wires":[["d30a2fe2.c23fa"]],"info":"用.拆分文件名。将文件名拆分成信息流"},{"id":"d30a2fe2.c23fa","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"字幕","vt":"str"},{"t":"cont","v":"人人影视","vt":"str"},{"t":"regex","v":"[\\u4E00-\\u9FA5]","vt":"str","case":true}],"checkall":"false","repair":false,"outputs":3,"x":410,"y":480,"wires":[[],[],["4db42465.c8e5cc"]],"info":"寻找文件名中的中文名字和第几季第几集。\n1、是否包含字幕二字。不是电影中文名舍弃。\n2、包含人人影视,不是电影中文名,舍弃。\n3、包含中文的内容,为电影的中文名。"},{"id":"b015e486.48e168","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.zhname=msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":480,"wires":[["3db21819.74b2f8"]],"info":"将获取到的中文内容保存到msg.zhname中"},{"id":"25dcefbc.03047","type":"fs-ops-move","z":"2006b4e6.d4439c","name":"移动文件","sourcePath":"path","sourcePathType":"msg","sourceFilename":"file","sourceFilenameType":"msg","destPath":"moviepath","destPathType":"msg","destFilename":"file","destFilenameType":"msg","link":false,"x":1280,"y":480,"wires":[["ba023516.efeb08","d1c843a5.f2f6a"]],"info":"将该文件移动到新建文件夹下"},{"id":"2e9cb10.98fba5","type":"fs-ops-mkdir","z":"2006b4e6.d4439c","name":"创建文件夹","path":"moviepath","pathType":"msg","dirname":"zhname","dirnameType":"msg","mode":"777","fullpath":"payload","fullpathType":"msg","x":1010,"y":480,"wires":[["ae2094f6.7e44c8"]],"info":"以中文名在预设的电影文件夹中新建文件夹"},{"id":"ae2094f6.7e44c8","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.moviepath=msg.moviepath+\"/\"+msg.zhname;\nreturn msg;","outputs":1,"noerr":0,"x":1150,"y":480,"wires":[["25dcefbc.03047"]],"info":"将新建文件夹添加到路径中"},{"id":"ba023516.efeb08","type":"link out","z":"2006b4e6.d4439c","name":"","links":["2acc1c4.3e5e2e4"],"x":1375,"y":480,"wires":[]},{"id":"6b92b01b.df167","type":"link in","z":"2006b4e6.d4439c","name":"","links":["a517315e.8267d"],"x":55,"y":480,"wires":[["a502d4b.7e92a28"]]},{"id":"4db42465.c8e5cc","type":"join","z":"2006b4e6.d4439c","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"-","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":480,"wires":[["b015e486.48e168"]],"info":"把获取到的中文名合并,考虑到有可能一个中文名被.分隔开,所以需要等待信息流中的所有中文内容,并且合并在一起"},{"id":"3db21819.74b2f8","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"empty"},{"t":"nempty"}],"checkall":"true","repair":false,"outputs":2,"x":830,"y":480,"wires":[["9a129340.4d0d3"],["2e9cb10.98fba5"]],"info":"判断是否正确获取到中文名,有些电影名中没有翻译或者没有中文字符例如1942,下一步就会出现错误"},{"id":"f6247f85.d4023","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"[\\u4E00-\\u9FA5]","vt":"str","case":true},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":830,"y":360,"wires":[["4c0e374c.519128"],["9a129340.4d0d3"]],"info":"判断是否正确获取到中文名,有些电影名中没有翻译或者没有中文字符例如1942,下一步就会出现错误"},{"id":"f6344c75.5f022","type":"file","z":"2006b4e6.d4439c","name":"归档错误","filename":"/home/归档错误.txt","appendNewline":true,"createDir":true,"overwriteFile":"false","encoding":"none","x":1140,"y":420,"wires":[[]],"info":"保存在一个文件中,以便后期查看,单独手动处理"},{"id":"9a129340.4d0d3","type":"function","z":"2006b4e6.d4439c","name":"","func":"msg.payload=msg.path+\"/\"+msg.file;\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":420,"wires":[["f6344c75.5f022"]],"info":"获取文件路径"},{"id":"c03394f1.d20c08","type":"switch","z":"2006b4e6.d4439c","name":"","property":"payload","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"msg.payload=[ \"@eaDir\" ]","vt":"jsonata"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":970,"y":200,"wires":[["8dd16de7.a2623","33c138dd.48dbe8"],["8dd16de7.a2623","33c138dd.48dbe8"]],"info":"\n1、文件夹下只有一个文件夹名字叫@eaDir(群晖索引文件)\n2、文件夹下什么文件和文件夹都没有,因此输出的为空。"},{"id":"91383374.24e0e","type":"debug","z":"2006b4e6.d4439c","name":"删除文件","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":550,"y":240,"wires":[],"info":"列出删除了什么文件"},{"id":"d1c843a5.f2f6a","type":"debug","z":"2006b4e6.d4439c","name":"移动文件","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"file","targetType":"msg","x":1650,"y":440,"wires":[],"info":"列出移动了哪些文件"},{"id":"920f6825.487bf8","type":"debug","z":"2006b4e6.d4439c","name":"删除文件夹","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"path","targetType":"msg","x":770,"y":20,"wires":[]},{"id":"33c138dd.48dbe8","type":"debug","z":"2006b4e6.d4439c","name":"删除文件夹","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"path","targetType":"msg","x":1110,"y":160,"wires":[],"info":"列出删除了哪些文件夹"},{"id":"c6ac1c1e.2182d","type":"comment","z":"2006b4e6.d4439c","name":"美剧处理","info":"","x":100,"y":320,"wires":[]},{"id":"e9531d34.09591","type":"comment","z":"2006b4e6.d4439c","name":"电影处理","info":"","x":100,"y":440,"wires":[]}]
回复

使用道具 举报

70

主题

596

帖子

3409

积分

论坛元老

Rank: 8Rank: 8

积分
3409
金钱
2813
HASS币
0
发表于 2020-5-24 12:23:26 | 显示全部楼层
还是看不明,真是小小白
回复

使用道具 举报

17

主题

357

帖子

2084

积分

论坛DIY达人

积分
2084
金钱
1717
HASS币
40
发表于 2020-5-24 13:49:06 | 显示全部楼层
学习学习
回复

使用道具 举报

8

主题

318

帖子

2172

积分

论坛技术达人

积分
2172
金钱
1844
HASS币
70
发表于 2020-5-24 19:21:39 | 显示全部楼层
哎呀,太精辟了!
回复

使用道具 举报

5

主题

66

帖子

332

积分

论坛分享达人

积分
332
金钱
266
HASS币
0
发表于 2020-5-24 21:13:32 | 显示全部楼层
支持一下。虽然没有的地方看不懂继续学习
回复

使用道具 举报

9

主题

527

帖子

2350

积分

金牌会员

Rank: 6Rank: 6

积分
2350
金钱
1823
HASS币
0
发表于 2020-5-24 22:00:25 | 显示全部楼层
这个教程好评~~~~
回复

使用道具 举报

62

主题

603

帖子

6380

积分

论坛元老

Rank: 8Rank: 8

积分
6380
金钱
5702
HASS币
240

教程狂人论坛风云人物

发表于 2020-5-25 11:46:43 | 显示全部楼层
去年录了个视频,能坚持看完,基本都能明白了。
nodered消息--msg的结构与应用
https://www.bilibili.com/video/BV1tE411R7iS
尝试过萝卜,我想你一定会忘记青瓜
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-21 23:38 , Processed in 0.590696 second(s), 36 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表