My omnium-gatherom of scripts and source code.
at main 56 lines 2.3 kB view raw
1#!/usr/bin/env bash 2#Script to download or make a list of every map on an osu! install 3IDGEN=true 4OSUDL=true 5IDFILE=songids.txt 6 7help_text(){ while IFS= read -r line; do 8 printf "%s\n" "$line" 9 done <<-EOF 10 Usage: osudl [OPTION]... [path/to/osu!/directory] 11 12 Downloads all of the beatmaps in your current osu! folder. 13 Consequently, can also be used to create a text file with all the beatmap id's in your /Songs folder, and/or be used to download all of the beatmap id's in a specified text file. 14 15 -h, --help show this help text 16 -g, --generate FILENAME generate beatmap id's text file 17 The default beatmap id's text file is named songids.txt and it is created into your /Songs folder. If you wish to create a file with a different name, specify the name here. 18 -d, --download [path/to/beatmap-id-file] download beatmaps from the beatmap id's text file (the default is located in your /Songs folder and that is where the program will look for the text file) 19 If you changed the beatmap id's filename then specify the new name. 20 -T, --test test if everything is working correctly; will only download the first beatmap id in the beatmap id's text file 21EOF 22} 23 24while [ "$1" != "" ];do 25 case $1 in 26 -h | --help)help_text;exit 0;; 27 -g)unset OSUDL;shift;; 28 --generate)shift;unset OSUDL;IDFILE=$1;shift;; 29 -d)unset IDGEN;shift;; 30 --download)shift;unset IDGEN;IDPATH=$1;shift;; 31 *)break;; 32 esac 33done 34 35[ "$1" ]&&DLPATH=$1||echo "Usage : supply a valid path to your osu! directory. Use -h or --help for more information" 36[ ! "$IDPATH" ]&&IDPATH=$DLPATH/$IDFILE 37 38id_gen(){ [ -d "$DLPATH" ]&&[ ! -s "$IDPATH" ]&&file_parse|awk '{FS="/"} {print $NF}'|grep -o '[0-9]\+'|awk '!a[$0]++'|sed '/^.\{7\}..*/d' > "$IDPATH" 39} 40 41file_parse(){ for file in "$DLPATH"/*;do 42 echo "$file" 43done 44} 45 46 47osudl(){ for i in $(cat "$IDPATH");do 48 DLLINK=$(curl -sI https://api.chimu.moe/v1/download/"${i}"?n=1|awk 'FNR == 3 {print $2}'|tr -d '\r"') 49 BEATMAPNAME=$(echo "$DLLINK" | cut -d= -f 2 - | sed 's/%20/\ /g') 50 curl "$(echo -E "$DLLINK")" > "$BEATMAPNAME" 51done 52} 53 54[ ! "$OSUDL" ]&&id_gen 55[ ! "$IDGEN" ]&&osudl 56[ "$OSUDL" ]&&[ "$IDGEN" ]&&id_gen osudl