Last active
December 20, 2023 22:49
-
-
Save thingsiplay/1f68e9125a1e2b2432c0ed58686b2008 to your computer and use it in GitHub Desktop.
RetroArch playlist key extractor - Dirty way of reading and printing values from .lpl playlist files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# RetroArch playlist key extractor | |
# Dirty way of reading and printing values from .lpl playlist files. | |
# | |
# EXAMPLES: | |
# lplpath | |
# lplpath "~/.config/retroarch/playlists/Nintendo - Game Boy.lpl" | |
KEY=path | |
#DEFAULT_FILE=~/.config/retroarch/content_favorites.lpl | |
DEFAULT_FILE=~/.config/retroarch/content_history.lpl | |
if [ "$#" -eq "0" ] | |
then | |
FILE=$DEFAULT_FILE | |
else | |
FILE=$1 | |
fi | |
# grep: get all lines with path | |
# awk: get the filepath | |
# sed: remove surrounding quotes and comma | |
grep -E '\s*"'$KEY'":\s*' "$FILE" \ | |
| awk -F: '{print $2}' \ | |
| sed 's/",\s*//g' \ | |
| sed 's/\s*"//g' |
At that time I didn't know about jq and didn't understood the file format. I actually plan on revisiting this soon, so it is good to know. Thanks for the reply, it's a great idea in case someone comes across this script. Edit: BTW I did it already it seems: https://gist.github.com/thingsiplay/21f92ab90cfbb75afc49a4624389c462
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jq (
sudo apt install jq --yes
) is your friend.jq -r '.items[].path' content_favorites.lpl