download media from various services using cobalt.tools via raycast
raycast raycast-extension

add ability to disable opening the file manager after downloading the media

add more info to the instance url description

+44 -15
+11 -3
package.json
··· 18 18 { 19 19 "name": "instance_url", 20 20 "title": "Instance URL", 21 - "description": "The cobalt.tools instance to use. Please make sure that the instance you choose is trustworthy.", 21 + "description": "The cobalt.tools instance to use. Please make sure that the instance you choose is trustworthy, as malicious instances can be used to get info about your device.", 22 22 "type": "textfield", 23 23 "default": "https://dl.woof.monster", 24 - "placeholder": "https://cobalt.sudoman.ia", 24 + "placeholder": "https://dl.woof.monster", 25 25 "required": false 26 26 }, 27 27 { ··· 49 49 { 50 50 "name": "default_folder", 51 51 "title": "Download media to", 52 - "description": "The default folder to save media. This does not apply to media that can only be downloaded via the web browser.", 52 + "description": "The default folder to save media.", 53 53 "type": "directory", 54 54 "required": true 55 + }, 56 + { 57 + "name": "show_in_file_manager", 58 + "label": "Show media in file manager when download finishes", 59 + "description": "Shows where the media has been saved in the file manager", 60 + "type": "checkbox", 61 + "default": true, 62 + "required": false 55 63 } 56 64 ], 57 65 "dependencies": {
+33 -12
src/download-media.tsx
··· 52 52 const media = await fetch(res.url); 53 53 await pipeline(Readable.fromWeb(media.body), fs.createWriteStream(`${values.destination}/${res.filename}`)); 54 54 55 - switch (os.type()) { 56 - case "Darwin": 57 - await showHUD("Opened in Finder"); 58 - break; 59 - case "Windows_NT": 60 - await showHUD("Opened in File Explorer"); 61 - break; 55 + if (preferences.show_in_file_manager) { 56 + switch (os.type()) { 57 + case "Darwin": 58 + await showHUD("Opened in Finder"); 59 + break; 60 + case "Windows_NT": 61 + await showHUD("Opened in File Explorer"); 62 + break; 63 + } 64 + await showInFinder(`${values.destination}/${res.filename}`); 65 + await closeMainWindow({ 66 + // showHUD can close the main window, making this redundant, but 67 + // we still needed to open the file manager, so we fully close 68 + // it here 69 + clearRootSearch: true, 70 + popToRootType: PopToRootType.Immediate, 71 + }); 72 + } else { 73 + await closeMainWindow(); 74 + showToast({ 75 + // showHUD does not allow subtitles, so we close the main window 76 + // and show a "toast" instead. 77 + title: "Media successfully downloaded", 78 + message: res.filename, 79 + style: Toast.Style.Success, 80 + }); 81 + await closeMainWindow({ 82 + // we still needed to show the toast, now that we have, we can 83 + // fully close the main window 84 + clearRootSearch: true, 85 + popToRootType: PopToRootType.Immediate, 86 + }); 62 87 } 63 - await showInFinder(`${values.destination}/${res.filename}`); 64 - await closeMainWindow({ 65 - clearRootSearch: true, 66 - popToRootType: PopToRootType.Immediate, 67 - }); 88 + 68 89 break; 69 90 } 70 91 case "error":