Skip to content

Instantly share code, notes, and snippets.

@joepie91
Last active May 16, 2024 14:53
Show Gist options
  • Save joepie91/08df1ccf3adb00dbce7c to your computer and use it in GitHub Desktop.
Save joepie91/08df1ccf3adb00dbce7c to your computer and use it in GitHub Desktop.
Playing a DI.fm channel in VLC Media Player
VLC_BIN=`which vlc`
CHANNEL="/di_trance_aac"
curl "http://pub5.di.fm$CHANNEL" \
-H 'Accept: */*' \
-H 'Connection: keep-alive' \
-H 'Referer: http://www.di.fm/' \
-H 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' \ -H 'Accept-Language: en-US,en;q=0.8' \
--compressed | $VLC_BIN -
@d0whc3r
Copy link

d0whc3r commented Sep 2, 2016

Here is a modded version

#!/bin/bash
VLC_BIN=`which cvlc`
CHANNEL="/di_djmixes_aacplus"
if [ "$1" ]; then
  CHANNEL="$1"
fi
if [ "$2" ]; then
  VLC_BIN=`which $2`
  shift
  shift
  options=$@
  if [ -z "$options" ]; then
    options="-"
  fi
  VLC_BIN="$VLC_BIN $options"
else
  VLC_BIN="$VLC_BIN -"
fi

curl "http://pub5.di.fm$CHANNEL" \
    -H 'Accept: */*' \
    -H 'Connection: keep-alive' \
    -H 'Referer: http://www.di.fm/' \
    -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' \
    -H 'Accept-Language: en-US,en;q=0.8' \
    --compressed | $VLC_BIN

Now you could use as: di.sh </channel_name> <your_player options_for_your_player> (the player must accept stdin input)

@AdrianTP
Copy link

On Mac, cvlc does not exist, so vlc is the only option.

I also tweaked it so I only have to type the name of the channel as I would in the browser.

#!/bin/bash
VLC_BIN=`which vlc`
CHANNEL="/di_djmixes_aacplus"
if [ "$1" ]; then
  CHANNEL="/di_$1_aacplus"
fi
# Identical from here on

Now to figure out how to display the current song in VLC like the old days.

@jimdi
Copy link

jimdi commented Apr 11, 2018

not work anymore =(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment