Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/awk -f
- # Running examples (simple.awk is name of this script):
- #
- # ./simple.awk sample.txt
- # ./simple.awk -v debug=1 sample.txt
- # ./simple.awk -v path='~/Media/' sample.txt
- # ./simple.awk -v debug=1 -v path='~/Media/' sample.txt
- BEGIN {
- LDEBUG="";
- LPATH="";
- if(length(path)>0){
- LPATH=path;
- }
- if(length(debug)>0){
- LDEBUG=debug;
- }
- extinf="";
- }
- /^#EXTINF:[0-9]+,.+$/{
- gsub(/[ \t\n\r]+$/,""); # remove trailing non-printable chars from $0
- match($0,/^#EXTINF:([0-9]+),(.+)[[:space:]]*$/,ar);
- gsub(/"/,"\\\"",ar[2]); # adding backslash to double quotes if found in song name
- extinf = "\"" ar[1] "." ar[2] ".mp3\"";
- if(LPATH) extinf = LPATH extinf;
- if(LDEBUG) print extinf;
- }
- /^http:\/\/.+\.mp3[\ \n\r\t]*$/{
- if(extinf){
- gsub(/[ \t\n\r]+$/,""); # remove trailing non-printable chars from $0
- cmd="wget -O "extinf" '"$0"'";
- if(LDEBUG) print cmd;
- else system(cmd);
- extinf="";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement