Browse Source

++mpfilter

master
Maxim Likhachev 5 years ago
parent
commit
863a8a18e4
  1. 1
      README.md
  2. 52
      scripts/mpfilter

1
README.md

@ -35,6 +35,7 @@ will create the symbolic link for each script in the \<path> directory.
- [a2mp3](scripts/a2mp3) converts wav audio files to mp3 format. - [a2mp3](scripts/a2mp3) converts wav audio files to mp3 format.
- [axaudio](scripts/axaudio) gets an information and audio stream from Axia Livewire network. - [axaudio](scripts/axaudio) gets an information and audio stream from Axia Livewire network.
- [mpfilter](scripts/mpfilter) removes the rated tracks from current mpd playlist.
- [mptk](scripts/mptk) allows to control mpd via mpc and store song's rating into id3v2 commentary tag. - [mptk](scripts/mptk) allows to control mpd via mpc and store song's rating into id3v2 commentary tag.
- [retag](scripts/retag) writes id3 tags based on file path. - [retag](scripts/retag) writes id3 tags based on file path.
- [radio](scripts/radio) plays the internet radio stations from a list stored in the file. - [radio](scripts/radio) plays the internet radio stations from a list stored in the file.

52
scripts/mpfilter

@ -0,0 +1,52 @@
#!/usr/bin/env tclsh
#Создан: пт 19 июн 2020 15:42:10
#Изменён: Сб 10 окт 2020 18:20:25
# Сценарий удаления треков с указанной оценкой из mpd
proc mpd {args} {
set mpd [socket 127.0.0.1 6600]
foreach command $args {
puts $mpd $command
}
puts $mpd close
flush $mpd
set mpd_answer [split [read $mpd] "\n"]
set mpd_status [lindex $mpd_answer 0]
set answer_code [lindex $mpd_answer 1]
if {[string match "OK MPD *" $mpd_status]} {
if {![string match "ACK*" $answer_code]} {
return [lrange $mpd_answer 1 end-2]
} else {
return [list 1 $answer_code]
}
} else {
return [list 1 $mpd_answer]
}
}
set playlistlength [regsub {^[^:]*:\s+} [lindex [mpd status] 6] {}]
set commented {}
for {set pos 0} {$pos <= $playlistlength} {incr pos} {
array unset song
set info [mpd "playlistinfo $pos"]
foreach metadata $info {
regexp -expanded {^([^:]+):\s+(.*)$} $metadata match key value
set song([string tolower $key]) $value
}
if {[info exists song(comment)] && [regexp {^[1-5]\+?$} $song(comment)]} {
lappend commented $song(id)
}
}
mpd {*}[lmap id $commented {list deleteid $id}]
Loading…
Cancel
Save