Skip to content

Instantly share code, notes, and snippets.

@vinodnimbalkar
Last active March 2, 2022 14:55
Show Gist options
  • Save vinodnimbalkar/3ad175badbd8f9141e476493dec5fe61 to your computer and use it in GitHub Desktop.
Save vinodnimbalkar/3ad175badbd8f9141e476493dec5fe61 to your computer and use it in GitHub Desktop.
Play live channel with help of curl, rofi and mpv (mxplayer)
#!/bin/bash
BASE_URL='https://www.mxplayer.in'
# GET LIST OF LINKS
links=$(curl -s https://www.mxplayer.in/browse/live-tv | grep -Eoi '<a [^>]+>' |
grep -Eo 'href="[^\"]+"' | grep -Eoi '\/live-tv\/.*' | grep -v '\-live-channels"$' | sed 's/\"//g')
# SELECT CHANNEL USING ROFI
link=$(echo ${links} | sed -e 's/\s/\n/g' | sed "s|^|$BASE_URL|g" | rofi -dmenu "live channel : ")
# GET M3U8 LINK
play=$(curl -s ${link} | tr "," "\n" | grep -E '(^\"contentUrl\":\"https:\/\/llvod\.mxplay).*(.m3u8)' | \
awk -F 'com' '{print $2}' | sed 's/\"//g' | | sed 's/^\///g')
# PLAY M3U8 LINK IN MPV
mpv $play
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment