Comments (4)
Thanks for this great suggestion!
I added the .raw
method to make possibleto access stream objects at [email protected]
:
const youtubedl = require('youtube-dl-exec')
const fs = require('fs')
const subprocess = youtubedl.raw('https://example.com', { dumpJson: true })
console.log(`Running subprocess as ${subprocess.pid}`)
subprocess.stdout.pipe(fs.createWriteStream('stdout.txt'))
subprocess.stderr.pipe(fs.createWriteStream('stderr.txt'))
setTimeout(subprocess.cancel, 30000)
from youtube-dl-exec.
@Kikobeats This is great, thank you! I wrote a script to pipe the stream object to a stream passthrough in order to directly upload to S3, but the resulting video file is corrupt. Am I misunderstanding something here? I can successfully download the Twitter link in this code example using the normal youtubedl
method.
const youtubedl = require('youtube-dl-exec')
const AWS = require('aws-sdk');
const stream = require('stream');
const s3 = new AWS.S3();
const uploadStream = ({ Bucket, Key, Metadata }) => {
const pass = new stream.PassThrough();
return {
writeStream: pass,
promise: s3.upload({ Bucket, Key, Body: pass }).promise(),
};
}
const { videoId, filename } = {
"videoId": "732194327145906176",
"filename": "sample_video",
}
const url = `https://twitter.com/i/status/${videoId}`
const { writeStream, promise } = uploadStream({ Bucket: process.env.S3_BUCKET, Key: `${filename}.mp4`});
youtubedl.raw(url, {
noCallHome: true,
noCheckCertificate: true,
preferFreeFormats: true,
format: 'mp4',
youtubeSkipDashManifest: true,
output: '%(id)s.%(ext)s'
}).stdout.pipe(writeStream);
const data = await promise;
return {
statusCode: 200,
body: data,
};
from youtube-dl-exec.
The script looks nice to me but I can't say too much there since I didn't have a use case like that before.
What I can recommend you to do is get the streaming source video URL via Microlink API:
https://api.microlink.io/?url=https://twitter.com/eejohnnnn/status/732194327145906176&video
It uses youtube-dl
(and this library) under the hood, then you can do a simple HTTP GET and pipe to your s3 bucket.
from youtube-dl-exec.
@Kikobeats amazing! Wasn't aware of this API, thank you!
from youtube-dl-exec.
Related Issues (20)
- Selected folder paths for downloads not implemented HOT 1
- Missing python? or ?
- Can I get the channel profile picture? HOT 2
- using best option , it not always give that url which contains both video and audio of youtube link HOT 1
- "Error: /usr/bin/env: python3: No such file or directory" in Next.js Backend HOT 3
- Update / Install of 2.4.3+ fails with Node v16 due to preinstall script HOT 5
- YtResponse type is incomplete missing: automatic_captions and others HOT 3
- HLS link extraction using youtube-dl-exec instead of youtube-dl HOT 2
- Getting 404 Errors HOT 1
- Error running on electron on mac HOT 1
- Not working after hosting on server HOT 2
- Unable to extract after uploading the code to a server HOT 1
- Not working when a binary is on a path with space HOT 1
- youtubedl.exec is missing cancel() function HOT 10
- tinyspawn version conflict HOT 2
- This expression is not callable. HOT 1
- Does not work if there is a space anywhere in the path HOT 5
- Issue with Python Check HOT 2
- All downloads return 'undefined' HOT 3
- post-install failures are minimized HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from youtube-dl-exec.