;[[[[[[[[[[[[[[[[[[[[[[[[[[ Now Playing ]]]]]]]]]]]]]]]]]]]]]]]]
alias np_format {
;//np.command // np.chan // player // name // artist // file // stream // duration // album // genre //
return $eval($iif(%np.command && %np.chan,/_describe,echo) %np.chan 3 $+ $chr(44) $+ 1<0 $+ %np.player $+ 3> Now Playing:12 $iif(%artist,%artist -12) $iif(%name,%name,%file) (3 $+ $iif(%stream,%stream,$asctime(%duration,n:ss)) $+ ) $iif(%album || %genre,14»»») %album $iif(%genre,[14 $+ %genre $+ ]),0)
}
alias np {
if ($chan) { /set -u5 %np.command $1- | /set -u5 %np.chan $chan }
/set -u5 %np.player iTunes | /itunes
/set -u5 %np.player MPC | /mpc
/set -u5 %np.player VLC | /vlc
}
alias itunes {
.comopen iitunes iTunes.application
if ($comerr) return
var %dummy = $com(iitunes,PlayerState,3)
if (($comerr) || ($com(iitunes).result != 1)) goto error
%dummy = $com(iitunes,CurrentTrack,3,dispatch* iittrack)
var %data = Artist:Name:Duration:Genre:Album:Comment | ;BitRate:BPM:Compilation:Composer:DateAdded:DiscNumber:KindAsString:PlayedCount:PlayedDate:Playlist:Rating:SampleRate:TrackCount:TrackNumber:Year
while ($numtok(%data,58) > 0) {
%dummy = $com(iittrack,$gettok(%data,1,58),3)
var % [ $+ [ $gettok(%data,1,58) ] ] $com(iittrack).result
echo -s >> $gettok(%data,1,58) == % [ $+ [ $gettok(%data,1,58) ] ]
if ($comerr) goto error
%data = $deltok(%data,1,58)
}
;Get Stream Information
%dummy = $com(iitunes,CurrentStreamTitle,3)
var %stream $regsubex($com(iitunes).result,-[^-]*(http://|www\.)[^ - ]*$,$null)
if (%stream) {
%artist = $gettok(%stream,1,$asc(-))
%name = $gettok(%stream,2-,$asc(-))
%dummy = $com(iitunes,CurrentStreamURL,3)
%stream = $com(iitunes).result
}
$eval($np_format,2)
.comclose iittrack
.comclose iitunes
halt
:error
if (!$com(iitunes)) return
.comclose iitunes
while ($com(0)) .comclose $com(1)
return
}
alias mpc {
;//gtsmirc also has an audio script that would pick up iTunes
var %message $dll(" $+ $scriptdir $+ gtsmirc.dll",GetOpenVideo,_)
if (!%message) return
/echo -s $replace(%message,$chr(1),$+($chr(160),$chr(183),$chr(160)))
/var %file = $regsubex($gettok(%message,3,1),\.mp3$,$null)
/var %duration = $duration($gettok(%message,5,1))
$eval($np_format,2)
halt
}
alias vlc {
sockclose vlc_meta_info
/set -u5 %vlc.chan $chan
/set -u5 %vlc.command $1-
sockopen vlc_meta_info 127.0.0.1 8082
}
on *:SOCKOPEN:vlc_meta_info: {
sockwrite -n $sockname GET /NowPlaying.htm HTTP/1.1
sockwrite -n $sockname Host: localhost
sockwrite -n $sockname $crlf
sockwrite -n $sockname $null
return
:error
reseterror
}
on *:SOCKREAD:vlc_meta_info: {
if ( $sockerr > 0 ) { return }
/var %artist, %name, %duration, %album, %genre, %stream, %file, %temp
:read
sockread %temp
if ($sockbr == 0) return
if (%temp == $null) goto read
if ( Error 404 isin %temp ) {
echo Announce: Error. 404. File not found.
goto close
}
if (Artist:* iswm %temp) %artist = $regsubex(%temp,/^Artist:/i,$null)
else if (Title:* iswm %temp) %name = $regsubex(%temp,/^Title:/i,$null)
else if (Seconds total:* iswm %temp) %duration = $regsubex(%temp,/^Seconds total:/i,$null)
else if (Album/movie/show title:* iswm %temp) %album = $regsubex(%temp,/^Album/movie/show title:/i,$null)
else if ($regex(%temp,Genre:.*)) %genre = $regsubex(%temp,/^Genre:/i,$null)
else if (PLAYLIST FILENAME:http://* iswm %temp) %stream = $regsubex(%temp,/^PLAYLIST FILENAME:/i,$null)
if (PLAYLIST FILENAME:* iswm %temp) %file = $nopath($file($regsubex(%temp,/PLAYLIST FILENAME:/i,$null)).longfn)
if (%temp) echo -s >> %temp
if ( %temp == EOF ) {
$eval($np_format,2)
goto close
}
goto read
:close
sockclose vlc_meta_info
}