Spaces:
Sleeping
Sleeping
File size: 4,284 Bytes
43a06dc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
<script lang="ts">
import settings from "$lib/state/settings";
import { t } from "$lib/i18n/translations";
import IconMovie from "@tabler/icons-svelte/IconMovie.svelte";
import IconMusic from "@tabler/icons-svelte/IconMusic.svelte";
let videoFilePreview: string;
let audioFilePreview: string;
const videoTitle = $t("settings.metadata.filename.preview.video");
const audioTitle = $t("settings.metadata.filename.preview.audio");
const infoBase = ["youtube", "dQw4w9WgXcQ"];
const fullResolution = {
"2160": "3840x2160",
"1440": "2560x1440",
"1080": "1920x1080",
"720": "1280x720",
"480": "854x480",
"360": "640x360",
"240": "426x240",
"144": "256x144",
};
let { downloadMode, youtubeVideoCodec, audioFormat, videoQuality } =
$settings.save;
let youtubeVideoExt = youtubeVideoCodec === "vp9" ? "webm" : "mp4";
audioFormat = audioFormat !== "best" ? audioFormat : "opus";
videoQuality = videoQuality !== "max" ? videoQuality : "2160";
if (youtubeVideoCodec === "h264" && Number(videoQuality) > 1080) {
videoQuality = "1080";
}
let classicTags = infoBase.concat([
fullResolution[videoQuality],
youtubeVideoCodec,
]);
let basicTags = [`${videoQuality}p`, youtubeVideoCodec];
if (downloadMode === "mute") {
classicTags.push("mute");
basicTags.push("mute");
}
$: switch ($settings.save.filenameStyle) {
case "classic":
videoFilePreview = classicTags.join("_");
audioFilePreview = "youtube_dQw4w9WgXcQ_audio";
break;
case "basic":
videoFilePreview = `${videoTitle} (${basicTags.join(", ")})`;
audioFilePreview = audioTitle;
break;
case "pretty":
videoFilePreview = `${videoTitle} (${[...basicTags, infoBase[0]].join(", ")})`;
audioFilePreview = `${audioTitle} (${infoBase[0]})`;
break;
case "nerdy":
videoFilePreview = `${videoTitle} (${basicTags.concat(infoBase).join(", ")})`;
audioFilePreview = `${audioTitle} (${infoBase.join(", ")})`;
break;
}
</script>
<div id="filename-preview">
<div id="filename-preview-video" class="filename-preview-item">
<div class="item-icon">
<IconMovie />
</div>
<div class="item-text">
<div class="preview">{`${videoFilePreview}.${youtubeVideoExt}`}</div>
<div class="subtext description">video file preview</div>
</div>
</div>
<div id="filename-preview-audio" class="filename-preview-item">
<div class="item-icon">
<IconMusic />
</div>
<div class="item-text">
<div class="preview">{`${audioFilePreview}.${audioFormat}`}</div>
<div class="subtext description">audio file preview</div>
</div>
</div>
</div>
<style>
#filename-preview {
font-weight: 500;
display: flex;
flex-direction: column;
background: var(--button);
box-shadow: var(--button-box-shadow);
border-radius: var(--border-radius);
}
.filename-preview-item {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
gap: 8px;
padding: 8px var(--padding);
}
.filename-preview-item:first-child {
border-bottom: 1.5px var(--button-stroke) solid;
}
.item-icon {
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
border-radius: 6px;
background-color: var(--gray);
}
.item-icon :global(svg) {
stroke: var(--white);
stroke-width: 1.5px;
height: 22px;
width: 22px;
will-change: transform;
}
.item-text {
display: flex;
flex-direction: column;
font-size: 14px;
overflow-wrap: anywhere;
}
.item-text .preview {
line-height: 1.3;
}
.item-text .description {
padding: 0;
}
@media screen and (max-width: 750px) {
.item-text {
font-size: 13px;
}
}
</style>
|