Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

youtube-transcript

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-transcript - npm Package Compare versions

Comparing version 1.0.6 to 1.1.0

50

dist/youtube-transcript.common.js

@@ -1,2 +0,2 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:true});var p=require('phin');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var p__default=/*#__PURE__*/_interopDefaultLegacy(p);/*! *****************************************************************************
'use strict';Object.defineProperty(exports,'__esModule',{value:true});/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

@@ -67,2 +67,3 @@

}var RE_YOUTUBE = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i;
var USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36,gzip(gfe)';
var YoutubeTranscriptError = /** @class */ (function (_super) {

@@ -88,3 +89,3 @@ __extends(YoutubeTranscriptError, _super);

return __awaiter(this, void 0, void 0, function () {
var identifier, videoPageBody, innerTubeApiKey, body, transcripts, e_1;
var identifier, videoPageResponse, videoPageBody, innerTubeApiKey, transcriptResponse, body, transcripts, e_1;
return __generator(this, function (_a) {

@@ -96,19 +97,30 @@ switch (_a.label) {

case 1:
_a.trys.push([1, 5, , 6]);
return [4 /*yield*/, p__default['default']("https://www.youtube.com/watch?v=" + identifier)];
_a.trys.push([1, 7, , 8]);
return [4 /*yield*/, fetch("https://www.youtube.com/watch?v=" + identifier, {
headers: {
'User-Agent': USER_AGENT,
},
})];
case 2:
videoPageBody = (_a.sent()).body;
videoPageResponse = _a.sent();
return [4 /*yield*/, videoPageResponse.text()];
case 3:
videoPageBody = _a.sent();
innerTubeApiKey = videoPageBody
.toString()
.split('"INNERTUBE_API_KEY":"')[1]
.split('"')[0];
if (!(innerTubeApiKey && innerTubeApiKey.length > 0)) return [3 /*break*/, 4];
return [4 /*yield*/, p__default['default']({
url: "https://www.youtube.com/youtubei/v1/get_transcript?key=" + innerTubeApiKey,
if (!(innerTubeApiKey && innerTubeApiKey.length > 0)) return [3 /*break*/, 6];
return [4 /*yield*/, fetch("https://www.youtube.com/youtubei/v1/get_transcript?key=" + innerTubeApiKey, {
method: 'POST',
data: this.generateRequest(videoPageBody.toString(), config),
parse: 'json',
body: JSON.stringify(this.generateRequest(videoPageBody, config)),
headers: {
'Content-Type': 'application/json',
'User-Agent': USER_AGENT,
},
})];
case 3:
body = (_a.sent()).body;
case 4:
transcriptResponse = _a.sent();
return [4 /*yield*/, transcriptResponse.json()];
case 5:
body = _a.sent();
if (body.responseContext) {

@@ -129,8 +141,8 @@ if (!body.actions) {

}
_a.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
_a.label = 6;
case 6: return [3 /*break*/, 8];
case 7:
e_1 = _a.sent();
throw new YoutubeTranscriptError(e_1);
case 6: return [2 /*return*/];
case 8: return [2 /*return*/];
}

@@ -154,4 +166,4 @@ });

client: {
hl: (config === null || config === void 0 ? void 0 : config.lang) || 'fr',
gl: (config === null || config === void 0 ? void 0 : config.country) || 'FR',
hl: (config === null || config === void 0 ? void 0 : config.lang) || 'en',
gl: (config === null || config === void 0 ? void 0 : config.country) || 'US',
visitorData: visitorData,

@@ -158,0 +170,0 @@ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36,gzip(gfe)',

@@ -1,3 +0,1 @@

import p from 'phin';
/*! *****************************************************************************

@@ -71,2 +69,3 @@ Copyright (c) Microsoft Corporation.

var RE_YOUTUBE = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i;
var USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36,gzip(gfe)';
var YoutubeTranscriptError = /** @class */ (function (_super) {

@@ -92,3 +91,3 @@ __extends(YoutubeTranscriptError, _super);

return __awaiter(this, void 0, void 0, function () {
var identifier, videoPageBody, innerTubeApiKey, body, transcripts, e_1;
var identifier, videoPageResponse, videoPageBody, innerTubeApiKey, transcriptResponse, body, transcripts, e_1;
return __generator(this, function (_a) {

@@ -100,19 +99,30 @@ switch (_a.label) {

case 1:
_a.trys.push([1, 5, , 6]);
return [4 /*yield*/, p("https://www.youtube.com/watch?v=" + identifier)];
_a.trys.push([1, 7, , 8]);
return [4 /*yield*/, fetch("https://www.youtube.com/watch?v=" + identifier, {
headers: {
'User-Agent': USER_AGENT,
},
})];
case 2:
videoPageBody = (_a.sent()).body;
videoPageResponse = _a.sent();
return [4 /*yield*/, videoPageResponse.text()];
case 3:
videoPageBody = _a.sent();
innerTubeApiKey = videoPageBody
.toString()
.split('"INNERTUBE_API_KEY":"')[1]
.split('"')[0];
if (!(innerTubeApiKey && innerTubeApiKey.length > 0)) return [3 /*break*/, 4];
return [4 /*yield*/, p({
url: "https://www.youtube.com/youtubei/v1/get_transcript?key=" + innerTubeApiKey,
if (!(innerTubeApiKey && innerTubeApiKey.length > 0)) return [3 /*break*/, 6];
return [4 /*yield*/, fetch("https://www.youtube.com/youtubei/v1/get_transcript?key=" + innerTubeApiKey, {
method: 'POST',
data: this.generateRequest(videoPageBody.toString(), config),
parse: 'json',
body: JSON.stringify(this.generateRequest(videoPageBody, config)),
headers: {
'Content-Type': 'application/json',
'User-Agent': USER_AGENT,
},
})];
case 3:
body = (_a.sent()).body;
case 4:
transcriptResponse = _a.sent();
return [4 /*yield*/, transcriptResponse.json()];
case 5:
body = _a.sent();
if (body.responseContext) {

@@ -133,8 +143,8 @@ if (!body.actions) {

}
_a.label = 4;
case 4: return [3 /*break*/, 6];
case 5:
_a.label = 6;
case 6: return [3 /*break*/, 8];
case 7:
e_1 = _a.sent();
throw new YoutubeTranscriptError(e_1);
case 6: return [2 /*return*/];
case 8: return [2 /*return*/];
}

@@ -158,4 +168,4 @@ });

client: {
hl: (config === null || config === void 0 ? void 0 : config.lang) || 'fr',
gl: (config === null || config === void 0 ? void 0 : config.country) || 'FR',
hl: (config === null || config === void 0 ? void 0 : config.lang) || 'en',
gl: (config === null || config === void 0 ? void 0 : config.country) || 'US',
visitorData: visitorData,

@@ -162,0 +172,0 @@ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36,gzip(gfe)',

{
"name": "youtube-transcript",
"version": "1.0.6",
"version": "1.1.0",
"description": "Fetch transcript from a youtube video",

@@ -25,5 +25,2 @@ "main": "dist/youtube-transcript.common.js",

},
"dependencies": {
"phin": "^3.5.0"
},
"files": [

@@ -36,3 +33,6 @@ "dist/*"

},
"homepage": "https://github.com/Kakulukian/youtube-transcript"
"homepage": "https://github.com/Kakulukian/youtube-transcript",
"engines": {
"node": ">=18.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc