All pastes #2052862 Raw Edit

Miscellany

public text v1 · immutable
#2052862 ·published 2011-05-02 14:07 UTC
rendered paste body
alias F2 {
  echo Announcing to $active
  /set %artist NA
  /set %album NA
  /set %title NA
  /set %genre NA
  /set %date NA
  /set %codec NA
  /set %language NA
  /set %type NA
  /set %channels NA
  /set %sampleRate NA
  /set %bitrate NA
  /set %filename NA
  /set %precent NA
  /set %trackNr NA
  /set %encoder NA
  /set %copyright NA
  /set %originalArtist NA
  /set %composer NA
  /set %duration NA
  /set %elapsedH NA
  /set %elapsedM NA
  /set %elapsedS NA

  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
  socketclose vlc_meta_info
}
on *:SOCKREAD:vlc_meta_info: {
  if ( $sockerr > 0 ) { return }

  :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: isin %temp ) { %artist = $remove( %temp,Artist: ) }
  if ( Album/movie/show title: isin %temp ) { %album = $remove( %temp,Album/movie/show title: ) }
  if ( Title: isincs %temp ) { %title = $remove( %temp,Title: ) }
  if ( ID TAG GENRE: isin %temp ) { %genre = $remove( %temp,ID TAG GENRE: ) }

  if ( Date: isin %temp ) { /set %date $remove( %temp,Date: ) }
  if ( Codec: isin %temp ) { /set %codec $remove( %temp,Codec: ) }
  if ( Language: isin %temp ) { /set %language $remove( %temp,Language: ) }
  if ( Type: isin %temp ) { /set %type $remove( %temp,Type: ) }
  if ( Channels: isin %temp ) { /set %channels $remove( %temp,Channels: ) }
  if ( Sample rate: isin %temp ) { /set %sampleRate $remove( %temp,Sample rate: ) }
  if ( Bitrate: isin %temp ) { /set %bitrate $remove( %temp,Bitrate: ) }
  if ( Track number/position in set: isin %temp ) { /set %trackNr $remove( %temp,Track number/position in set:) }
  if ( Encoded by: isin %temp ) { /set %encoder $remove( %temp,Encoded by:) }
  if ( Copyright: isin %temp ) { /set %copyright $remove( %temp,Copyright:) }
  if ( Original artist(s)/performer(s): isin %temp ) { /set %originalArtist $remove( %temp,Original artist(s)/performer(s):) }
  if ( Composer: isin %temp ) { /set %composer $remove( %temp,Composer:) }
  if ( Duration: isin %temp ) { /set %duration $remove( %temp,Duration:) }
  if ( Now Playing: isin %temp ) { /set %nowPlaying $remove( %temp,Now playing:) }

  if ( PLAYLIST FILENAME: isin %temp ) { /set %fullPath $remove( %temp,PLAYLIST FILENAME: )
    if ( :// isin %fullPath ) { /set %type %type $+ Stream }
    /set %filename $nopath( %fullPath )
  }
  if ( ELAPSED HOURS: isin %temp) { /set %elapsedH $remove( %temp,ELAPSED HOURS: ) }
  if ( ELAPSED MINUTES: isin %temp) { /set %elapsedM $remove( %temp,ELAPSED MINUTES: ) }
  if ( ELAPSED SECONDS: isin %temp) { /set %elapsedS $remove( %temp,ELAPSED SECONDS: ) }

  if ( SECONDS ELAPSED: isin %temp) { /set %secondsElapsed $remove( %temp,SECONDS ELAPSED: ) }
  if ( SECONDS TOTAL: isin %temp) { /set %secondsTotal $remove( %temp,SECONDS TOTAL: ) }
  /set %percent $calc( %secondsElapsed / %secondsTotal * 100 )

  if ( %artist == $null ) { /set %artist NA }
  if ( %album == $null ) { /set %album NA }
  if ( %title == $null ) { /set %title NA }
  if ( %genre == $null ) { /set %genre NA }
  if ( %date == $null ) { /set %date NA }
  if ( %codec == $null ) { /set %codec NA }
  if ( %language == $null ) { /set %language NA }
  if ( %type == $null ) { /set %type NA }
  if ( %channels == $null ) { /set %channels NA }
  if ( %sampleRate == $null ) { /set %sampleRate NA }
  if ( %bitrate == $null ) { /set %bitrate NA }
  if ( %trackNr == $null ) { /set %trackNr NA }
  if ( %encoder == $null ) { /set %encoder NA }
  if ( %copyright == $null ) { /set %copyright NA }
  if ( %originalArtist == $null ) { /set %originalArtist NA }
  if ( %composer == $null ) { /set %composer NA }
  if ( %duration == $null ) { /set %duration NA }

  if ( %temp == EOF ) {
    /msg $active 4NP:7 %artist - %album - ( $+ %trackNr $+ ) %title 14( $+ %percent $+ % - %elapsedH $+ : $+ %elapsedM $+ : $+ %elapsedS $+ / $+ %duration - %bitrate - %codec - %filename $+ )
    goto close
    # The underneeth lines are still under development.. Just wait ;)
    if ( %type == Audio ) {
      /msg $active 4NP:7 %artist - %album - ( $+ %trackNr $+ ) %title 14( $+ %percent $+ % - %elapsedH $+ : $+ %elapsedM $+ : $+ %elapsedS $+ / $+ %duration - %bitrate - %codec - %filename $+ )
      goto close
    }
    if ( %type == Video ) {
      /msg $active 4NP:7 %filename
      goto close
    }
    if ( %type == AudioStream ) {
      /msg $active 4NP:7 %nowPlaying 14( $+ Audio: %title - %filename $+ )
      goto close
    }
    if ( %type == VideoStream ) {
      /msg $active 4NP:7 %nowPlaying 14( $+ Video: %title - %filename $+ )
      goto close
    }
    /msg $active 4NP:7 %filename ( $+ Unknown type $+ )
    goto close
  }

  goto read

  :close

  sockclose vlc_meta_info
}