Skip to content

Instantly share code, notes, and snippets.

@luisnquin
Created January 4, 2023 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisnquin/710e298b0a073eb7a1421411369d629a to your computer and use it in GitHub Desktop.
Save luisnquin/710e298b0a073eb7a1421411369d629a to your computer and use it in GitHub Desktop.
Bash script to get the current billboard of cinerama in your city
# You can extract your own 'city' value from 'http://www.cinerama.com.pe/cines'
curl --silent http://www.cinerama.com.pe/cartelera_cine/{city} | htmlq --text .row .container .card .card-header | sed 's/.*/\L&/; s/[a-z]*/\u&/g'
@luisnquin
Copy link
Author

However, see this

billboard() {
    local city=$1

    if [[ "$city" == "" ]]; then
        local output=$(curl --silent http://www.cinerama.com.pe/cines |
            htmlq --pretty .row .container .card .row .col-md-8 .card-body .btn --attribute href |
            awk '{sub("cartelera_cine/",""); print}')
        set -A cities $(echo "$output" | tr '\n' ' ')

        local reset=$(tput sgr0)

        echo "Options:"

        for city in "${cities[@]}"; do
            color=$((RANDOM % 256))
            color_code=$(tput setaf $color)
            echo " - ${color_code}${city}${reset}"
        done

        return
    fi

    # TODO: improve input verification in case of empty response
    curl --silent http://www.cinerama.com.pe/cartelera_cine/$city | htmlq --text .row .container .card .card-header | sed 's/.*/\L&/; s/[a-z]*/\u&/g'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment