Personal dotfiles.
at main 52 lines 1.7 kB view raw
1#!/bin/bash 2 3# Install twitch plugin: 4# 5# 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' 6 7# purple script credentials 8PURPLE_CLIENT_ID=hvxqh56odhgw9hcgm4krxyztmgn82n 9PURPLE_CLIENT_SECRET=mrk3wt08q4aw5ll5nz58pf6e2wlmwg 10 11 12# select stream 13if [ $# -eq 1 ]; then 14 STREAM=$1 15else 16 # obtain the list of streams 17 JSON_STREAM_LIST=$(purple --popular -l es) 18 # create visual options 19 OPTIONS_LIST=$(echo "$JSON_STREAM_LIST" | jq -r '.[] | "\(.user_name) - \(.viewer_count) - \(.game_name) - \(.title)"') 20 IFS=$'\n' read -r -d '' -a options <<< "$OPTIONS_LIST" 21 # create stream options 22 STREAM_LIST=$(echo "$JSON_STREAM_LIST" | jq -r '.[] | "\(.user_login)"') 23 IFS=$'\n' read -r -d '' -a streams <<< "$STREAM_LIST" 24 # select stream 25 choice=$(printf "%s\n" "${options[@]}" | fuzzel --dmenu --width 88) 26 [[ -z "$choice" ]] && exit 1 27 for i in "${!options[@]}"; do 28 if [[ "${options[$i]}" == "$choice" ]]; then 29 STREAM="${streams[$i]}" 30 break 31 fi 32 done 33fi 34 35# play stream 36PROXIES=( 37 "https://twitch.nadeko.net/" 38 "https://eu2.luminous.dev" 39 "https://as.luminous.dev" 40 "https://lb-as.cdn-perfprod.com" 41 "https://lb-sa.cdn-perfprod.com" 42 "https://eu.luminous.dev" 43 "https://lb-eu3.cdn-perfprod.com" 44 "https://lb-eu5.cdn-perfprod.com" 45) 46 47PROXY_LIST=$(IFS=,; echo "${PROXIES[*]}") 48streamlink "https://www.twitch.tv/$STREAM" best \ 49 --player mpv \ 50 --twitch-proxy-playlist="$PROXY_LIST" \ 51 --twitch-low-latency \ 52 --twitch-proxy-playlist-fallback