Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # This is just a simple script to fetch the stream url from a program
- #
- # Licence WTPL - Do WTF you want with this, just dont remove this comment
- # Made for freak.no, by Sauu
- #
- function getStream(){
- local URL=$1
- if [[ $URL != *tv.nrk.no* ]]; then
- echo -e "Invalid url. U Must provide a real URL!!"
- exit 1
- fi
- echo -e "\e[01;32mTrying to find stream...\e[00m"
- echo "This is Γber fancy HTML-Parsing in bash!!"
- HTML=`curl $URL`
- # See if program has more than one part
- STREAMS=`echo $HTML | awk '
- /a href="#" class="p-link js-player"/ {
- gsub( ".*data-argument=\"", "" );
- gsub( "\".*", "" );
- print;
- }
- ' RS="[<>]"`
- if [[ -z $STREAMS ]]; then
- # Only one part
- STREAMS=`echo $HTML | awk '
- /div id="playerelement"/ {
- gsub( ".*data-media=\"", "" );
- gsub( "\".*", "" );
- print;
- }
- ' RS="[<>]"`
- # If stream is unable to be found,
- # make the user use "stream"
- if [ -z $STREAMS ]; then
- echo -e "Unable to find the fucking stream..."
- echo "Program not available, or not valid...."
- exit 1
- fi
- PARTS=false
- else
- # Several parts
- PARTS=true
- fi
- for STREAM in $STREAMS ; do
- # Make sure it is HLS, not flash
- # if it is flash, change url to HLS
- if [[ $STREAM == *manifest.f4m ]]; then
- #Replacing char(s)
- STREAM=`echo $STREAM | sed -e 's/z/i/g'`
- STREAM=`echo $STREAM | sed -e 's/manifest.f4m/master.m3u8/g'`
- fi
- # See if the stream is the master playlist
- if [[ "$STREAM" == *master.m3u8 ]]; then
- STREAM=`echo $STREAM | sed -e "s/master.m3u8/index_4_av.m3u8/g"`
- fi
- echo -e "\e[01;32mStream url:\e[00m"
- echo "${STREAM}"
- done
- }
- URL=$1
- getStream $URL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement