This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To use this, put it in a folder, install ytdl-core with `npm i ytdl-core`, then create a ZIP with the content of the folder and deploy it. | |
// https://docs.aws.amazon.com/lambda/latest/dg/nodejs-package.html#nodejs-package-dependencies | |
var AWS = require('aws-sdk'); | |
const ytdl = require('ytdl-core'); | |
const stream = require('stream'); | |
var s3 = new AWS.S3(); | |
exports.handler = async (event, context, cb) => { | |
const { videoUrl, key, bucket } = event; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URI { | |
public func appendingQueryParameters(_ parameters: [String: String]) -> URI { | |
let allParameters = mergeParameters(queryParameters(fromQuery: query), rhs: parameters) | |
let newQuery = toQuery(parameters: allParameters) | |
return URI(scheme: scheme, userInfo: userInfo, hostname: hostname, port: port, path: path, | |
query: newQuery, fragment: fragment) | |
} | |
private func toQuery(parameters: [String: String]) -> String { |