-
-
Save GwynethLlewelyn/a7bc7f47dbf37127e9f157c347bc495a to your computer and use it in GitHub Desktop.
| #!/bin/sh | |
| # Grab all possible textures from LL's own CDN, referenced by UUID from LLSD backups. | |
| # Usage: Go to where your LLSD XML files are stored; run script. Wait a few seconds. Done! | |
| # (cc) 2024โ2025 by Gwyneth Llewelyn. Some rights reserved. | |
| # Distributed under the MIT license: https://gwyneth-llewelyn.mit-license.org | |
| # Second Lifeยฎ is a registered trademark of Linden Lab. No copyright infringement is intended. | |
| # | |
| # `ug` below is `ugrep`, a `grep` replacement, which you can get from here: <https://ugrep.com/> | |
| # All others should be standard on any Un*x system. | |
| # `curl` is usually available on all systems as well, but, if not, you can grab it from <https://curl.se/> | |
| # | |
| # The commands below have only been tested under `bash` 5.2.* but should work on most shells (not tested) | |
| # | |
| LLURL=http://asset-cdn.glb.agni.lindenlab.com/?texture_id= | |
| for uuid in $( ug -U -P --format='%1%~' --regexp '<uuid>([a-f0-9\-]+)</uuid>' -- *.xml | sort | uniq ) ; | |
| do | |
| if [ -f $uuid ]; | |
| then | |
| echo $uuid "(skipped) ๐" | |
| continue | |
| fi | |
| assetdir=$( echo $uuid | cut -b 1 ); | |
| if [ -f ~/Library/Caches/SecondLife/assets/$assetdir/$uuid.asset ]; | |
| then | |
| cp ~/Library/Caches/SecondLife/assets/$assetdir/$uuid.asset $uuid | |
| if [ $? -eq 0 ]; | |
| then | |
| echo $uuid "(from cache) โ " | |
| else | |
| echo "โ ๏ธ Copy \"~/Library/Caches/SecondLife/assets/$assetdir/$uuid.asset to $uuid\" failed with error $? โ ๏ธ" | |
| fi | |
| else | |
| # Attempt to retrieve it remotely | |
| curl -o $uuid $LLURL$uuid | |
| if [ $? -eq 0 ]; | |
| then | |
| echo $uuid "(from direct download) โ " | |
| else | |
| echo $uuid โ | |
| fi | |
| fi | |
| done |
Oh, dang โ you're absolutely right, I keep forgetting that...
ug is the short form of ugrep, a grep replacement which is ultra-fast and has the kind of bells and whistles that, once you taste them, you will never go back. It's tiny, small, efficient...
Their homepage shows several different ways of installing ugrep. If you want the bleeding edge version, you can even compile it yourself โ it's one of those tools that is easy to compile and all.
Nevertheless, you're right, I should have stuck with familiar, pre-installed tools. The trouble is โ I'll have to see if grep/egrep/fgrep can do all that nice little parsing in a single line! I would guess not โ so it might require an extra formatting step (say, with cut or sed and/or a bit of awk). Because I'm lazy and can't ever remember all those parameters, I tend to use โ and abuse! โ ugrep in whatever machine I'm running.
Thanks for pointing it out, I'll add an extra comment on the script!
Thanks! found it in AUR.
Enjoy ๐
what is the dependency for for uuid in $( ug -U -P --format='%1%~' --regexp '([a-f0-9-]+)' -- *.xml | sort | uniq ) ;
What is "ug" ?