Event for skipped Import task

Hello,

I’m thinking to use the Hook Plugin to send a GET request via a bash script to a web hook endpoint for skipped albums especialy skipped by none-rec-action .

I don’t find any reference for skipped event in the source code. I’d mainly looked in importer.py, i’m really (really) in python so it might be not the right file where to look or it is not even possible…

If you can put in the right direction It would be great.

Thank you
J.

Hi! Give the import_task_choice event:
https://beets.readthedocs.io/en/stable/dev/plugins.html#listen-for-events

It happens right after the importer makes a decision about what to do with an album/item (including to skip it).

1 Like

Hi @adrian Thank you for your answer

It’s not perfect but it’ss work for those who are interested

config.yml :

hook:
  hooks: 
    - event: import_task_choice
      command: /bin/bash -c "/myscripts/skipped.sh \"{task.choice_flag}\" \"{task.paths}\" \"{task.rec}\""

skipped.sh :

#!/bin/bash

# arg 1 = task.choice_flag
# arg 2 = task.paths
# arg 3 = task.rec

choice_flag="$1"

# remove "[b'" at the beginning and "']" at the end
path=$(echo "$2" | sed -e "s/^\[b'//" -e "s/'\]$//")

#assign the path and the directory name
base_path=$(basename "$path")
dir_name=$(dirname "$path")


# test the output
echo $path
echo $base_path
echo $dir_name

# send a POST request with curl
if [ "$choice_flag" == 'action.SKIP' ]; then
  curl \
    --request POST \
    --data-urlencode "name=$base_path" \
    --data-urlencode "path=$dir_name" \
    --header "X-API-Key: $api_key" \
    "https://example.com"
fi

exit 0

i haven’t find how to get imported album’s path properly or a way to print all task.* possibilities

1 Like