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

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

[教程系列] Node Red 实现电视剧更新自动提醒

[复制链接]

12

主题

85

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
661
HASS币
10
发表于 2023-11-22 10:41:59 | 显示全部楼层 |阅读模式
本帖最后由 KevinYAN 于 2023-11-22 15:18 编辑

最近在追个电视剧,由于免费网站更新电视剧的时间不定,为了尽早追到,不断的刷新网页不是一个太好的操作。
于是有了下边的流程。
微信截图_20231122102624.png
效果如下:
微信可以收到一条消息,并且小爱也会进行语音播报。
微信截图_20231122102740.png


实现思路,在网站F12调试跟踪,根据对多个免费网站的跟踪,发现都能提取到一个数组,记录电视剧每集的资源地址。

示例:
《以爱为营》全集在线观看-国产剧_西瓜影音_西瓜影院_免费在线 (xigua60.com)

微信截图_20231122103219.png

如图,是可以非常轻松的拿到每一集电视剧的m3u8文件的。判断这个video数组的数量,就可以实现判断是否有更新。

题外话:
   m3u8文件实际是个目录文件,每一集电视剧40多分钟,会别切分成很多很小的片段,每一个片段的地址信息,就记录在这个文件中。以前还通过这个文件下载电视剧。脚本也是比较容易实现。


我这里直接放流程代码:
[{"id":"b2699fefc1a90f2f","type":"group","z":"9f46062cc77a7dfe","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["c71c08e2ca479574","43a0262447ae8e06","5da19fe78409dffb","dfe9cf87f94ef7be","10686dd1f85807c3","8a6394c7963d51cc","865282639363dd21","b1d821280749d20f","73466f04b204673a"],"x":34,"y":3499,"w":1022,"h":122},{"id":"c71c08e2ca479574","type":"inject","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"1min/c","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":3580,"wires":[["b1d821280749d20f"]]},{"id":"43a0262447ae8e06","type":"http request","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://www.xigua60.com/ass.php?url=dp&vid=110365&vfrom=0&vpart=0&cb=jQuery110204111119050263272_1700129369033&_=1700129369034","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Cookie","valueType":"other","valueValue":"PHPSESSID=a7j6qstcgkkqghor12ron94trk; Hm_lvt_d54f911a3c277d1625ac59778b7afe5b=1699961958,1700044933,1700099727,1700129302; recente=%5B%7B%22vod_name%22%3A%22%E4%BB%A5%E7%88%B1%E4%B8%BA%E8%90%A5%22%2C%22vod_url%22%3A%22http%3A%2F%2Fwww.xigua60.com%2Fplay%2F110365-0-0.html%22%2C%22vod_part%22%3A%22%E7%AC%AC1%E9%9B%86%22%7D%5D; Hm_lpvt_d54f911a3c277d1625ac59778b7afe5b=1700129366; security_session_verify=e8143c915798cf5ed4416be4584d89ef"},{"keyType":"other","keyValue":"Accept","valueType":"other","valueValue":"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"},{"keyType":"other","keyValue":"User-Agent","valueType":"other","valueValue":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Mobile Safari/537.36 Edg/119.0.0.0"}],"x":560,"y":3580,"wires":[["5da19fe78409dffb"]]},{"id":"5da19fe78409dffb","type":"function","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"提取","func":"msg.payload = msg.payload.split("(")\nmsg.payload = msg.payload[1].split(")")[0]\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":3580,"wires":[["dfe9cf87f94ef7be"]]},{"id":"dfe9cf87f94ef7be","type":"json","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"","property":"payload","action":"","pretty":false,"x":810,"y":3580,"wires":[["10686dd1f85807c3"]]},{"id":"10686dd1f85807c3","type":"function","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"判新","func":"var new_count = msg.payload.s.video.length\nvar old_count = global.get("old_count")||new_count;\nvar jicha = new_count - old_count\n\nif ( jicha > 0 ){\n    msg.payload = "主人好,您关注的电视剧更新了" + jicha + "集,从" + old_count + "更新到" + new_count +"集了,请关注哦。"\n    global.set("old_count",new_count); \n    return msg;\n}else {\n    global.set("old_count", new_count);\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":930,"y":3580,"wires":[["8a6394c7963d51cc"]]},{"id":"8a6394c7963d51cc","type":"link out","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"link out 98","mode":"link","links":["0766e19cc29bf18e","d746ba0c8e810306"],"x":1015,"y":3580,"wires":[]},{"id":"865282639363dd21","type":"comment","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"电视剧更新监控","info":"","x":140,"y":3540,"wires":[]},{"id":"b1d821280749d20f","type":"time-range-switch","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":"时间范围","lat":"","lon":"","startTime":"18:30:00","endTime":"22:00:00","startOffset":0,"endOffset":0,"x":280,"y":3580,"wires":[["43a0262447ae8e06"],["73466f04b204673a"]]},{"id":"73466f04b204673a","type":"join","z":"9f46062cc77a7dfe","g":"b2699fefc1a90f2f","name":" ","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"30","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":430,"y":3580,"wires":[["43a0262447ae8e06"]]}]


流程简要说明:
     流程时间范围,取了最容易更新的时间段,配合后边30合并节点,实现了18:30-22:00每一分钟判断一次,其他时间每30分钟判断一次。 不建议太频繁获取。

   http请求直接请求数组信息的url, 获取到数组信息后,”提取“节点对字符串进行了删减处理,然后转为json, 在通过”判断“节点进行数量判断。 最后输入的小爱播报就行。
微信截图_20231122103811.png




以后追剧了,只需要F12复制这个链接到node red,即可实现自动更新提醒。  

可能大佬们还有更好的思路,欢迎交流学习。



文本导入提示括号截取的问题,这里重新放下导出文件:
flows (2).json (3.8 KB, 下载次数: 11)

这个是一个一个选的,测试没问题。

回复

使用道具 举报

0

主题

53

帖子

1923

积分

金牌会员

Rank: 6Rank: 6

积分
1923
金钱
1870
HASS币
0
发表于 2023-11-22 11:17:02 | 显示全部楼层
代码导入有错误
回复

使用道具 举报

12

主题

85

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
661
HASS币
10
 楼主| 发表于 2023-11-22 12:30:02 | 显示全部楼层

恩,看到看,字符串截取的括号。这个是论坛编辑器的问题。 你在上文最下边下载flows文件导入吧。
回复

使用道具 举报

3

主题

121

帖子

1601

积分

金牌会员

Rank: 6Rank: 6

积分
1601
金钱
1480
HASS币
0
发表于 2023-11-22 13:03:51 | 显示全部楼层
楼主,你导出文件没导出全呀。
回复

使用道具 举报

2

主题

178

帖子

713

积分

高级会员

Rank: 4

积分
713
金钱
535
HASS币
0
发表于 2023-11-22 14:09:49 | 显示全部楼层
导入之后就一个这
1700633356372.jpg
回复

使用道具 举报

12

主题

85

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
661
HASS币
10
 楼主| 发表于 2023-11-22 14:45:30 | 显示全部楼层
xiangboshi 发表于 2023-11-22 14:09
导入之后就一个这

更新了,重下看看
回复

使用道具 举报

12

主题

85

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
661
HASS币
10
 楼主| 发表于 2023-11-22 14:45:52 | 显示全部楼层
jole 发表于 2023-11-22 13:03
楼主,你导出文件没导出全呀。

更新了,哈哈。
回复

使用道具 举报

2

主题

178

帖子

713

积分

高级会员

Rank: 4

积分
713
金钱
535
HASS币
0
发表于 2023-11-22 15:08:53 | 显示全部楼层
KevinYAN 发表于 2023-11-22 14:45
更新了,重下看看

导入就多了个http请求的节点
回复

使用道具 举报

12

主题

85

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
661
HASS币
10
 楼主| 发表于 2023-11-22 15:18:58 | 显示全部楼层
xiangboshi 发表于 2023-11-22 15:08
导入就多了个http请求的节点

更新了,测试导入没问题了。
回复

使用道具 举报

2

主题

178

帖子

713

积分

高级会员

Rank: 4

积分
713
金钱
535
HASS币
0
发表于 2023-11-22 16:20:31 | 显示全部楼层
KevinYAN 发表于 2023-11-22 15:18
更新了,测试导入没问题了。

问下 微信在哪接入
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 22:52 , Processed in 0.173398 second(s), 34 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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