Vlákno názorů k článku Ripování hudby z internetových rádií od mln - Asi pred mesicem jsem resil presne ten samy...

  • Článek je starý, nové názory již nelze přidávat.
  • 1. 3. 2012 22:04

    mln (neregistrovaný)

    Asi pred mesicem jsem resil presne ten samy problem jako autor clanku. Nabizim alternativni skript pro ty, ktere (tak jako mne) nebavi hrabat se v cronu:

    #!/bin/sh
    # The next line restarts with tclsh.\
    exec tclsh "$0" ${1+"$@"}

    # station definitions
    set station(praha) {http://icecas­t5.play.cz:8000/cro2-128.mp3}
    set station(vltava) {http://icecas­t5.play.cz:8000/cro3-128.mp3}
    set station(wave) {http://icecas­t5.play.cz:8000/cro­wave-128.mp3}
    set station(radio1) {http://netshow­.play.cz:8000/ra­dio1.mp3}
    set station(humor) {http://mp3st­ream4.abradio­.cz:8000/humor128­.mp3}

    set destination {~/Downloads/}
    set downloadProgram {/usr/bin/stre­amripper}
    set tmpfile {/tmp/.atjob}

    # input parameters
    if { $argc != 3 } {
    puts "The radio.tcl script requires the following input parameters:"
    puts " - radio station: \[ [array names station] \]"
    puts " - start time: \[ examples: Mon12:30 or 18:45 \]"
    puts " - duration: \[ example: 0:30 \]"
    puts "Example: radio.tcl praha Mon20:00 1:30"
    exit
    } else {
    set inpStation [lindex $argv 0]
    set inpStartTime [lindex $argv 1]
    set inpDuration [lindex $argv 2]
    }

    # create atjob file
    if { [catch {open $tmpfile w} atJobfileId] } {
    puts "Could not open $tmpfile for writing\n"
    exit
    }

    # create destination directory
    if [file isdirectory $destination] {
    puts "INFO: Directory $destination already exists"
    } else {
    file mkdir $destination
    puts "INFO: Creating directory $destination"
    }

    # get current date
    set currDay [clock format [clock seconds] -format %a]
    # calculate start time
    if [regexp {^(Mon|Tue|Wed|Thu|Fr­i|Sat|Sun)*([0-2]*[0-9]):([0-5][0-9])$} $inpStartTime {} dStart hStart mStart] {
    puts "INFO: Start time: $dStart ${hStart}:${mStar­t}"
    } else {
    puts "ERROR: Start time format not recognized ( $inpStartTime )"
    exit
    }

    # calculate length
    if [regexp {^([0-3]*[0-9]):([0-5][0-9])$} $inpDuration {} h m] {
    puts "INFO: Duration: ${h}:${m} "
    set length [expr ($m + ($h * 60)) * 60]
    puts "INFO: Duration: ${length} \[seconds\]"
    } else {
    puts "ERROR: Duration format not recognized ( $inpDuration )"
    exit
    }

    # main loop
    foreach i [array names station] {
    if {$i == $inpStation} {
    puts "INFO: Found station $i ( $station($i) )"
    puts "INFO: writing $downloadProgram $station($i) -d $destination -D %d_%S -l $length to $tmpfile"
    puts $atJobfileId "$downloadProgram $station($i) -d $destination -D %d_%S -l $length"
    puts "INFO: running: at ${hStart}:${mStart} $dStart < $tmpfile"
    close $atJobfileId
    puts "INFO: closing ${destination}/at­job"
    set runcmd [list exec at "${hStart}:${mStar­t}" $dStart \< "$tmpfile"]
    if {[catch $runcmd res]} {
    puts "INFO: $runcmd: $res"
    }
    exit
    }
    }
    puts "ERROR: Station name not recognized ( $inpStation )"

  • 2. 3. 2012 9:14

    bez přezdívky

    Zdravím, moc pěkný skriptík, je vidět, že si skriptování užíváte.Líbí se mi, jak jste vyřešil seznam oblíbených rádií a spouštění přes parametr. Řeší ale spuštění 1x v určený čas - to je dobré pro nahrání určitého pořadu a je samozřejmě zbytečné to dávat do CRONU. Já si pravidelným spouštěním naplňuji archiv o nové skladby pro offline poslech. Děkuji za inspiraci.