nichobi / sponsorblockcast

A shell script that skips sponsored YouTube content on all local Chromecasts
GNU General Public License v3.0
348 stars 16 forks source link

jq: error #2

Closed unbraind closed 3 years ago

unbraind commented 3 years ago

I get the following error when a chromcast starts playing:

jq: error (at :0): string ("") and number (11.649165) cannot be added

nichobi commented 3 years ago

Interesting, I haven't run into this myself, maybe depends on the jq version. Can you try making the following substitution on line 20 in sponsorblockcast.sh

get_segments () {
   if [ ! -f "$id".segments ]
   then
     curl -fs "https://sponsor.ajay.app/api/skipSegments?videoID=$id&categories=$categories" |\
-    jq -r '.[] | (.segment|join(" ")) + " " + .category' > "$id.segments"
+    jq -r '.[] | (.segment|map_values(tostring)|join(" ")) + " " + .category' > "$id.segments"
   fi
 }

Hopefully that's enough to fix it, if not I'll have to look into it further tomorrow.

unbraind commented 3 years ago

Thank you very much, now it works!