Download-shaders.sh - Download additional Libretro Shaders

download-shaders.sh

#!/bin/env bash

# Required non standard packages:
#   lynx megatools

for option in "${@}"
do
    if [[ "${option}" == "-q" ]]
    then
        quiet=1
    else
        quiet=0
    fi
done

declare -a urls=(
    'https://forums.libretro.com/t/sonkun-s-crt-guest-advanced-hd-slot-mask-presets-thread/39091'
    'https://forums.libretro.com/t/new-crt-shader-from-guest-crt-guest-advanced-updates/25444'
)

for url in "${urls[@]}"
do
    # mediafire.com by sonkun
    link=$(lynx -dump -listonly "${url}" \
        | grep -oE "https://www.mediafire.com/.+$")
    file=$(lynx -dump -listonly "${link}" \
        | grep -oE "https://download.+.mediafire.com/.+$")
    if [[ "${quiet}" -eq 1 ]]
    then
        curl --silent --remote-name "${file}"
    else
        curl --remote-name "${file}"
    fi

    # mega.nz by guest
    # First link is official release, second link is newest version.
    link_number='2'
    link=$(lynx -dump -listonly "${url}" \
        | grep -oE "https://mega.nz/.+$" \
        | sed -n "${link_number}p" \
        | sed 's+#+!+g' \
        | sed 's+/file/+/#!+g')
    if [[ "${quiet}" -eq 1 ]]
    then
        megatools dl --no-progress "${link}" 2>/dev/null
    else
        megatools dl "${link}"
    fi
done

I am lazy. So that’s why I wrote a little helper script to download files from mega and mediafire. In fact, it is only to download Shader packages from the forum members of @sonkun and @guest.r from following forum posts:

Downloading files from mediafire is straight forward with lynx and curl programs. But those on mega are complicated, unless installing specific software megatools. Which I did. At the moment this is a Bash script (Linux) and just downloads the archives to current directory. I may or may not update the script to make them install into correct folders, but I am too lazy right now.

Note: The script is not well tested and is not designed to add any source links. Because it is expecting specific ordering of links in example, that are controlled by the forum post members. I still hope they will decide to upload to places where it is even more straight forward and standard, like Github.

4 Likes