31 lines
893 B
Bash
31 lines
893 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Check if the correct number of arguments is provided
|
||
|
if [ $# -ne 2 ]; then
|
||
|
echo "Usage: $0 <extension_name> <extension_version>"
|
||
|
echo "Example: $0 Mpdf REL1_41"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Extension name and version from arguments
|
||
|
extension_name="$1"
|
||
|
extension_version="$2"
|
||
|
|
||
|
# URL to fetch
|
||
|
url="https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdistname=${extension_name}&extdistversion=${extension_version}"
|
||
|
|
||
|
# Fetch the HTML content using curl
|
||
|
html=$(curl -s "$url")
|
||
|
|
||
|
# Extract the download link using grep and sed
|
||
|
download_link=$(echo "$html" | grep -oP '<a rel="nofollow" class="external free" href="\K[^"]+' | sed 's/&/\&/g')
|
||
|
|
||
|
# Check if the download link is found
|
||
|
if [ -z "$download_link" ]; then
|
||
|
echo "Download link not found for extension '$extension_name' version '$extension_version'."
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
# Print the extracted download link
|
||
|
echo -n $download_link
|