summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-08-29 21:33:33 +0200
committerRasmus Steinke <rasi@xssn.at>2015-08-29 21:33:33 +0200
commit6d0afb9f6f37e7980f6dd7ae3d160c7d0d61dba5 (patch)
tree29e5f85930a361570fb51d0de3bef6c7e939c4f6
parentf1f35782e7e6fad4e5629f9538a40a3aa11c4ddc (diff)
downloadperl-app-clerk-6d0afb9f6f37e7980f6dd7ae3d160c7d0d61dba5.tar.gz
perl-app-clerk-6d0afb9f6f37e7980f6dd7ae3d160c7d0d61dba5.tar.xz
first try at aligned input
-rwxr-xr-xclerk97
-rwxr-xr-xclerk_helper8
2 files changed, 48 insertions, 57 deletions
diff --git a/clerk b/clerk
index d0a9679..c41659d 100755
--- a/clerk
+++ b/clerk
@@ -77,8 +77,16 @@ shuf=$([[ "$OSTYPE" == "darwin"* ]] && echo 'gshuf' || echo 'shuf')
tac=$([[ "$OSTYPE" == "darwin"* ]] && echo 'gtac' || echo 'tac')
updateCache() {
- rm -f $HOME/.config/clerk/*.cache
+ cd $HOME/.config/clerk
+ rm -f *.cache
clerk_helper createcache
+ for i in {tracks,albums}.cache; do
+ cat "$i" | column -o $'\t' -s $'\t' -t | sort -n > "${i}.new"
+ mv "${i}.new" "$i"
+ cat latest.cache | column -o $'\t' -s $'\t' -t > latest.cache.new
+ mv latest.cache.new latest.cache
+ done
+
}
# main Menu
@@ -910,18 +918,6 @@ playRandomTracks () {
}
addLastMod() {
- if [[ -z $last_temp ]]; then
- loadCacheLatest > /dev/null
- else
- echo "re-using track list from memory"
-# unset tracks_temp
-# export tracks_temp=${tracks_temp} > /dev/null
- fi
-
-menu="0 Return to Browse Menu
----
-${last_temp}"
-
help_text=$(echo -e "${add}: Add - ${insert}: Insert - ${replace}: Replace (Default)\n${rate}: Rate - ${addplay}: Add + Play - ${insertplay}: Insert + Play" | column -s '-' -t)
line1=$(echo "${help_text}" | head -1)
line2=$(echo "${help_text}" | tail -1)
@@ -931,7 +927,7 @@ ${line2}</span>"
#HELP="<span color='$help_color'>${add}: Add, ${insert}: Insert, ${replace}: Replace (Default), ${rate}: Rate
#${addplay}: Add &amp; Play, ${insertplay}: Insert &amp; Play</span>"
-TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -select "$entry" -filter "$filter" -format "f¬s" -mesg "${HELP}" -p "Choose Album > ")
+TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/latest.cache) | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -select "$entry" -filter "$filter" -format "f¬s" -mesg "${HELP}" -p "Choose Album > ")
val=$?
@@ -947,9 +943,10 @@ TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${i
elif [[ "$TRACK" == "${add}: Add, ${insert}: Insert, ${replace}: Replace (Default)" ]]; then
addLastMod
else
- artist=$(echo "$TRACK" | awk -F "$separator" '{print $1}')
- date=$(echo "$TRACK" | awk -F "$separator" '{print $2}')
- album=$(echo "$TRACK" | awk -F "$separator" '{print $3}')
+ artist=$(echo -en "$TRACK" | awk -F "\t" '{print $1}' | sed -e 's/[[:space:]]*$//')
+ group2=$(echo -en "$TRACK" | awk -F '\t' '{print $2}'| sed -e 's/[[:space:]]*$//')
+ album=$(echo "$group2" | awk -F " - " '{print $2}')
+ date=$(echo "$group2" | awk -F " - " '{print $1}' | awk '{print substr($0, 2, length($0) - 2)}')
if [[ $val -eq 11 ]]; then
mpc search date "$date" album "$album" albumartist "$artist" | mpc insert
entry="$TRACK"
@@ -992,17 +989,6 @@ TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${i
}
AddAlbumTags() {
- if [[ -z $album_temp ]]; then
- loadCacheAlbums > /dev/null
- else
- echo "re-using track list from memory"
-# unset tracks_temp
-# export tracks_temp=${tracks_temp} > /dev/null
- fi
-
-menu="0 Return to Browse Menu
----
-${album_temp}"
help_text=$(echo -e "${add}: Add - ${insert}: Insert - ${replace}: Replace (Default)\n${rate}: Rate - ${addplay}: Add + Play - ${insertplay}: Insert + Play" | column -s '-' -t)
@@ -1012,7 +998,7 @@ HELP="<span color='$help_color'>${line1}
${line2}</span>"
-TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -filter "$filter" -select "$entry" -format "f¬s" -mesg "${HELP}" -p "Choose Album > ")
+TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/albums.cache) | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -filter "$filter" -select "$entry" -format "f¬s" -mesg "${HELP}" -p "Choose Album > ")
val=$?
@@ -1028,9 +1014,11 @@ TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${i
unset line
AddAlbumTags
else
- artist=$(echo "$TRACK" | awk -F "$separator" '{print $1}')
- date=$(echo "$TRACK" | awk -F "$separator" '{print $2}')
- album=$(echo "$TRACK" | awk -F "$separator" '{print $3}')
+ artist=$(echo -en "$TRACK" | awk -F "\t" '{print $1}' | sed -e 's/[[:space:]]*$//')
+ group2=$(echo -en "$TRACK" | awk -F '\t' '{print $2}'| sed -e 's/[[:space:]]*$//')
+ album=$(echo "$group2" | awk -F " - " '{print $2}')
+ date=$(echo "$group2" | awk -F " - " '{print $1}' | awk '{print substr($0, 2, length($0) - 2)}')
+ echo -e "artist: ${artist}\ndate: ${date}\nalbum: ${album}"
if [[ $val -eq 11 ]]; then
mpc find date "$date" album "$album" albumartist "$artist" | mpc insert
@@ -1075,17 +1063,13 @@ TRACK_TEMP=$(echo -e "${menu}" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${i
}
AddTrackTags() {
- if [[ -z $tracks_temp ]]; then
- loadCacheTracks > /dev/null
- else
- echo "re-using track list from memory"
+# if [[ -z $tracks_temp ]]; then
+# loadCacheTracks > /dev/null
+# else
+# echo "re-using track list from memory"
# unset tracks_temp
# export tracks_temp=${tracks_temp} > /dev/null
- fi
-
-menu="0 Return to Browse Menu
----
-${tracks_temp}"
+# fi
help_text=$(echo -e "${add}: Add (Default) - ${insert}: Insert - ${replace}: Replace\n${rate}: Rate - ${addplay}: Add + Play - ${insertplay}: Insert + Play" | column -s '-' -t)
line1=$(echo "${help_text}" | head -1)
@@ -1094,7 +1078,7 @@ HELP="<span color='$help_color'>${line1}
${line2}</span>"
-TRACK_TEMP=$(echo -e "$menu" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -filter "$filter" -select "$entry" -format "f¬s" -mesg "${HELP}" -p "Choose Track > ")
+TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/tracks.cache) | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${insert}" -custom-kb-3 "${replace}" -custom-kb-8 "${rate}" -custom-kb-4 "${addplay}" -custom-kb-5 "${insertplay}" -dmenu -filter "$filter" -select "$entry" -format "f¬s" -mesg "${HELP}" -p "Choose Track > ")
val=$?
@@ -1109,33 +1093,40 @@ TRACK_TEMP=$(echo -e "$menu" | dmenu_t -custom-kb-1 "${add}" -custom-kb-2 "${ins
elif [[ "$TRACK" == "${add}: Add | ${insert}: Insert | ${replace}: Replace | ${rate}: Rate" ]]; then
AddTrackTags
else
- artist=$(echo "$TRACK" | awk -F "$separator" '{print $1}')
- date=$(echo "$TRACK" | awk -F "$separator" '{print $2}')
- album=$(echo "$TRACK" | awk -F "$separator" '{print $3}')
- track=$(echo "$TRACK" | awk -F "$separator" '{print $4}')
- title=$(echo "$TRACK" | awk -F "$separator" '{print $5}')
-
+ group1=$(echo -en "$TRACK" | awk -F "\t" '{print $1}' | sed -e 's/[[:space:]]*$//')
+ artist=$(echo -ne "$group1" | awk -F " - " '{print $1}')
+ date=$(echo -ne "$group1" | awk -F " - " '{print $2}' | awk '{print substr($0, 2, length($0) - 2)}')
+ album=$(echo -ne "$group1" | awk -F " - " '{print $2}')
+ group2=$(echo -en "$TRACK" | awk -F "\t" '{print $2}' | sed -e 's/[[:space:]]*$//')
+ track=$(echo -ne "$group2" | awk -F " - " '{print $1}')
+ title=$(echo -en "$group2" | awk -F " - " '{print $2}')
+ filename=$(echo "$TRACK" | awk -F "\t" '{print $3}')
+
+ echo -e "artist: ${artist}\nalbum: ${album}\ntitle: ${title}\ntrack: ${track}\ndate: ${date}\ngroup1: ${group1}\ngroup2: ${group2}"
if [[ $val -eq 11 ]]; then
- mpc find artist "$artist" album "$album" title "$title" date "$date" | mpc insert
+ mpc insert "${filename}"
entry="$TRACK"
elif [[ $val -eq 12 ]]; then
mpc clear
- mpc findadd artist "$artist" album "$album" title "$title" date "$date"
+ mpc add "${filename}"
mpc play
entry="$TRACK"
elif [[ $val -eq 0 || $val -eq 10 ]]; then
- mpc findadd artist "$artist" album "$album" title "$title" date "$date"
+ #mpc findadd artist "$artist" album "$album" title "$title" date "$date"
+ mpc add "${filename}"
entry="$TRACK"
elif [[ $val -eq 13 ]]; then
- mpc findadd artist "$artist" album "$album" title "$title" date "$date"
+ mpc add "${filename}"
mpc searchplay "${title}"
+ entry="$TRACK"
elif [[ $val -eq 14 ]]; then
- mpc find artist "$artist" album "$album" title "$title" date "$date" | mpc insert
+ mpc insert "${filename}"
mpc searchplay "${title}"
+ entry="$TRACK"
elif [[ $val -eq 17 ]]; then
rateartist="${artist}" ratealbum="${album}" ratetrack="${track}" ratetitle="${title}" rateTrack
diff --git a/clerk_helper b/clerk_helper
index 6d9ce9a..fa6ce69 100755
--- a/clerk_helper
+++ b/clerk_helper
@@ -97,7 +97,7 @@ def createCache(args):
with open(os.getenv('HOME')+'/.config/clerk/latest.cache', "w") as cache_file:
for album in blist:
- cache_file.write(album['albumartist']+os.getenv('separator')+album['date']+os.getenv('separator')+album['album']+'\n')
+ cache_file.write(album['albumartist']+"\t("+album['date']+") - "+album['album']+'\n')
# create albums.cache
temp_albums=[]
@@ -105,7 +105,7 @@ def createCache(args):
albumlist=createRecentList(blist)
for album in albumlist:
- temp_albums.append(album['albumartist']+os.getenv('separator')+album['date']+os.getenv('separator')+album['album'])
+ temp_albums.append(album['albumartist']+"\t("+album['date']+") - "+album['album'])
final_albumlist=set(temp_albums)
blub=sorted(final_albumlist)
@@ -117,10 +117,10 @@ def createCache(args):
# create tracks.cache
tracklist=[]
for track in alist:
- taglist = ['date', 'artist', 'albumartist', 'album', 'track', 'title']
+ taglist = ['date', 'artist', 'albumartist', 'album', 'track', 'title', 'file']
track.update([(k, reduceToFstElm(v)) for (k, v) in track.items() if k in taglist])
- tracklist.append(track['artist']+os.getenv('separator')+track['date']+os.getenv('separator')+track['album']+os.getenv('separator')+track['track']+os.getenv('separator')+track['title'])
+ tracklist.append(track['artist']+" - ("+track['date']+") - "+track['album']+"\t"+track['track']+" - "+track['title']+"\t"+track['file'])
#
with open(os.getenv('HOME')+'/.config/clerk/tracks.cache', "w") as cache_file:
for track in tracklist: