#!/bin/bash

animecopy() {
  url="$1"
  case "$url" in
    */) ;; # already ends with /
    *) url="$url/" ;;
  esac
  wget -qO- "$url" | \
  grep -o '"[^"]*\.\(mkv\|mp4\)"' | \
  tr -d '"' | \
  sed "s|^|$url|" | \
  xclip -selection clipboard
  echo "Copied .mkv and .mp4 URLs from $url to clipboard!"
}

animecopy "$1"
