blob: 283d2733f2056906d9d1e67c1a5da12d508e69a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/bash
XSLT_TRACKLIST="`dirname \"$0\"`/tracklist.xsl"
check() {
if ! type ${1} >/dev/null 2>&1; then
echo "missing ${1}${2}"
exit 2
fi
}
check rtmpdump
check xsltproc
check ffmpeg
check vorbiscomment ": see vorbis-tools package"
getplid() {
wget -q -O - "$1" | sed -n -e 'b start; :quit; q; :start; s/.*plid=\([0-9]*\).*/\1/p; t quit'
}
getfriendid() {
wget -q -O - "$1" | sed -n -e 'b start; :quit; q; :start; s/.*friendId=\([0-9]*\).*/\1/p; t quit'
}
eachSong() {
for song in `wget -O - -q "http://musicservices.myspace.com/Modules/MusicServices/Services/MusicPlayerService.ashx?action=getPlaylist&friendId=${2}&playlistId=${1}" | xsltproc "${XSLT_TRACKLIST}" -`; do
songId=`echo $song | cut -d \; -f 1`
albumId=`echo $song | cut -d \; -f 2`
releaseId=`echo $song | cut -d \; -f 3`
title=`echo $song | cut -d \; -f 4`
artist=`echo $song | cut -d \; -f 5`
if [ "xx${songId}" == "xx" ] || [ "xx${albumId}" == "xx" ] || [ "xx${releaseId}" == "xx" ] || [ "xx${title}" == "xx" ]; then
echo "skip: ${song}" >&2
continue
fi
echo "load: ${song}" >&2
if [ "xx${albumId}" == "xx0" ]; then
rtmpUrl=`wget -O - -q \
"http://musicservices.myspace.com/Modules/MusicServices/Services/MusicPlayerService.ashx?releaseId=${releaseId}&sample=0&el=&action=getSong&songId=${songId}&ptype=4" \
| sed -n -e 's/.*<rtmp>rtmp\(.*\)<\/rtmp>.*/rtmpe\1/p'`
else
rtmpUrl=`wget -O - -q \
"http://musicservices.myspace.com/Modules/MusicServices/Services/MusicPlayerService.ashx?albumId=${albumId}&sample=0&el=&action=getSong&songId=${songId}&ptype=4" \
| sed -n -e 's/.*<rtmp>rtmp\(.*\)<\/rtmp>.*/rtmpe\1/p'`
fi
if [ "xx${rtmpUrl}" == "xx" ]; then
echo "could not find rtmpe URL" >&2
else
filename=${title}.ogg
download "${rtmpUrl}" "${filename}"
vorbiscomment -w -t "ARTIST=${artist}" -t "TITLE=${title}" "${filename}"
fi
done
echo done
}
download() {
echo ${1} ${2}
if [ -f "${2}" ]; then
echo "Skip ${2} - file exist"
return
else
echo "load ${2}"
rtmpdump -o - -r "$1" \
| ffmpeg -f flv -i - -acodec libvorbis -ab 192k -ar 44100 -vn "${2}"
fi
}
if [ $# -eq 1 ]; then
plid=`getplid "$1"`
friendId=`getfriendid "$1"`
if [ "xx${plid}" == "xx" ] || [ "xx${friendId}" == "xx" ]; then
echo "no plid/friendid found for $1" >&2
else
echo "load all songs from playlist id=$plid friendId=$friendId" >&2
eachSong "$plid" "$friendId"
fi
else
echo "$0 URL - loads all music files from a myspace profile"
echo "URL in form: http://www.myspace.com/PROFILE"
fi
|