mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
Merge branch 'current' into improvement/hls-istream
This commit is contained in:
commit
18f0b9b860
@ -594,7 +594,7 @@ export default function(obj) {
|
|||||||
<div id="download-area">
|
<div id="download-area">
|
||||||
<div id="top">
|
<div id="top">
|
||||||
<div id="link-icon">${linkSVG}</div>
|
<div id="link-icon">${linkSVG}</div>
|
||||||
<input id="url-input-area" class="mono" type="text" autocomplete="off" spellcheck="false" maxlength="256" autocapitalize="off" placeholder="${t('LinkInput')}" aria-label="${t('AccessibilityInputArea')}" oninput="button()">
|
<input id="url-input-area" class="mono" type="text" autocomplete="off" data-form-type="other" spellcheck="false" maxlength="256" autocapitalize="off" placeholder="${t('LinkInput')}" aria-label="${t('AccessibilityInputArea')}" oninput="button()">
|
||||||
<button id="url-clear" onclick="clearInput()" style="display:none;">x</button>
|
<button id="url-clear" onclick="clearInput()" style="display:none;">x</button>
|
||||||
<input id="download-button" class="mono dontRead" onclick="download(document.getElementById('url-input-area').value)" type="submit" value="" disabled aria-label="${t('AccessibilityDownloadButton')}">
|
<input id="download-button" class="mono dontRead" onclick="download(document.getElementById('url-input-area').value)" type="submit" value="" disabled aria-label="${t('AccessibilityDownloadButton')}">
|
||||||
</div>
|
</div>
|
||||||
|
@ -61,7 +61,7 @@ export default async function(o) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info = await yt.getBasicInfo(o.id, 'WEB');
|
info = await yt.getBasicInfo(o.id, 'IOS');
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
if (e?.message === 'This video is unavailable') {
|
if (e?.message === 'This video is unavailable') {
|
||||||
return { error: 'ErrorCouldntFetch' };
|
return { error: 'ErrorCouldntFetch' };
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"alias": "reddit videos & gifs",
|
"alias": "reddit videos & gifs",
|
||||||
"patterns": ["r/:sub/comments/:id/:title", "user/:user/comments/:id/:title"],
|
"patterns": ["r/:sub/comments/:id/:title", "user/:user/comments/:id/:title"],
|
||||||
"subdomains": "*",
|
"subdomains": "*",
|
||||||
"enabled": true
|
"enabled": false
|
||||||
},
|
},
|
||||||
"twitter": {
|
"twitter": {
|
||||||
"alias": "twitter videos & voice",
|
"alias": "twitter videos & voice",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { request } from 'undici';
|
import { request } from 'undici';
|
||||||
import { Readable } from 'node:stream';
|
import { Readable } from 'node:stream';
|
||||||
import { assert } from 'console';
|
import { assert } from 'console';
|
||||||
import { getHeaders } from './shared.js';
|
import { getHeaders, pipe } from './shared.js';
|
||||||
import { handleHlsPlaylist, isHlsRequest } from './internal-hls.js';
|
import { handleHlsPlaylist, isHlsRequest } from './internal-hls.js';
|
||||||
|
|
||||||
const CHUNK_SIZE = BigInt(8e6); // 8 MB
|
const CHUNK_SIZE = BigInt(8e6); // 8 MB
|
||||||
@ -67,8 +67,7 @@ async function handleYoutubeStream(streamInfo, res) {
|
|||||||
if (headerValue) res.setHeader(headerName, headerValue);
|
if (headerValue) res.setHeader(headerName, headerValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.pipe(res);
|
pipe(stream, res, () => res.end());
|
||||||
stream.on('error', () => res.end());
|
|
||||||
} catch {
|
} catch {
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
@ -101,8 +100,7 @@ export async function internalStream(streamInfo, res) {
|
|||||||
if (isHlsRequest(req)) {
|
if (isHlsRequest(req)) {
|
||||||
await handleHlsPlaylist(streamInfo, req, res);
|
await handleHlsPlaylist(streamInfo, req, res);
|
||||||
} else {
|
} else {
|
||||||
req.body.pipe(res);
|
pipe(req.body, res, () => res.end());
|
||||||
req.body.on('error', () => res.end());
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
streamInfo.controller.abort();
|
streamInfo.controller.abort();
|
||||||
|
@ -29,3 +29,13 @@ export function getHeaders(service) {
|
|||||||
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
||||||
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pipe(from, to, done) {
|
||||||
|
from.on('error', done)
|
||||||
|
.on('close', done);
|
||||||
|
|
||||||
|
to.on('error', done)
|
||||||
|
.on('close', done);
|
||||||
|
|
||||||
|
from.pipe(to);
|
||||||
|
}
|
@ -6,7 +6,7 @@ import { create as contentDisposition } from "content-disposition-header";
|
|||||||
import { metadataManager } from "../sub/utils.js";
|
import { metadataManager } from "../sub/utils.js";
|
||||||
import { destroyInternalStream } from "./manage.js";
|
import { destroyInternalStream } from "./manage.js";
|
||||||
import { env, ffmpegArgs, hlsExceptions } from "../config.js";
|
import { env, ffmpegArgs, hlsExceptions } from "../config.js";
|
||||||
import { getHeaders, closeResponse } from "./shared.js";
|
import { getHeaders, closeResponse, pipe } from "./shared.js";
|
||||||
|
|
||||||
function toRawHeaders(headers) {
|
function toRawHeaders(headers) {
|
||||||
return Object.entries(headers)
|
return Object.entries(headers)
|
||||||
@ -28,16 +28,6 @@ function killProcess(p) {
|
|||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function pipe(from, to, done) {
|
|
||||||
from.on('error', done)
|
|
||||||
.on('close', done);
|
|
||||||
|
|
||||||
to.on('error', done)
|
|
||||||
.on('close', done);
|
|
||||||
|
|
||||||
from.pipe(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCommand(args) {
|
function getCommand(args) {
|
||||||
if (!isNaN(env.processingPriority)) {
|
if (!isNaN(env.processingPriority)) {
|
||||||
return ['nice', ['-n', env.processingPriority.toString(), ffmpeg, ...args]]
|
return ['nice', ['-n', env.processingPriority.toString(), ffmpeg, ...args]]
|
||||||
|
Loading…
Reference in New Issue
Block a user