Ero sivun ”Koodilistaus:Jamoget” versioiden välillä
v. ke 13.5.2009 11:11:02 +0300 |
v. ke 13.5.2009 12:55:14 +0300 |
||
| Rivi 13: | Rivi 13: | ||
{{#fileanchor: jamoget}}<pre>#!/bin/bash | {{#fileanchor: jamoget}}<pre>#!/bin/bash | ||
# Jamoget ke 13.5.2009 11:11:02 +0300 | # Jamoget ke 13.5.2009 12:55:14 +0300 | ||
# | |||
# Changes since ke 13.5.2009 11:11:02 +0300 | |||
# - download and torrent file target directories now configurable through variables | |||
# | # | ||
# Changes since ke 13.5.2009 10:30:00 +0300: | # Changes since ke 13.5.2009 10:30:00 +0300: | ||
| Rivi 25: | Rivi 28: | ||
# It will then also grab the .torrent file, unzip the album and move the .torrent to your client's watch directory. | # It will then also grab the .torrent file, unzip the album and move the .torrent to your client's watch directory. | ||
# Put the IDs of all the albums you want into a file called idlist, one id per line. | # Put the IDs of all the albums you want into a file called idlist, one id per line. | ||
# CONFIGURATION | |||
downloadtarget=/home/jani/Työpöytä/Arkisto/Vapaat/Musiikki/Jamendo | |||
torrentfiletarget=/home/jani/Työpöytä | |||
# END CONFIGURATION | |||
limit= | limit= | ||
| Rivi 63: | Rivi 74: | ||
while read zipfile ; do | while read zipfile ; do | ||
echo "INFO: Unzipping to torrents directory and moving ZIP to extracted directory, .torrent to watch directory" | echo "INFO: Unzipping to torrents directory and moving ZIP to extracted directory, .torrent to watch directory" | ||
unzip -q -n "${zipfile}" -d "/ | unzip -q -n "${zipfile}" -d "${downloadtarget%/}/${zipfile%.zip}" && mv "${zipfile}" extracted/ && mv ${albumid}.torrent "${torrentfiletarget%/}/" | ||
done < ziplistfile | done < ziplistfile | ||
rm ziplistfile | rm ziplistfile | ||
Versio 13. toukokuuta 2009 kello 09.57
<metadesc content="Bash-komentojono, joka lataa Jamendosta albumin Ogg Vorbis -muodossa ja panee sen sitten jakoon." />
Lataa tiedostona: [{{#file: jamoget}} jamoget]
Tämä Bash-komentojono lataa sille parametreina tai tiedostossa (nykyisessä hakemistossa oleva idlist-niminen tiedosto) listatut albumit Jamendosta Ogg Vorbis -muotoisina, ja pudottaa ne sen jälkeen Bittorrent-asiakasohjelman jakoon. Albumit tulee antaa pelkästään niiden tunnusnumeroilla, esimerkiksi näin:
jamoget 42673 43733
Mikäli albumit luetellaan tiedostossa, ne tulee erotella toisistaan rivinvaihdoilla.
Komentojonon käyttöönotto vaatii melko varmasti mukailua hakemistoviittausten osalta.
Tämä on oma muunnelmani Jamendon foorumilta löytyneestä alkuperäisteoksesta, jonka on luonut The Chilling Spirit. Alkuperäisen lisenssi on tuntematon, todennäköisesti kuitenkin vapaa.
{{#fileanchor: jamoget}}
#!/bin/bash
# Jamoget ke 13.5.2009 12:55:14 +0300
#
# Changes since ke 13.5.2009 11:11:02 +0300
# - download and torrent file target directories now configurable through variables
#
# Changes since ke 13.5.2009 10:30:00 +0300:
# - mentioning of limit-rate in usage
#
# Changes since ke 13.5.2009 10:20:04 +0300:
# - implements limit-rate for wget
#
# This will download album ZIP files from Jamendo directly. By default it gets Ogg Vorbis,
# remove the last parameter from the wget lines to get MP3
# It will then also grab the .torrent file, unzip the album and move the .torrent to your client's watch directory.
# Put the IDs of all the albums you want into a file called idlist, one id per line.
# CONFIGURATION
downloadtarget=/home/jani/Työpöytä/Arkisto/Vapaat/Musiikki/Jamendo
torrentfiletarget=/home/jani/Työpöytä
# END CONFIGURATION
limit=
if [[ "$1" == "--limit" || "$1" == "--limit-rate" ]]
then
shift
limit=--limit-rate=$1
shift
fi
idlist=`mktemp -t`
if [ -e idlist ]
then
cp idlist $idlist
else
if [ $# -lt 1 ]
then
echo "usage: `basename ${0}` [--limit-rate amount] id..."
exit 1
fi
for id in $@ ; do
echo $id >> $idlist
done
fi
while read albumid ; do
mkdir -p "/tmp/jamoget-${albumid}/extracted" "/tmp/jamoget-${albumid}/errorsonunzip" || { echo "ERROR: Creating temporary output directories."; exit; }
pushd "/tmp/jamoget-${albumid}"
echo "INFO: Downloading Ogg Vorbis album ZIP"
wget $limit --continue "http://www.jamendo.com/get/album/id/album/archiverestricted/redirect/${albumid}/?p2pnet=bittorrent&are=ogg3"
echo "INFO: Downloading torrent for Ogg Vorbis album"
wget -nv --continue -O ${albumid}.torrent "http://api.jamendo.com/get2/bittorrent/file/redirect/?album_id=${albumid}&type=archive&class=ogg3"
echo "INFO: Unzipping"
find . -maxdepth 1 -name "*.zip" > ziplistfile
while read zipfile ; do
echo "INFO: Unzipping to torrents directory and moving ZIP to extracted directory, .torrent to watch directory"
unzip -q -n "${zipfile}" -d "${downloadtarget%/}/${zipfile%.zip}" && mv "${zipfile}" extracted/ && mv ${albumid}.torrent "${torrentfiletarget%/}/"
done < ziplistfile
rm ziplistfile
mv *.zip errorsonunzip/ > /dev/null 2>&1
mv *.torrent errorsonunzip/ > /dev/null 2>&1
if [ "$(ls -A errorsonunzip/)" ]; then
echo "ERROR: While unzipping. Downloaded files saved in /tmp/jamoget-${albumid}/errorsonunzip/."
else
cd /tmp && rm -rf "jamoget-${albumid}"
fi
popd > /dev/null 2>&1
done < $idlist
rm $idlist
echo "INFO: Script finished"