Compare commits

...

2 Commits

Author SHA1 Message Date
Jeroen De Meerleer f4c71cd38e Fixed playlist sync in parallel 2020-02-16 13:27:14 +01:00
Jeroen De Meerleer ddbca852db Playlists didn't run in parallel 2020-02-16 11:05:39 +01:00
1 changed files with 20 additions and 12 deletions

View File

@ -53,8 +53,8 @@ jobcount=$(expr $(nproc) - 2)
multithread=false
script_name=$(basename "${0}")
script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
listmapping[0]=''
listmapping[1]=''
mappingdest=''
mappingsrc=''
windowspaths=false
playlists=false
@ -237,10 +237,10 @@ GetOptions() {
-m|--mapping)
VerboseOutput 0 "--mapping given"
listmappingparam=(${2//,/ })
listmapping[0]=${listmappingparam[0]:-""}
listmapping[1]=${listmappingparam[1]:-""}
mappingsrc=${listmappingparam[0]:-""}
mappingdest=${listmappingparam[1]:-""}
shift 2
VerboseOutput 1 "Playlist mappings enabled source=${listmapping[0]} dest=${listmapping[1]}"
VerboseOutput 1 "Playlist mappings enabled source=${mappingsrc} dest=${mappingdest}"
;;
--)
shift
@ -346,6 +346,7 @@ Execute() {
VerboseOutput 3 "Running in parallel. Mind your load"
export -f ProcessFile
export -f ConvertFile
export -f ConvertPlaylist
export -f CopyFile
export -f VerboseOutput
export -f ExecTime
@ -357,6 +358,9 @@ Execute() {
export verbose
export coverartsize
export begin
export windowspaths
export mappingsrc
export mappingdest
parallel --jobs ${jobcount} --will-cite --line-buffer --arg-file "/tmp/music-sync-filelist" ProcessFile
else
for line in $(cat "/tmp/music-sync-filelist")
@ -398,19 +402,23 @@ ConvertPlaylist() {
fi;
if [[ -f "$temp/$line" ]]; then
rm $temp/$line
rm "$temp/$line"
fi
search=${listmapping[0]}
replace=${listmapping[1]}
VerboseOutput 0 "Creating playlist $temp/$line"
IFS="
"
for item in $(cat "$source/$line")
do
mp3item=$(echo $item | sed -e 's/\.*\//\//g'| tr -s ' ')
playline=$(echo "${mp3item}" | sed -e "s,$mappingsrc,$mappingdest,g")
echo "${playline}"
echo "search: $mappingsrc"
echo "replace: $mappingdest"
echo $playline
if [[ $windowspaths == true ]]; then
echo "${mp3item/$search/$replace}" | sed -e 's,\/,\\,g' >> $temp/$line
else
echo "${mp3item/$search/$replace}" >> $temp/$line
fi
playline=$(echo "${playline}" | sed -e 's,\/,\\,g')
fi
echo $playline >> $temp/$line
done
if [[ $windowspaths == true ]]; then
VerboseOutput 0 "Converting lf to crlf"