Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
854c6ea164 | |
|
f993811649 | |
|
d28fa521a9 | |
|
9becdcc826 | |
|
c22a96e877 | |
|
d3d4fd02dd |
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ FILENAME = getvods
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(info modify the Makefile with the directory you wish to place the script in)
|
$(info modify the Makefile with the directory you wish to place the script in)
|
||||||
$(info default is $(INSTALLDIR))
|
$(info default is /usr/bin)
|
||||||
$(info place your client_secret and client_id in ~/.config/getvods)
|
$(info place your client_secret and client_id in ~/.config/getvods)
|
||||||
$(info run make install as root to install the script at $(INSTALLDIR)/$(FILENAME) when you're ready)
|
$(info run make install as root to install the script at $(INSTALLDIR)/$(FILENAME) when you're ready)
|
||||||
$(info run make uninstall as root to remove script)
|
$(info run make uninstall as root to remove script)
|
||||||
|
|
32
getvods.sh
32
getvods.sh
|
@ -48,7 +48,7 @@ get_token(){
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -f "${CFG_DIR}/token.json" ] && [ -f "${CFG_DIR}/expiration.txt" ] && {
|
[ -f "${CFG_DIR}/token.json" ] && [ -f "${CFG_DIR}/expiration.txt" ] && {
|
||||||
[ "$(cat "${CFG_DIR}/expiration.txt")" -le "$(date +%s)" ] && get_token
|
[ "$(cat "${CFG_DIR}/expiration.txt")" -le "$(date +%s)" ] && get_token || :
|
||||||
} || {
|
} || {
|
||||||
get_token
|
get_token
|
||||||
}
|
}
|
||||||
|
@ -63,15 +63,17 @@ access_token="$(grep -o "access_token\":\"[a-zA-Z0-9]\+" "${CFG_DIR}/token.json"
|
||||||
# get the username to search for
|
# get the username to search for
|
||||||
declare -i retries=0
|
declare -i retries=0
|
||||||
[ ! -z "${1}" ] && {
|
[ ! -z "${1}" ] && {
|
||||||
[ "${#1}" -ge "4" ] && [ "${#1}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${1}" >/dev/null && {
|
while :; do
|
||||||
login="${1}"
|
[ "${#1}" -ge "4" ] && [ "${#1}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${1}" >/dev/null && {
|
||||||
break
|
login="${1}"
|
||||||
}
|
break
|
||||||
printf "username must be between 4 and 25 characters long\n"
|
}
|
||||||
printf "username may have only characters a-z A-Z 0-9 and _\n"
|
printf "username must be between 4 and 25 characters long\n"
|
||||||
retries+=1
|
printf "username may have only characters a-z A-Z 0-9 and _\n"
|
||||||
|
retries+=1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
[ -z "${login}"] && {
|
[ -z "${login}" ] && {
|
||||||
while :; do
|
while :; do
|
||||||
read -p 'type in username >' login
|
read -p 'type in username >' login
|
||||||
[ "${#login}" -ge "4" ] && [ "${#login}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${login}" >/dev/null && break
|
[ "${#login}" -ge "4" ] && [ "${#login}" -le "25" ] && grep "[a-zA-Z0-9_]\{4,25\}" <<< "${login}" >/dev/null && break
|
||||||
|
@ -122,7 +124,7 @@ utf-16-surrogate-pair-decode() {
|
||||||
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
remain="$(printf '\\U%8.8x' "${U}")${BASH_REMATCH[4]}${remain}"
|
||||||
out="${BASH_REMATCH[1]}"
|
out="${BASH_REMATCH[1]}"
|
||||||
done
|
done
|
||||||
printf "%s%s\n" "${out}" "${remain}"
|
printf "${out}${remain}\n" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
printf "VODs of ${login}\n"
|
printf "VODs of ${login}\n"
|
||||||
|
@ -139,7 +141,7 @@ done < <(grep -o '"title":"\(\\"\|[^"]*\)*",' "${CFG_DIR}/streamarchives.json")
|
||||||
|
|
||||||
j=0
|
j=0
|
||||||
while IFS= read -r i; do
|
while IFS= read -r i; do
|
||||||
duration[${j}]="${i:11:-1}"
|
duration[${j}]="${i:12:-1}"
|
||||||
j+=1
|
j+=1
|
||||||
done < <(grep -o "\"duration\":\"[a-z0-9]\+\"" "${CFG_DIR}/streamarchives.json")
|
done < <(grep -o "\"duration\":\"[a-z0-9]\+\"" "${CFG_DIR}/streamarchives.json")
|
||||||
|
|
||||||
|
@ -154,10 +156,12 @@ for i in {0..19}; do
|
||||||
printf "%s:\t%s %s\n" "$((${i}+1))" "${titles[${i}]}" "${duration[${i}]}"
|
printf "%s:\t%s %s\n" "$((${i}+1))" "${titles[${i}]}" "${duration[${i}]}"
|
||||||
done
|
done
|
||||||
|
|
||||||
declare -i retries
|
retries=0
|
||||||
while :; do
|
while :; do
|
||||||
read -p "choose a video from the list (type 1-20) >" choice
|
read -p "choose a video from the list (type 1-20) >" choice
|
||||||
grep "[0-9]\{1,2\}" <<< "${choice}" && [ "${choice}" -ge 0 ] && [ "${choice}" -le 20 ] && break
|
grep "[0-9]\{1,2\}" <<< "${choice}" >/dev/null && [ "${choice}" -ge 0 ] && [ "${choice}" -le 20 ] && break
|
||||||
printf "%s is not a number from 1-20\n" "${choice}"
|
printf "%s is not a number from 1-20\n" "${choice}"
|
||||||
|
retries+=1
|
||||||
|
[ "${retries}" -ge 3 ] && on_fail "exceeded max retries" "1"
|
||||||
done
|
done
|
||||||
printf "%s\n" "${urls[$((${choice}-1))]}" | xclip -selection clipboard
|
printf "%s" "${urls[$((${choice}-1))]}" | xclip -selection clipboard
|
||||||
|
|
Loading…
Reference in New Issue