opengeodata.de

Best of Bash 6

2017-09-25

Something unrelated first: how to submit scrobbled tracks to last.fm? (aka: How to make your listening habits transparent?)

I use a SanDisk Clip+ MP3 player with Rockbox which saves any played track in a text file on the player. So, the player is added as a removable device, mounted and a small helper program is called:

python3 /home/thomas/bin/Laspyt/laspyt.py -f /media/thomas/SANSA\ CLIPP/.scrobbler.log -t +2

It will correct the timezone with +2 hours and delete the scrobble file after the submission. To configure the program run python3 laypyt.py --help.

audio converter

Let’s stay a bit on the multimedia side. If you use youtube-dl a lot, you may need to convert a talk or music video to audio only.

for vid in *.webm; do ffmpeg -i "$vid" -vn "${vid%.webm}.mp3"; done

Or you could do the following for a .mp3 and IDv3 tags (if you’re lucky):

youtube-dl --add-metadata -x --audio-format mp3 IZeef8iZq1s

time tracking

Again, the time tracking issue - if you want just the time your computer is turned on (assuming you fully reboot or shutdown), then last reboot is your friend. You could create a bash “script” copying the output from last reboot to a location while timestamping it.

last reboot > /home/user/work/time_logs/$(date +%Y-%m-%d).txt
crontab -e 
0 11 * * * /home/user/bin/tracktime.sh