catt icon indicating copy to clipboard operation
catt copied to clipboard

Improvements to `add`

Open sigboe opened this issue 4 years ago • 5 comments

I want two improvements to the add subcommand.

  1. I wish it would fall back to using the cast subcommand if no video is already playing.
  2. I wish it would fall back to using the cast subcommand if it was an unsupported URL.

This is only because I launch catt from my browser, where I have one command/button for each my chromecasts and I would I would not want many more permutations to be able to queue the videos.

Meanwhile I'll just write a wrapper script

sigboe avatar Mar 22 '20 13:03 sigboe

I think those are reasonable feature requests (although from a general user perspective, 1 makes a lot more sense than 2). It's not going to be super-easy to implement, because of the way that the code is currently structured, so I'm afraid it's not going to be at the top of my todo list.

theychx avatar Mar 22 '20 14:03 theychx

@theychx Thanks, I whipped up a quick wrapper that I will use in the meantime in my browsers (Firefox using youtube 2 player addon, and qutebrowser just using keybinding)

#!/usr/bin/env bash
# Author: Sigurd Bøe
# Open domain code

[[ -x "$(command -v catt)" ]] || { echo "catt not found" ; exit 1 ; }

while (( "${#}" )); do
    case "${1}" in
        -d)
            device="${2}"
            d="-d"
            shift 2
            ;;
        *)
            url="${1}"
            shift
            ;;
    esac
done

[[ -z "${url}" ]] && { echo "url not provided" ; exit 1 ; }

case "${url}" in
    *youtub*)	
        youtube="true" ;;
    *)
        youtube="false" ;;
esac

deviceactive="false"
catt -d "${device}" info > /dev/null 2> /dev/null && deviceactive="true"

if [[ "${deviceactive}" == "true" ]] && [[ "${youtube}" == "true" ]]; then
    catt "${d}" "${device}" add "${url}"
else
    catt "${d}" "${device}" cast "${url}"
fi

sigboe avatar Mar 22 '20 14:03 sigboe

That script looks nice, though I agree that 1 is much more sensible than 2. With 2, I'm not sure I'd want it overwriting your entire playlist if you send a weird URL, but catt should definitely default to "play" if nothing is already playing.

skorokithakis avatar Mar 23 '20 00:03 skorokithakis

What about optionally?

sigboe avatar Mar 23 '20 07:03 sigboe

Hmm, I'm not sure I see the rationale for "add" performing a "cast" on an unsupported URL ever (no matter the option). It's a different operation.

skorokithakis avatar Mar 23 '20 16:03 skorokithakis