silian87 Advocate
Joined: 06 Oct 2003 Posts: 2318 Location: Treviso, Italy
|
Posted: Fri Sep 02, 2005 4:31 pm Post subject: [OT] Utility per beep-media-player |
|
|
Stufo di amarok che mi dava problemi su ppc nonostante tutti i tentativi del mondo, sono tornato a beep-media-player... pero' qualcosa mi mancava... come dcop e il finder delle lyrycs... cosi mi sono messo di buona lenza ed ho fatto uno scriptino un po' porcoso (si, non ho fatto particolare attenzione al codice), che mi da come output quello che sto ascoltando se chiamato da solo, e il testo della canzone se aggiungo come opzione "lyric".
Vediamo due esempi facili facili:
Code: | ./song
A Change Of Seasons - Dream Theater - A Change Of Seasons
|
Ora mostrero' la lyric, presa direttamente dallo stesso sito in cui si fornisce amarok. Ovviamente i tag mp3 (o ogg) dovranno essere perfetti, se no si rischia di ottenere una pagina di suggerimenti.
Code: |
./song lyric
A change of seasons
Dream theater
I. The Crimson Sunrise
(Instrumental)
II. Innocence
I remember a time
My frail, virgin mind
watched the crimson sunrise
Imagined what it might find
Life was filled with wonder
I felt the warm wind blow
I must explore the boundaries
Transcend the depth of winter's snow
Innocence caressing me
...
|
Forse migliorero' un po' il codice ed implementero' qualcosa... se per ora vi sembra utile... (Da notare l'hack lolloso per ottenere il titolo ed il nome della canzone e dell'album ).
Eccolo:
Code: |
#!/bin/bash
PLAYER="beep-media-player"
BROWSER="links"
option=${1}
print()
{
local options=${2}
local text=${1}
echo "${options}" "${text}"
}
lyric()
{
local album=${1}
local author=${2}
local song=${3}
local resource="lyrc.com.ar"
if [ "${resource}" = "lyrc.com.ar" ]; then
local i
for i in ${author}; do
local f_author="${f_author}${i}+"
done
for i in ${song}; do
local f_song="${f_song}${i}+"
done
"${BROWSER}" -dump "http://lyrc.com.ar/en/tema1en.php?artist=${f_author}&songname=${f_song}"
fi
}
# Main
if [ "${PLAYER}" = "amarok" ]; then
album=`dcop amarok player album`
song=`dcop amarok player title`
author=`dcop amarok player artist`
playing="${album} - ${author} - ${song}"
print "${playing}"
if [ "${option}" = "lyric" ]; then
lyric "${album}" "${author}" "${song}"
fi
elif [ "${PLAYER}" = "beep-media-player" ]; then
X1=`xwininfo -children -name "Beep Media Player"`
l=0
for i in ${X1}; do
lol=`echo "${i}" | grep 0x`
if [ ! "${lol}" = "" ]; then
let l++
if [ "${l}" = "4" ]; then
id=${i}; let id++
id=`echo ""$id" "16" o p" | dc`
id="0x${id}"
playing=`xprop -id "${id}" WM_NAME`
playing=`echo "${playing}" | sed -e s/"WM_NAME(STRING) = "/""/`
playing=`echo "${playing}" | sed -e s/" - BMP"/""/`
IFS="-"
set -- ${playing}
b_author=${1}
b_album=${2}
b_song=${3}
IFS=" "
author=`echo ${b_author} | sed -e s/.*\".*[.]/""/`
album=${b_album}
song=`echo ${b_song} | sed -e s/\(.*\)\"/""/`
playing="${album} - ${author} - ${song}"
if [ "${option}" = "lyric" ]; then
lyric "${album}" "${author}" "${song}"
else
print "${playing}"
fi
exit
fi
fi
done
fi
|
//EDIT: Mi eroi dimenticato di dire che va anche con amarok se cambiate la variabile PLAYER a "amarok" , e che BROWSER va sia con "links" che con "lynx".
Inoltre c'e' da segnalare che funziona benissimo con il plugin bangexec per gaim che si trova in portage. _________________ Musica che ascolto: http://www.last.fm/user/silian87/
Silian87 FAQs: http://marentax.homelinux.org/~silian87/silian87-faq.txt
GTalk: silian87@gmail.com |
|