Compare commits
No commits in common. "7e501a3acac535df8f206d0cfe3f7c5b70b85235" and "f1ac690abee3aa42a371fc563ccbd36b9f5f623e" have entirely different histories.
7e501a3aca
...
f1ac690abe
3 changed files with 42 additions and 107 deletions
|
|
@ -57,27 +57,6 @@ to an hour. Limits are constants at the top of `server/src/clips.js`.
|
|||
|
||||
A source can be several GB, so leave room on that disk.
|
||||
|
||||
**If YouTube says "Sign in to confirm you're not a bot"**, it's
|
||||
refusing the VPS's address, and yt-dlp needs a signed-in account's
|
||||
cookies. Use a separate Google account made for this, never a
|
||||
personal one: whoever has the cookies is signed in as it. Then set
|
||||
one of:
|
||||
|
||||
```ini
|
||||
# A cookies.txt exported from a browser signed in to that account
|
||||
# (a "Get cookies.txt" browser extension, Netscape format). Keep it
|
||||
# readable only by the service: chmod 600, owned by its user.
|
||||
Environment=YTDLP_COOKIES=/var/lib/ngu/youtube-cookies.txt
|
||||
|
||||
# Or: read them from a browser installed and signed in on the VPS
|
||||
# itself, as yt-dlp's --cookies-from-browser takes it.
|
||||
# Environment=YTDLP_COOKIES_FROM_BROWSER=firefox
|
||||
```
|
||||
|
||||
The file is copied for each download, so yt-dlp never rewrites the
|
||||
original. Cookies expire; when downloads start failing again, export
|
||||
a fresh file.
|
||||
|
||||
4. **nginx**: the editor's video and clip downloads are big streams. Give
|
||||
them their own block so nginx passes them straight through:
|
||||
|
||||
|
|
|
|||
|
|
@ -12,20 +12,6 @@
|
|||
FFMPEG_PATH default "ffmpeg"
|
||||
FFPROBE_PATH default "ffprobe"
|
||||
|
||||
When YouTube asks the server to "sign in to confirm you're not a
|
||||
bot", yt-dlp needs a signed-in account's cookies. One of:
|
||||
|
||||
YTDLP_COOKIES a cookies.txt exported from a browser
|
||||
(Netscape format). Copied per download,
|
||||
so yt-dlp never writes to the original
|
||||
YTDLP_COOKIES_FROM_BROWSER a browser on this machine to read them
|
||||
from, as yt-dlp's --cookies-from-browser
|
||||
takes it: "firefox", "chrome", or
|
||||
"firefox:/path/to/profile"
|
||||
|
||||
Use a separate Google account, not a personal one: the cookies
|
||||
are that account's sign-in. If both are set, the file wins.
|
||||
|
||||
── Safety ──
|
||||
Only links on YouTube and Facebook are accepted (SOURCE_HOSTS),
|
||||
so yt-dlp can't be pointed at anything else, internal addresses
|
||||
|
|
@ -58,8 +44,6 @@ export const CLIPS_DIR = path.resolve(process.env.CLIPS_DIR ?? "./clips");
|
|||
const YTDLP = process.env.YTDLP_PATH ?? "yt-dlp";
|
||||
const FFMPEG = process.env.FFMPEG_PATH ?? "ffmpeg";
|
||||
const FFPROBE = process.env.FFPROBE_PATH ?? "ffprobe";
|
||||
const COOKIES_FILE = process.env.YTDLP_COOKIES || null;
|
||||
const COOKIES_FROM_BROWSER = process.env.YTDLP_COOKIES_FROM_BROWSER || null;
|
||||
|
||||
const MAX_SOURCE_SECONDS = 4 * 60 * 60;
|
||||
const MAX_SOURCE_SIZE = "4G";
|
||||
|
|
@ -245,38 +229,14 @@ function update(db, id, fields) {
|
|||
);
|
||||
}
|
||||
|
||||
/* yt-dlp's cookie options, from the environment. A cookies file is
|
||||
copied first: yt-dlp saves updated cookies back to the file it's
|
||||
given, and the original may be read-only to the service. */
|
||||
async function cookieArgs(jobId) {
|
||||
if (COOKIES_FILE) {
|
||||
const copy = path.join(CLIPS_DIR, `.cookies-${jobId}.txt`);
|
||||
try {
|
||||
await copyFile(COOKIES_FILE, copy);
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Couldn't read the cookies file at ${COOKIES_FILE} (YTDLP_COOKIES)${err.code === "ENOENT" ? ": it isn't there" : ""}.`,
|
||||
);
|
||||
}
|
||||
return { args: ["--cookies", copy], cleanup: () => rm(copy, { force: true }) };
|
||||
}
|
||||
if (COOKIES_FROM_BROWSER) {
|
||||
return { args: ["--cookies-from-browser", COOKIES_FROM_BROWSER], cleanup: async () => {} };
|
||||
}
|
||||
return { args: [], cleanup: async () => {} };
|
||||
}
|
||||
|
||||
async function download(db, job) {
|
||||
const template = path.join(CLIPS_DIR, `source-${job.id}.%(ext)s`);
|
||||
let file = null;
|
||||
let title = null;
|
||||
const cookies = await cookieArgs(job.id);
|
||||
|
||||
try {
|
||||
await run(
|
||||
YTDLP,
|
||||
[
|
||||
...cookies.args,
|
||||
job.source_url,
|
||||
// YouTube needs a JavaScript runtime to list formats; the one
|
||||
// running this server will do.
|
||||
|
|
@ -317,10 +277,6 @@ async function download(db, job) {
|
|||
},
|
||||
);
|
||||
|
||||
} finally {
|
||||
await cookies.cleanup();
|
||||
}
|
||||
|
||||
if (!file) throw new Error("The video couldn't be downloaded. It may be private, too long, or too big.");
|
||||
const info = await probe(file);
|
||||
const { size } = await stat(file);
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@
|
|||
box or a build banner can read the same value later.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export const SITE_VERSION = "NGU-Web.v1.8.2-video-mgmt";
|
||||
export const SITE_VERSION = "NGU-Web.v1.8.1-video-mgmt";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue