#!/usr/bin/env sh ## Config if [ ! -d "/root/.youtube-local" ]; then # make dir install -d /root/.youtube-local # generate config cat > /root/.youtube-local/settings.txt <<- EOF # 0 - Off # 1 - On, except video # 2 - On, including video (see warnings) route_tor = $ROUTE_TOR tor_port = $TOR_PORT tor_control_port = TOR_CONTROL_PORT port_number = 8080 # This will allow others to connect to your Youtube Local instance as a website. # For security reasons, enabling this is not recommended. allow_foreign_addresses = $ALLOW_FOREIGN_ADDRESSES # 0 - off by default # 1 - only manually created subtitles on by default # 2 - enable even if automatically generated is all that's available subtitles_mode = $SUBTITLES_MODE # ISO 639 language code: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes subtitles_language = $SUBTITLES_LANG # 0 - Related videos disabled # 1 - Related videos always shown # 2 - Related videos hidden; shown by clicking a button related_videos_mode = $RELATED_VIDEOS_MODE # 0 - Video comments disabled # 1 - Video comments always shown # 2 - Video comments hidden; shown by clicking a button comments_mode = $COMMENTS_MODE enable_comment_avatars = $ENABLE_COMMENTS_AVATARS # 0 to sort by top # 1 to sort by newest default_comment_sorting = $DEFAULT_COMMENT_SORTING theater_mode = $THEATER_MODE default_resolution = $DEFAULT_RESOLUTION use_video_player = $USE_VIDEO_PLAYER proxy_images = $PROXY_IMAGES use_comments_js = $USE_COMMENTS_JS use_sponsorblock_js = $USE_SPONSORBLOCK_JS theme = $THEME font = $FONT embed_page_mode = $EMBED_PAGE_MODE autocheck_subscriptions = $AUTOCHECK_SUBSCRIPTIONS # Developer use to debug 403s gather_googlevideo_domains = $GATHER_GOOGLEVIDEO_DOMAINS # Save all responses from youtube for debugging debugging_save_responses = $DEBUGGING_SAVE_RESPONSES # Do not change, remove, or comment out this value, or else your settings may be lost or corrupted settings_version = 3 EOF fi if [ "$ROUTE_TOR" = 1 ] || [ "$ROUTE_TOR" = 2 ]; then cat > /etc/tor/torrc <<- EOF Log notice stdout SocksPort ${TOR_PORT:-9050} # Default: Bind to localhost:9050 for local connections. MaxCircuitDirtiness ${MAX_CIRCUIT:-300} CircuitBuildTimeout ${CIRCUIT_TIMEOUT:-300} ExcludeExitNodes {US} StrictNodes 1 EOF tor -f /etc/tor/torrc --runasdaemon 1 # check health tor while :; do checkurl=$(curl --socks5 "localhost:${TOR_PORT:-9050}" -o /dev/null -s -w "%{http_code}\n" "${URL_CHECK:-https://www.youtube.com/results?search_query=rms}") if [ "$checkurl" = '502' ] || [ "$checkurl" = '302' ]; then pkill tor && tor -f /etc/tor/torrc --runasdaemon 1 2>&1 pkill python3 && /usr/bin/python3 /srv/app/server.py else pgrep python3 > /dev/null || exec /usr/bin/python3 /srv/app/server.py fi sleep 5 done else exec /usr/bin/python3 /srv/app/server.py fi