Compare commits
2 Commits
744af7337b
...
83e2685c6a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83e2685c6a | ||
|
|
c24964a1ee |
@@ -449,15 +449,15 @@ def fetch_dislike_count(youtube_video_id: str) -> int | None:
|
||||
|
||||
|
||||
QUALITY_FORMATS = {
|
||||
"best": "bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a]/bestvideo[ext=mp4]+bestaudio[ext=m4a]/22/18/bestvideo+bestaudio/best",
|
||||
"2160p": "bestvideo[ext=mp4][height<=2160]+bestaudio[ext=m4a]/bestvideo[height<=2160]+bestaudio/best[height<=2160]",
|
||||
"1440p": "bestvideo[ext=mp4][height<=1440]+bestaudio[ext=m4a]/bestvideo[height<=1440]+bestaudio/best[height<=1440]",
|
||||
"1080p": "bestvideo[ext=mp4][vcodec^=avc1][height<=1080]+bestaudio[ext=m4a]/bestvideo[ext=mp4][height<=1080]+bestaudio[ext=m4a]/137+140/22/best[height<=1080]",
|
||||
"720p": "bestvideo[ext=mp4][vcodec^=avc1][height<=720]+bestaudio[ext=m4a]/bestvideo[ext=mp4][height<=720]+bestaudio[ext=m4a]/22/best[height<=720]",
|
||||
"480p": "bestvideo[ext=mp4][vcodec^=avc1][height<=480]+bestaudio[ext=m4a]/bestvideo[ext=mp4][height<=480]+bestaudio[ext=m4a]/18/best[height<=480]",
|
||||
"360p": "bestvideo[ext=mp4][height<=360]+bestaudio[ext=m4a]/18/best[height<=360]",
|
||||
"240p": "bestvideo[ext=mp4][height<=240]+bestaudio[ext=m4a]/best[height<=240]",
|
||||
"144p": "bestvideo[ext=mp4][height<=144]+bestaudio[ext=m4a]/best[height<=144]",
|
||||
"best": "bestvideo+bestaudio/best",
|
||||
"2160p": "bestvideo[height<=2160]+bestaudio/best[height<=2160]",
|
||||
"1440p": "bestvideo[height<=1440]+bestaudio/best[height<=1440]",
|
||||
"1080p": "bestvideo[height<=1080]+bestaudio/best[height<=1080]",
|
||||
"720p": "bestvideo[height<=720]+bestaudio/best[height<=720]",
|
||||
"480p": "bestvideo[height<=480]+bestaudio/best[height<=480]",
|
||||
"360p": "bestvideo[height<=360]+bestaudio/best[height<=360]",
|
||||
"240p": "bestvideo[height<=240]+bestaudio/best[height<=240]",
|
||||
"144p": "bestvideo[height<=144]+bestaudio/best[height<=144]",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -710,7 +710,7 @@ export default function Watch() {
|
||||
}, [playRequested, fileReady, dlStatus?.status, dlStatus?.file_url, video?.is_downloaded, youtubeVideoId, pollForFile]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const downloadMut = useMutation({
|
||||
mutationFn: () => createDownload(youtubeVideoId, selectedQuality),
|
||||
mutationFn: (quality) => createDownload(youtubeVideoId, quality ?? selectedQuality),
|
||||
onSuccess: (res) => {
|
||||
setDownloadId(res.data.id);
|
||||
refetchVideo();
|
||||
@@ -722,7 +722,7 @@ export default function Watch() {
|
||||
setPlayRequested(true);
|
||||
downloadMut.mutate();
|
||||
}, [downloadMut]);
|
||||
const handleRedownload = useCallback(async () => {
|
||||
const handleRedownload = useCallback(async (quality) => {
|
||||
const dlId = downloadId ?? allDownloads.find(
|
||||
d => d.youtube_video_id === youtubeVideoId && d.status === "complete"
|
||||
)?.id;
|
||||
@@ -736,7 +736,7 @@ export default function Watch() {
|
||||
setIsRedownloading(false);
|
||||
qc.invalidateQueries({ queryKey: ["downloads"] });
|
||||
refetchVideo();
|
||||
downloadMut.mutate();
|
||||
downloadMut.mutate(quality);
|
||||
}, [downloadId, allDownloads, youtubeVideoId, downloadMut, refetchVideo, qc]);
|
||||
|
||||
const saveProgress = useCallback((secs) => {
|
||||
@@ -933,7 +933,11 @@ export default function Watch() {
|
||||
{!isDownloading && !downloadMut.isPending && !isRedownloading && (
|
||||
<select
|
||||
value={selectedQuality ?? "best"}
|
||||
onChange={(e) => setSelectedQuality(e.target.value)}
|
||||
onChange={(e) => {
|
||||
const q = e.target.value;
|
||||
setSelectedQuality(q);
|
||||
if (dlComplete) handleRedownload(q);
|
||||
}}
|
||||
className="bg-zinc-800 text-zinc-300 text-xs rounded-full px-3 py-2 border border-zinc-700 focus:outline-none focus:border-accent"
|
||||
>
|
||||
{[
|
||||
@@ -987,15 +991,6 @@ export default function Watch() {
|
||||
</Chip>
|
||||
)}
|
||||
|
||||
{dlComplete && (
|
||||
<Chip onClick={handleRedownload} disabled={isRedownloading || downloadMut.isPending}>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2}
|
||||
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
||||
</svg>
|
||||
Re-download
|
||||
</Chip>
|
||||
)}
|
||||
|
||||
{video?.id && (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user