|
848 | 848 | loading = true; |
849 | 849 |
|
850 | 850 | try { |
851 | | - const body: any = { url, profileId: activeProfileId, saveToLibrary }; |
| 851 | + // Parse URLs - one per line |
| 852 | + const urls = url.trim().split('\n') |
| 853 | + .map(line => line.trim()) |
| 854 | + .filter(line => line.length > 0); |
| 855 | +
|
| 856 | + const body: any = { profileId: activeProfileId, saveToLibrary }; |
852 | 857 | if (advancedMode) { |
853 | 858 | const cf = buildCustomFlags(); |
854 | 859 | if (cf.length > 0) body.customFlags = cf; |
|
857 | 862 | if (bf.length > 0) body.customFlags = bf; |
858 | 863 | } |
859 | 864 |
|
860 | | - const res = await fetch("/api/downloads", { |
861 | | - method: "POST", |
862 | | - headers: { "Content-Type": "application/json" }, |
863 | | - body: JSON.stringify(body), |
864 | | - }); |
865 | | -
|
866 | | - if (!res.ok) { |
867 | | - const data = await res.json(); |
868 | | - throw new Error(data.message || "Failed to create download"); |
| 865 | + // If single URL, use original API |
| 866 | + if (urls.length === 1) { |
| 867 | + body.url = urls[0]; |
| 868 | + const res = await fetch("/api/downloads", { |
| 869 | + method: "POST", |
| 870 | + headers: { "Content-Type": "application/json" }, |
| 871 | + body: JSON.stringify(body), |
| 872 | + }); |
| 873 | +
|
| 874 | + if (!res.ok) { |
| 875 | + const data = await res.json(); |
| 876 | + throw new Error(data.message || "Failed to create download"); |
| 877 | + } |
| 878 | + } else { |
| 879 | + // Batch submission |
| 880 | + body.urls = urls; |
| 881 | + const res = await fetch("/api/downloads/batch", { |
| 882 | + method: "POST", |
| 883 | + headers: { "Content-Type": "application/json" }, |
| 884 | + body: JSON.stringify(body), |
| 885 | + }); |
| 886 | +
|
| 887 | + if (!res.ok) { |
| 888 | + const data = await res.json(); |
| 889 | + throw new Error(data.message || "Failed to create batch download"); |
| 890 | + } |
869 | 891 | } |
870 | 892 |
|
871 | 893 | url = ""; |
|
1001 | 1023 | <textarea |
1002 | 1024 | id="url" |
1003 | 1025 | bind:value={url} |
1004 | | - placeholder="Paste YouTube, TikTok, Twitter, or any supported URL..." |
| 1026 | + placeholder="Paste YouTube, TikTok, Twitter, or any supported URL... Tip: Paste multiple URLs (one per line) for batch download" |
1005 | 1027 | rows="3" |
1006 | 1028 | disabled={loading} |
1007 | 1029 | ></textarea> |
| 1030 | + {#if url.trim().split('\n').filter(line => line.trim()).length > 1} |
| 1031 | + <p class="batch-hint"> |
| 1032 | + {url.trim().split('\n').filter(line => line.trim()).length} URLs detected |
| 1033 | + </p> |
| 1034 | + {/if} |
1008 | 1035 | </div> |
1009 | 1036 |
|
1010 | 1037 | {#if libraryConfigured} |
|
1849 | 1876 | margin-bottom: var(--spacing-md); |
1850 | 1877 | } |
1851 | 1878 |
|
| 1879 | + .batch-hint { |
| 1880 | + margin-top: var(--spacing-xs); |
| 1881 | + font-size: 0.75rem; |
| 1882 | + color: var(--accent-primary); |
| 1883 | + font-weight: 500; |
| 1884 | + } |
| 1885 | +
|
1852 | 1886 | button[type="submit"] { |
1853 | 1887 | width: 100%; |
1854 | 1888 | } |
|
0 commit comments