Plug-ins for mpd and moc and Lyrics

Source: Internet
Author: User
For mpd and moc plug-ins and lyrics-Linux general technology-Linux technology and application information, the following is a detailed description. [I = s] This post was last edited by im ye Fei

I haven't struggled with the lyrics for a long time. I 've used lrcdis (worship Daniel), but I am unable to search for the lyrics on the Internet. so I can use it for my next revision by google. Of course, it's not as powerful as lrcdis. For mpd, I can use this
CODE :#! /Bin/bash
# Lyric dirLYRIC = $ HOME/. lyrics
# Temp filesSEARCH = $ HOME/. lyrics/tmp
# Notify timeoutTIMEOUT = 1000
# Player StatusSTATUS = $ (mpc status | sed-n '2p' | awk '{print $1}' | sed's/[^ a-zA-Z] // g ')
GetInfo (){
# Song infoSONG = $ (mpc -- format % title % | sed-n '1p' 2>/dev/null) ARTIST = $ (mpc -- format % artist % | sed-n '1p' 2>/dev/null)
NAME = $ (echo $ SONG | sed "s/$ ARTIST //" 2>/dev/null | sed's/\-// G' | sed's /(. *) // G ')

# LRC fileFILE = $ LYRIC/'echo $ NAME | tr-d '''. lrc}
Download () {# search for and Download the lyrics from gougou # gougou will lead to the site used below
GetInfo;
PERIOD = ''[-f" $ SEARCH "] & rm-f $ SEARCH
# "Song name Singer" Search pipeline writing reference lrcdis script wget-c-T 10 "http://www.lrc123.com /? Keyword = $ NAME $ ARTIST & "-O $ SEARCH>/dev/null 2> & 1 | iconv-f GBK
URL = 'cat $ SEARCH | grep-B1 'download' | grep color | sed-n '1p' | sed's/<[^>] *> // G' | tr-d ''| sed's/\ r //''
# If [-z "$ URL"]; then wget-c-T 10 "http://www.lrc123.com /? Keyword = $ NAME & "-O $ SEARCH>/dev/null 2> & 1 | iconv-f GBK fi URL = 'cat $ SEARCH | grep-B1 'Download' | grep color | sed-n '1p' | sed's/<[^>] *> // G' | tr-d' | sed's/\ r //''
If [-z "$ URL"]; then # echo "LRC not found cannot be found in both methods! "# & Exit 1SONG_PREV = $ (mpc -- format % title % | sed-n '1p') Wait;
Else # if there is a search result, download the lyrics FILE wget-c-T 10 $ URL-O "$ FILE">/dev/null 2> & 1 | iconv-f GBK fi
}
Wait () {# For a track that cannot Download the lyrics, read the player information again every one second. Once you switch to the next one, try again to Download the lyrics while: do sleep 1 # SONG = $ (mpc -- format % title % | sed-n '1p') GetInfo if ["$ SONG_PREV "! = "$ SONG"]; then SONG_PREV = $ SONG [-f "$ FILE"] | Download; ShowLyric; fidone}
# GetSecond () {# obtain the number of seconds in the format of 4: 24 # min = 'echo "$1" | cut-d ': '-f1' # sec = 'echo "$1" | cut-d ': '-f2' # res = 'echo "$ min * 60 + $ sec" | bc '#}

ShowLyric () {# [-f "$ FILE"] | Download; # eval "$ CMD" "\ n $ NAME-$ ARTIST \ n" echo-e "\ n $ NAME-$ ARTIST \ n" # Choose y-send "$ NAME-$ ARTIST "while: do if [! "'File $ file | grep-I UTF-8 '"]; then iconv-f GBK-t UTF-8 $ FILE-o $ FILE fi TIME = 'nmstatus | grep'/'| awk-F'/''{print $2}' | awk '{print $2} ''TEXT =' [-f" $ FILE "] & cat" $ FILE "| grep $ TIME | sed's/\ [[^] *] // G' | sed's/\ r // ''current = 'nm' if [-z "$ PREV"-o "$ CURRENT" = "$ PREV"]; then PREV = $ CURRENT
# Change to the next lyrics if [-n "$ TEXT"-a "$ TEXT "! = "$ TEXT_PREV"]; then # There is a problem with the Notify method, and it is too slow to update the lyrics, even if the specified timeout problem is still # Running y-send-t $ TIMEOUT -- "$ TEXT" # echo $ TEXT sleep 0.8 eval "$ CMD" TEXT_PREV = "$ TEXT" fi # Song Switching else PREV = ''getinfo # eval "$ CMD" "\ n $ NAME-$ ARTIST \ n" # echo-e "\ n $ NAME-$ ARTIST \ n" # Policy -send "$ NAME-$ ARTIST"
[-F "$ FILE"] | Download; continue fi sleep 0.3 done}
Case $1 in-n) CMD = 'your y-send-t $ TIMEOUT -- $ text'; *) CMD = 'echo $ text'; esac
While: docase $ STATUS in playing) GetInfo [-f "$ FILE"] | Download; ShowLyric; *) echo "MPD not running! "& Exit 1; esacdone
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.