I created a Node-Red flow that is capable of showing me what is currently playing on Netflix for my account.
I still need to add a loop and switch to trigger this flow when Netflix is active but for now I want to find out if it is possible to use the created sensor as a now playing source in a Media Control card?
Is such thing possible with a Media Control card or any other card?
Use a different sensor as Now Playing source?
If you want to use this flow follow the instructions in this video: https://www.youtube.com/watch?v=Lqo-Lf-iq60 on how to get the needed links/cookie data and add Node-RED Companion Integration using HACS.
When imported edit nodes: http request, change and sensor
All credits for ibleedcubbieblue26 who created the initial flow.
I ran in to some issues that certain Netflix titles contained double information so i stripped it and this is the result.
The full node-red flow:
Note: It can probably be optimized but for me it works now.
[{"id":"a7c84c79bae391c2","type":"tab","label":"Netflix Now Playing","disabled":false,"info":"","env":[]},{"id":"fa5a8027e7898f2e","type":"inject","z":"a7c84c79bae391c2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"14400","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":100,"wires":[["875601fd8ad74584"]]},{"id":"aa8217f31a7bd270","type":"debug","z":"a7c84c79bae391c2","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":160,"wires":[]},{"id":"875601fd8ad74584","type":"http request","z":"a7c84c79bae391c2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"<insert netflix viewing activity url here>","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"cookie","valueType":"other","valueValue":"<insert cookie data here>"}],"x":170,"y":160,"wires":[["dc3586b3fab31b48"]]},{"id":"dc3586b3fab31b48","type":"html","z":"a7c84c79bae391c2","name":"","property":"payload","outproperty":"payload","tag":"#appMountPoint > div > div > div > div.bd > div > div > ul","ret":"html","as":"single","x":285,"y":160,"wires":[["a77235aafdf2e7c8"]],"l":false},{"id":"ee290267f7626243","type":"ha-sensor","z":"a7c84c79bae391c2","name":"schumi2004 Netflix Now Playing","entityConfig":"ec75a1e558bbb195","version":0,"state":"schumi2004 Netflix Now Playing","stateType":"str","attributes":[{"property":"data","value":"payload[0]","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":810,"y":100,"wires":[["aa8217f31a7bd270"]]},{"id":"a77235aafdf2e7c8","type":"change","z":"a7c84c79bae391c2","name":"","rules":[{"t":"change","p":"payload[0]","pt":"msg","from":"<span class=\"tooltip\">Hide from viewing history</span>","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload[0]","pt":"msg","from":"<a class=\"deleteBtn\" href=\"#\">⊘</a>","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload[0]","pt":"msg","from":"<div class=\"col report\"><a class=\"reportLink\" href=\"/reportproblem/(\\d{8})\">Report a problem</a></div><div class=\"col delete\"></div>","fromt":"re","to":"","tot":"str"},{"t":"change","p":"payload[0]","pt":"msg","from":"<a href=\"/","fromt":"str","to":"<a href=\"https://www.netflix.com/","tot":"str"},{"t":"change","p":"payload[0]","pt":"msg","from":"<li class=\"retableRow\">","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"</li>","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":160,"wires":[["c339b8b59524e251"]]},{"id":"3a5216fbbda128a3","type":"comment","z":"a7c84c79bae391c2","name":"schumi2004","info":"","x":130,"y":60,"wires":[]},{"id":"c339b8b59524e251","type":"function","z":"a7c84c79bae391c2","name":"Now playing","func":"// Input contains the data\nvar input = msg.payload[0];\n\n// Find the start and end positions of the desired substring\nvar start = input.indexOf('<div class=\"col title\"><a href=\"') + '<div class=\"col title\"><a href=\"'.length;\nvar end = input.indexOf('</a></div>');\n\n// Cut the substring from the input\nvar substring = input.substring(start, end);\n\n// Remove the URL and keep just the title\nsubstring = substring.replace(/https:\\/\\/www\\.netflix\\.com\\/title\\/\\d+\">/, '');\n\n// Remove random duplicates\nsubstring = removeDuplicates(substring);\n\n// Function to remove random duplicates\nfunction removeDuplicates(inputString) {\n var words = inputString.split(/\\s+/); // Split the string into words\n var uniqueWords = Array.from(new Set(words)); // Remove duplicates\n var resultString = uniqueWords.join(' '); // Put the unique words back together\n return resultString;\n}\n\n// Send the substring as output\nmsg.payload[0] = substring;\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":570,"y":100,"wires":[["ee290267f7626243"]]},{"id":"ec75a1e558bbb195","type":"ha-entity-config","server":"88a41fe6.efbb1","deviceConfig":"","name":"schumi2004 Netflix Now Playing","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"schumi2004 Netflix Now Playing"},{"property":"icon","value":""},{"property":"entity_picture","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"88a41fe6.efbb1","type":"server","name":"Home Assistant RT","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]