Added media library params to the db generator and subsonic api bench

This commit is contained in:
emeric
2024-02-04 15:01:43 +01:00
parent 9090cc64a9
commit 14d65dc7c2
2 changed files with 37 additions and 8 deletions
+22 -6
View File
@@ -1,7 +1,7 @@
#!/bin/bash
if [ "$#" -ne 6 ]; then
echo "Usage: $0 <base_url> <user> <artist_count> <album_count> <song_count> <batch_size>"
if [ "$#" -lt 6 ] || [ "$#" -gt 7 ]; then
echo "Usage: $0 <base_url> <user> <artist_count> <album_count> <song_count> <batch_size> [musicFolderId]"
exit 1
fi
@@ -19,25 +19,41 @@ album_count="$4"
song_count="$5"
batch_size="$6"
music_folder_id=""
if [ "$#" -eq 7 ]; then
music_folder_id="$7"
fi
append_music_folder() {
local url="$1"
if [ -n "$music_folder_id" ]; then
url="$url&musicFolderId=$music_folder_id"
fi
echo "$url"
}
start_time=$(date +%s.%3N)
# artists
echo "Fetching $artist_count artists..."
for ((i = 0; i < artist_count; i += $batch_size)); do
wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=$batch_size&artistOffset=$i&albumCount=0&songCount=0" > /dev/null
wget -q -O - "$(append_music_folder "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=$batch_size&artistOffset=$i&albumCount=0&songCount=0")" > /dev/null
done
# albums
echo "Fetching $album_count albums..."
for ((i = 0; i < album_count; i += $batch_size)); do
wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=$batch_size&albumOffset=$i&songCount=0" > /dev/null
wget -q -O - "$(append_music_folder "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=$batch_size&albumOffset=$i&songCount=0")" > /dev/null
done
# songs
echo "Fetching $song_count songs..."
for ((i = 0; i < song_count; i += $batch_size)); do
wget -q -O - "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=0&songCount=$batch_size&songOffset=$i" > /dev/null
wget -q -O - "$(append_music_folder "$base_url/rest/search3.view?u=$user&p=$user_password&v=1.13.0&c=benchmark&f=json&query=&artistCount=0&albumCount=0&songCount=$batch_size&songOffset=$i")" > /dev/null
done
end_time=$(date +%s.%3N)
elapsed_time=$(echo "$end_time - $start_time" | bc)
echo "Fetch time: $elapsed_time seconds"
echo "Fetch time: $elapsed_time seconds"