Skip to content

Commit

Permalink
Check if $id defined before fetching segments
Browse files Browse the repository at this point in the history
Fixed #13
  • Loading branch information
nichobi committed May 31, 2021
1 parent bb36a0e commit eb629e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sponsorblockcast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd "$SBCDIR" || exit 1

get_segments () {
id=$1
if [ ! -f "$id".segments ]
if [ -n "$id" ] && [ ! -f "$id".segments ]
then
curl -fs "https://sponsor.ajay.app/api/skipSegments?videoID=$id&categories=$categories" |\
jq -r '.[] | (.segment|map_values(tostring)|join(" ")) + " " + .category' > "$id.segments"
Expand All @@ -25,7 +25,7 @@ watch () {
uuid=$1
go-chromecast watch -u "$uuid" --interval 1 \
| while read -r status; do
if echo "$status" | grep -q "YouTube (PLAYING)"
if echo "$status" | grep -q "YouTube (PLAYING)"
then
video_id=$(echo "$status" | grep -oP "id=\"\K[^\"]+")
get_segments "$video_id"
Expand Down

0 comments on commit eb629e4

Please sign in to comment.