1 Commits

Author SHA1 Message Date
Richard Kuhnt
472cd58a8c feat(core/au): Handle mediafire.com downloads 2019-10-05 18:34:27 +02:00
2 changed files with 17 additions and 0 deletions

View File

@@ -224,6 +224,11 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
$hashmode = 'sourceforge'
}
if (!$hashfile_url -and $url -match "^.*mediafire.com\/\w+\/(?<random>\w+)\/(?<filename>.*)\/file(?:#\/.*)?$") {
$hashmode = 'mediafire'
}
debug $hashmode
switch ($hashmode) {
'extract' {
$hash = find_hash_in_textfile $hashfile_url $substitutions $regex
@@ -251,6 +256,11 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u
$hashfile_url = (strip_filename (strip_fragment "https://sourceforge.net/projects/$($matches['project'])/files/$($matches['file'])")).TrimEnd('/')
$hash = find_hash_in_textfile $hashfile_url $substitutions '"$basename":.*?"sha1":\s"([a-fA-F0-9]{40})"'
}
'mediafire' {
if ((Invoke-RestMethod -Uri $url) -match 'aria-label="Download file"\s+href="(?<url>[^"]+)"') {
$url = $Matches.url
}
}
}
if ($hash) {

View File

@@ -917,6 +917,13 @@ function handle_special_urls($url)
# Reshapes the URL to avoid redirections
$url = "https://downloads.sourceforge.net/project/$($matches['project'])/$($matches['file'])"
}
# MediaFire.com
if ($url -match "^.*mediafire.com\/\w+\/(?<random>\w+)\/(?<filename>.*)\/file(?:#\/.*)?$") {
if ((Invoke-RestMethod -Uri $url) -match 'aria-label="Download file"\s+href="(?<url>[^"]+)"') {
$url = $Matches.url
}
}
return $url
}