#!/bin/bash # Install twitch plugin: # # INSTALL_DIR="${XDG_DATA_HOME:-${HOME}/.local/share}/streamlink/plugins"; mkdir -p "$INSTALL_DIR"; curl -L -o "$INSTALL_DIR"/twitch.py 'https://github.com/2bc4/streamlink-ttvlol/releases/latest/download/twitch.py' # purple script credentials PURPLE_CLIENT_ID=hvxqh56odhgw9hcgm4krxyztmgn82n PURPLE_CLIENT_SECRET=mrk3wt08q4aw5ll5nz58pf6e2wlmwg # select stream if [ $# -eq 1 ]; then STREAM=$1 else # obtain the list of streams JSON_STREAM_LIST=$(purple --popular -l es) # create visual options OPTIONS_LIST=$(echo "$JSON_STREAM_LIST" | jq -r '.[] | "\(.user_name) - \(.viewer_count) - \(.game_name) - \(.title)"') IFS=$'\n' read -r -d '' -a options <<< "$OPTIONS_LIST" # create stream options STREAM_LIST=$(echo "$JSON_STREAM_LIST" | jq -r '.[] | "\(.user_login)"') IFS=$'\n' read -r -d '' -a streams <<< "$STREAM_LIST" # select stream choice=$(printf "%s\n" "${options[@]}" | fuzzel --dmenu --width 88) [[ -z "$choice" ]] && exit 1 for i in "${!options[@]}"; do if [[ "${options[$i]}" == "$choice" ]]; then STREAM="${streams[$i]}" break fi done fi # play stream PROXIES=( "https://twitch.nadeko.net/" "https://eu2.luminous.dev" "https://as.luminous.dev" "https://lb-as.cdn-perfprod.com" "https://lb-sa.cdn-perfprod.com" "https://eu.luminous.dev" "https://lb-eu3.cdn-perfprod.com" "https://lb-eu5.cdn-perfprod.com" ) PROXY_LIST=$(IFS=,; echo "${PROXIES[*]}") streamlink "https://www.twitch.tv/$STREAM" best \ --player mpv \ --twitch-proxy-playlist="$PROXY_LIST" \ --twitch-low-latency \ --twitch-proxy-playlist-fallback