Added ttDownloader
This commit is contained in:
		
							
								
								
									
										32
									
								
								ttDownloader.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								ttDownloader.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					import uu from 'url-unshort';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class VidDownload {
 | 
				
			||||||
 | 
					    public async UnshortenUrl(string) { 
 | 
				
			||||||
 | 
					        let shorturl = new URL(string);
 | 
				
			||||||
 | 
					        let longurl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            const url = await uu.expand(shorturl);
 | 
				
			||||||
 | 
					            longurl = url;
 | 
				
			||||||
 | 
					        } catch (err) {
 | 
				
			||||||
 | 
					            console.log("URL Unshortening failed");
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return longurl;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public CreateDownloadLink(string) { 
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public isValidUrl(string) {
 | 
				
			||||||
 | 
					        let url;
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            url = new URL(string);
 | 
				
			||||||
 | 
					        } catch (_) {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return url.protocol === "https:";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user