Skip to content

Instantly share code, notes, and snippets.

@eboye
Last active January 14, 2026 07:49
Show Gist options
  • Select an option

  • Save eboye/9d86f09439e876b33b851a3ab88f2ae7 to your computer and use it in GitHub Desktop.

Select an option

Save eboye/9d86f09439e876b33b851a3ab88f2ae7 to your computer and use it in GitHub Desktop.

Open N1 in VLC:

curl -s https://gist.githubusercontent.com/eboye/9d86f09439e876b33b851a3ab88f2ae7/raw/18f20706505ed355037e3e9c05c32e320db41b84/n1nova.sh | bash -s -- 1

Open NovaS in VLC:

curl -s https://gist.githubusercontent.com/eboye/9d86f09439e876b33b851a3ab88f2ae7/raw/18f20706505ed355037e3e9c05c32e320db41b84/n1nova.sh | bash -s -- 2
#!/bin/bash
# Script to stream N1 or Nova channels using VLC, checking for native or Flatpak install.
# Usage:
# Non-interactive (provide choice as argument):
# curl -s <gist_url> | bash -s -- 1 # For N1
# curl -s <gist_url> | bash -s -- 2 # For Nova
#
# Dependencies: curl, grep, sed, bash, vlc (native or flatpak)
# --- Debugging Configuration ---
# Set DEBUG_MODE=true to enable verbose debugging output.
# Set DEBUG_MODE=false to disable it for cleaner output.
DEBUG_MODE=true
# Function for debug messages
debug_echo() {
if [ "$DEBUG_MODE" = true ]; then
echo "DEBUG: $@"
fi
}
# --- Configuration ---
declare -A PAGE_URLS
PAGE_URLS=(
["N1"]="https://n1nova.live/n1-uzivo.html"
["Nova"]="https://n1nova.live/novas-uzivo.html"
)
# --- Function to extract stream URL from a given page ---
# This function should ONLY echo the extracted stream URL if found.
extract_stream_url() {
local page_url="$1"
local stream_url=""
local html_content=""
# Fetch content without printing debug messages here
html_content=$(curl -s -L "$page_url")
# --- Attempt to extract the stream URL ---
# More specific grep patterns for N1 and Nova, capturing the full URL.
stream_url=$(echo "$html_content" | grep -oP 'https?://best-str\.umn\.cdn\.united\.cloud/stream\?stream=sp1400&sp=n1info&channel=n1srp&u=n1info&p=n1Sh4redSecre7iNf0&player=m3u8[^"]*')
if [ -z "$stream_url" ]; then
stream_url=$(echo "$html_content" | grep -oP 'https?://best-str\.umn\.cdn\.united\.cloud/stream\?stream=hp7000&sp=novas&channel=novashd&u=novas&p=n0v43!23t001&player=m3u8[^"]*')
fi
# Fallback: General m3u8 pattern (less reliable)
if [ -z "$stream_url" ]; then
stream_url=$(echo "$html_content" | grep -oP 'https?://[^"]+\.m3u8[^"]*')
fi
# Clean up any trailing quotes or problematic characters from the extracted URL.
stream_url=$(echo "$stream_url" | sed 's/"$//' | sed "s/'$//")
# Only echo the final, cleaned stream URL.
echo "$stream_url"
}
# --- Function to find VLC executable ---
find_vlc_executable() {
debug_echo "Starting find_vlc_executable..."
local flatpak_app_id="org.videolan.VLC"
local vlc_executable_cmd=""
# 1. Check for native installation (in PATH)
if command -v vlc &> /dev/null; then
local native_path=$(command -v vlc)
debug_echo "Native VLC found at: $native_path"
echo "$native_path"
return 0 # Success
fi
debug_echo "Native VLC not found in PATH."
# 2. Check for Flatpak installation
if command -v flatpak &> /dev/null; then
debug_echo "Flatpak command found."
# Construct the Flatpak command prefix based on typical structure and your .desktop file hint.
vlc_executable_cmd="/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=/app/bin/vlc $flatpak_app_id --"
debug_echo "Constructed potential Flatpak command prefix: $vlc_executable_cmd"
echo "$vlc_executable_cmd"
return 0 # Assume success if flatpak command exists and structure is plausible.
else
debug_echo "Flatpak command not found."
fi
debug_echo "VLC not found via native or Flatpak methods."
echo "Error: VLC not found (neither native nor Flatpak)."
return 1 # Failure
}
# --- Main Script Logic ---
debug_echo "Script starting..."
# --- Dependency Checks ---
if ! command -v curl &> /dev/null || ! command -v grep &> /dev/null || ! command -v sed &> /dev/null; then
echo "Error: Required command(s) (curl, grep, sed) not found. Please install them."
exit 1
fi
debug_echo "Dependencies (curl, grep, sed) found."
# --- Find VLC ---
VLC_EXEC_CMD=$(find_vlc_executable)
exit_code=$?
if [ $exit_code -ne 0 ]; then
debug_echo "find_vlc_executable failed with exit code $exit_code. Exiting."
exit 1
fi
debug_echo "VLC command prefix determined: '$VLC_EXEC_CMD'"
# --- Determine Channel Choice from Argument ---
channel_choice_num="$1"
debug_echo "Channel choice provided as argument: '$channel_choice_num'"
# Trim whitespace from argument
channel_choice_num=$(echo "$channel_choice_num" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if ! [[ "$channel_choice_num" =~ ^[0-9]+$ ]]; then
echo "Invalid input. Please provide a number (1 for N1, 2 for Nova) as an argument."
debug_echo "Exiting due to invalid numeric argument."
exit 1
fi
# --- Prepare Channel List and Validate Choice ---
channel_list=()
for key in "${!PAGE_URLS[@]}"; do
channel_list+=("$key")
done
IFS=$'\n' sorted_channels=($(sort <<<"${channel_list[*]}"))
unset IFS
channel_index=$((channel_choice_num - 1))
if [ "$channel_index" -lt 0 ] || [ "$channel_index" -ge "${#sorted_channels[@]}" ]; then
echo "Invalid choice. Please select a valid number (1 or 2)."
debug_echo "Exiting due to out-of-bounds choice index."
exit 1
fi
SELECTED_CHANNEL_NAME="${sorted_channels[$channel_index]}"
SELECTED_PAGE_URL="${PAGE_URLS[$SELECTED_CHANNEL_NAME]}"
debug_echo "Selected channel name: '$SELECTED_CHANNEL_NAME', Page URL: '$SELECTED_PAGE_URL'"
# --- Extract the stream URL ---
STREAM_URL=$(extract_stream_url "$SELECTED_PAGE_URL")
debug_echo "STREAM_URL captured from function output: '$STREAM_URL'"
# --- Check if we found a URL ---
if [ -z "$STREAM_URL" ]; then
echo "Could not automatically extract a stream URL for '$SELECTED_CHANNEL_NAME'."
echo "The website structure might have changed, or the stream is unavailable."
debug_echo "Exiting because STREAM_URL is empty."
exit 1
fi
# --- Execute VLC ---
echo "Attempting to play stream for $SELECTED_CHANNEL_NAME..."
CMD_STRING="$VLC_EXEC_CMD \"$STREAM_URL\""
debug_echo "Final command string to eval: '$CMD_STRING'"
if eval "$CMD_STRING"; then
echo "VLC command executed successfully."
debug_echo "Script finished successfully."
else
echo "Error executing VLC command. Check VLC player for details."
debug_echo "Script finished with execution error."
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment