mirror of
				https://github.com/hydralauncher/hydra.git
				synced 2025-03-09 15:40:26 +00:00 
			
		
		
		
	Fix Pixeldrain/pdcybar Ratelimit
This commit is contained in:
		
							parent
							
								
									8513f83169
								
							
						
					
					
						commit
						6832c11d06
					
				
					 3 changed files with 46 additions and 2 deletions
				
			
		|  | @ -2,7 +2,7 @@ import { Downloader, DownloadError } from "@shared"; | |||
| import { WindowManager } from "../window-manager"; | ||||
| import { publishDownloadCompleteNotification } from "../notifications"; | ||||
| import type { Download, DownloadProgress, UserPreferences } from "@types"; | ||||
| import { GofileApi, QiwiApi, DatanodesApi, MediafireApi } from "../hosters"; | ||||
| import { GofileApi, QiwiApi, DatanodesApi, MediafireApi, PixelDrainApi } from "../hosters"; | ||||
| import { PythonRPC } from "../python-rpc"; | ||||
| import { | ||||
|   LibtorrentPayload, | ||||
|  | @ -283,11 +283,12 @@ export class DownloadManager { | |||
|       } | ||||
|       case Downloader.PixelDrain: { | ||||
|         const id = download.uri.split("/").pop(); | ||||
|         const downloadUrl = await PixelDrainApi.getDownloadUrl(id!); | ||||
| 
 | ||||
|         return { | ||||
|           action: "start", | ||||
|           game_id: downloadId, | ||||
|           url: `https://cdn.pd5-gamedriveorg.workers.dev/api/file/${id}`, | ||||
|           url: downloadUrl, | ||||
|           save_path: download.downloadPath, | ||||
|         }; | ||||
|       } | ||||
|  |  | |||
|  | @ -2,3 +2,4 @@ export * from "./gofile"; | |||
| export * from "./qiwi"; | ||||
| export * from "./datanodes"; | ||||
| export * from "./mediafire"; | ||||
| export * from "./pixeldrain"; | ||||
|  |  | |||
							
								
								
									
										42
									
								
								src/main/services/hosters/pixeldrain.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/main/services/hosters/pixeldrain.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,42 @@ | |||
| import axios from "axios"; | ||||
| 
 | ||||
| export class PixelDrainApi { | ||||
|   private static readonly browserHeaders = { | ||||
|     "User-Agent": | ||||
|       "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36", | ||||
|     Accept: | ||||
|       "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8", | ||||
|     "Accept-Language": "en-US,en;q=0.9", | ||||
|     "Accept-Encoding": "gzip, deflate, br", | ||||
|     DNT: "1", | ||||
|     Connection: "keep-alive", | ||||
|     "Sec-Fetch-Dest": "document", | ||||
|     "Sec-Fetch-Mode": "navigate", | ||||
|     "Sec-Fetch-Site": "none", | ||||
|     "Sec-Fetch-User": "?1", | ||||
|   }; | ||||
| 
 | ||||
|   public static async getDownloadUrl(fileId: string): Promise<string> { | ||||
|     try { | ||||
|       const response = await axios.get(`https://pd.cybar.xyz/${fileId}`, { | ||||
|         headers: this.browserHeaders, | ||||
|         maxRedirects: 0, | ||||
|         validateStatus: (status) => | ||||
|           status === 301 || status === 302 || status === 200, | ||||
|       }); | ||||
| 
 | ||||
|       if ( | ||||
|         response.headers.location || | ||||
|         response.status === 301 || | ||||
|         response.status === 302 | ||||
|       ) { | ||||
|         return response.headers.location; | ||||
|       } | ||||
| 
 | ||||
|       throw new Error(`No redirect URL found (status: ${response.status})`); | ||||
|     } catch (error) { | ||||
|       console.error("Error fetching PixelDrain URL:", error); | ||||
|       throw error; | ||||
|     } | ||||
|   } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue