Add premium plugin detection and user guidance for manual downloads
This commit is contained in:
1 parent
a5e7b766ac
commit
057bba0c56
4 files changed
+251
-63
No files matched your search
@@ -355,6 +355,9 @@ impl Repository for SpigotMCCrawler {
|
||||
// First, get the plugin details
|
||||
let details = self.get_plugin_details(plugin_id).await?;
|
||||
|
||||
// Get the plugin page URL for potential manual download instructions
|
||||
let plugin_page_url = details.page_url.clone();
|
||||
|
||||
// Use the SpigotMC direct download URL instead of SpiGet
|
||||
// SpigotMC has a direct download URL pattern for resources
|
||||
let direct_download_url = format!("https://www.spigotmc.org/resources/{}/download", plugin_id);
|
||||
@@ -370,19 +373,46 @@ impl Repository for SpigotMCCrawler {
|
||||
Ok(destination.to_string_lossy().to_string())
|
||||
},
|
||||
Err(e) => {
|
||||
// If direct download fails, try the SpiGet URL as fallback
|
||||
println!("Direct SpigotMC download failed: {}. Trying SpiGet URL as fallback...", e);
|
||||
// If direct download fails with 403, it might be a premium resource
|
||||
let error_message = format!("{}", e);
|
||||
if error_message.contains("403 Forbidden") {
|
||||
println!("Plugin appears to be a premium/protected resource on SpigotMC");
|
||||
|
||||
let download_url = &details.download_url;
|
||||
if download_url.is_empty() {
|
||||
return Err(format!("No download URL found for SpigotMC resource {}", plugin_id));
|
||||
}
|
||||
// Try the SpiGet URL as a fallback just to be sure
|
||||
let download_url = &details.download_url;
|
||||
if download_url.is_empty() {
|
||||
return Err(format!("PREMIUM_RESOURCE:{}", plugin_page_url));
|
||||
}
|
||||
|
||||
println!("Falling back to SpiGet download URL: {}", download_url);
|
||||
println!("Falling back to SpiGet download URL: {}", download_url);
|
||||
|
||||
match self.client.download(download_url, destination).await {
|
||||
Ok(_) => Ok(destination.to_string_lossy().to_string()),
|
||||
Err(e) => Err(format!("Failed to download from SpiGet: {}", e))
|
||||
match self.client.download(download_url, destination).await {
|
||||
Ok(_) => Ok(destination.to_string_lossy().to_string()),
|
||||
Err(spiget_err) => {
|
||||
// If both methods fail, this is very likely a premium plugin
|
||||
if format!("{}", spiget_err).contains("404 Not Found") {
|
||||
println!("Confirmed premium resource - both direct and SpiGet downloads failed");
|
||||
Err(format!("PREMIUM_RESOURCE:{}", plugin_page_url))
|
||||
} else {
|
||||
Err(format!("Failed to download from SpiGet: {}", spiget_err))
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// For other errors with direct download, try SpiGet
|
||||
println!("Direct SpigotMC download failed: {}. Trying SpiGet URL as fallback...", e);
|
||||
|
||||
let download_url = &details.download_url;
|
||||
if download_url.is_empty() {
|
||||
return Err(format!("No download URL found for SpigotMC resource {}", plugin_id));
|
||||
}
|
||||
|
||||
println!("Falling back to SpiGet download URL: {}", download_url);
|
||||
|
||||
match self.client.download(download_url, destination).await {
|
||||
Ok(_) => Ok(destination.to_string_lossy().to_string()),
|
||||
Err(e) => Err(format!("Failed to download from SpiGet: {}", e))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user