chore: Init
This commit is contained in:
commit
b604662f7b
|
@ -0,0 +1,24 @@
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <https://unlicense.org>
|
|
@ -0,0 +1,18 @@
|
||||||
|
# funkblubber
|
||||||
|
|
||||||
|
A simple CLI for Funkwhale
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
- [jq](https://stedolan.github.io/jq/) package for curl json parsing.
|
||||||
|
- [curl](https://curl.se/) package for transferring data with URLs.
|
||||||
|
|
||||||
|
### How To
|
||||||
|
|
||||||
|
```
|
||||||
|
./funkblubber [full artist url|full album url]
|
||||||
|
```
|
||||||
|
|
||||||
|
For example:
|
||||||
|
```
|
||||||
|
./funkblubber https://whale.domain/library/albums/2165/
|
||||||
|
```
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
errecho()
|
||||||
|
{
|
||||||
|
echo -e "\e[0;31m${1}\e[0m" 1>&2
|
||||||
|
}
|
||||||
|
|
||||||
|
for dep in jq curl
|
||||||
|
do
|
||||||
|
if [ -z $(which $dep) ]
|
||||||
|
then
|
||||||
|
errecho "Missing $dep package, please install"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z ${1} ]
|
||||||
|
then
|
||||||
|
errecho "Provide a URL"
|
||||||
|
errecho "'$0 --help' for more"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
domain=$(echo "$1" | cut -f 3 -d '/')
|
||||||
|
echo "So your domain is $domain..."
|
||||||
|
|
||||||
|
album_flag="albums"
|
||||||
|
artist_flag="artists"
|
||||||
|
look_for_id_of=""
|
||||||
|
IFS='/' read -ra chunks <<< "$1"
|
||||||
|
for chunk in "${chunks[@]}"
|
||||||
|
do
|
||||||
|
case $chunk in
|
||||||
|
$album_flag)
|
||||||
|
echo "Found out it's an album..."
|
||||||
|
look_for_id_of=$album_flag
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
|
||||||
|
$artist_flag)
|
||||||
|
echo -n "Found out it's an artist..."
|
||||||
|
look_for_id_of=$artist_flag
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $look_for_id_of in
|
||||||
|
$album_flag)
|
||||||
|
echo "And its ID is ${chunk}..."
|
||||||
|
response=$(curl -X GET "https://${domain}/api/v1/tracks/?album=${chunk}&ordering=creation_date&page=1&page_size=16&scope=all" -H "accept: application/json" | jq .)
|
||||||
|
echo "${response}" | jq '.results' | jq -c '.[]' | while read song
|
||||||
|
do
|
||||||
|
echo "${song}" | jq '.uploads' | jq -c '.[]' | while read upload
|
||||||
|
do
|
||||||
|
extension=$(echo ${upload} | jq -r '.extension')
|
||||||
|
folder=$(echo ${song} | jq -r '.album.title' | sed 's#/#_#g')
|
||||||
|
mkdir -p "${folder}"
|
||||||
|
title=$(echo ${song} | jq -r '.title' | sed 's#/#_#g')
|
||||||
|
listen_url=$(echo ${song} | jq -r '.listen_url')
|
||||||
|
echo "Downloading '${title}'..."
|
||||||
|
curl -X GET "https://${domain}${listen_url}" -H "accept: */*" -o "${folder}/${title}.${extension}"
|
||||||
|
break
|
||||||
|
done
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
$artist_flag)
|
||||||
|
echo -n "And its ID is ${chunk}..."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
errecho "Invalid URL"
|
||||||
|
errecho "Should be either https://<domain>/library/albums/<ID>/ or https://<domain>/library/artists/<ID>/"
|
||||||
|
errecho "'$0 --help' for more"
|
Loading…
Reference in New Issue