Skip to content
Snippets Groups Projects
Select Git revision
  • 2e99c350493014e2971d7278cdfc923d92bb1e4e
  • master default
2 results

deduce_aws_region

Blame
    • nimrod's avatar
      2e99c350
      Address pre-commit issues. · 2e99c350
      nimrod authored
      - Bandit complains on using urlopen, ignore since I'm using a hard-coded
      URL.
      - Pylint complains on the module name, rename.
      - Remove the docker-compose hook, no docker-compose.yml.
      2e99c350
      History
      Address pre-commit issues.
      nimrod authored
      - Bandit complains on using urlopen, ignore since I'm using a hard-coded
      URL.
      - Pylint complains on the module name, rename.
      - Remove the docker-compose hook, no docker-compose.yml.
    kodi-scan 1.05 KiB
    #!/bin/sh
    set -eu
    
    scan() {
        case "${1:-}" in
            audio) curl \
                    --data-binary \
                    '{ "jsonrpc": "2.0", "method": "AudioLibrary.Scan", "id": "transmission"}' \
                    -H 'content-type: application/json;' \
                    http://172.18.0.1:8080/jsonrpc ;;
            video) curl \
                    --data-binary \
                    '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan", "id": "transmission"}' \
                    -H 'content-type: application/json;' \
                    http://172.18.0.1:8080/jsonrpc ;;
            *) scan video; scan audio ;;
        esac
    }
    
    starts_with() {
        [ "${1##$2}" != "$1" ]
    }
    
    is_in_dir() {
        ! starts_with "$(realpath --relative-base "$1" "$2")" '/'
    }
    
    if [ -z "${TR_TORRENT_DIR:-}" ]
    then
        scan
    elif is_in_dir '/var/lib/transmission/Downloads/TV Shows' "$TR_TORRENT_DIR"
    then
        scan video
    elif is_in_dir '/var/lib/transmission/Downloads/Movies' "$TR_TORRENT_DIR"
    then
        scan video
    elif is_in_dir '/var/lib/transmission/Downloads/Music' "$TR_TORRENT_DIR"
    then
        scan audio
    else
        scan
    fi