ionic-youtube-streams
Advanced tools
Comparing version 1.2.1 to 1.3.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sortByType = exports.info = exports.Name = void 0; | ||
exports.Name = void 0; | ||
exports.info = info; | ||
exports.sortByType = sortByType; | ||
var search_1 = require("./lib/search"); | ||
var Name = function (name) { return "Hello " + name; }; | ||
var Name = function (name) { return "Hello ".concat(name); }; | ||
exports.Name = Name; | ||
function info(videoId) { | ||
return search_1.searchVideo(videoId, 'video'); | ||
return (0, search_1.searchVideo)(videoId, 'video'); | ||
} | ||
exports.info = info; | ||
function sortByType(videoId, type) { | ||
return search_1.searchVideo(videoId, type); | ||
return (0, search_1.searchVideo)(videoId, type); | ||
} | ||
exports.sortByType = sortByType; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -12,8 +35,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); | ||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -39,13 +62,10 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.searchVideo = void 0; | ||
exports.searchVideo = searchVideo; | ||
var urllib = __importStar(require("url")); | ||
var ngx_1 = require("@ionic-native/http/ngx"); | ||
var tube_service_1 = require("./tube.service"); | ||
var querystring_1 = __importDefault(require("querystring")); | ||
function searchVideo(youtubeId, sortType) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var httpClient, tubeService, watchPageURL, ytApi, response, body, info, args, playErr, infoResponse; | ||
var httpClient, tubeService, headers, params, url, response, body, info, args, playErr, infoResponse, e_1; | ||
return __generator(this, function (_a) { | ||
@@ -56,15 +76,24 @@ switch (_a.label) { | ||
tubeService = new tube_service_1.YTubeService(httpClient); | ||
watchPageURL = tubeService.BASE_URL; | ||
ytApi = "" + watchPageURL; | ||
return [4 /*yield*/, httpClient.get(ytApi, { | ||
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Safari/537.36', | ||
}; | ||
params = {}; | ||
url = urllib.format({ | ||
protocol: 'https', | ||
host: "www.youtube.com", | ||
pathname: "watch", | ||
query: { | ||
v: youtubeId, | ||
hl: 'en', | ||
bpctr: Math.ceil(Date.now() / 1000), | ||
bpctr: "".concat(Math.ceil(Date.now() / 1000)), | ||
has_verified: 1, | ||
}, { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Safari/537.36', | ||
})]; | ||
}, | ||
}); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, httpClient.get(url, params, headers)]; | ||
case 2: | ||
response = _a.sent(); | ||
body = querystring_1.default.parse(response.data); | ||
body = response.data; | ||
info = { page: 'watch', player_response: '', response: '', html5player: '' }; | ||
@@ -99,6 +128,12 @@ try { | ||
} | ||
return [4 /*yield*/, tubeService.gotConfig(youtubeId, null, info, tubeService)]; | ||
case 2: | ||
return [4 /*yield*/, tubeService.gotConfig(youtubeId, null, info, tubeService, httpClient)]; | ||
case 3: | ||
infoResponse = _a.sent(); | ||
return [2 /*return*/, infoResponse]; | ||
case 4: | ||
e_1 = _a.sent(); | ||
// tslint:disable-next-line:no-console | ||
console.log(e_1); | ||
return [3 /*break*/, 5]; | ||
case 5: return [2 /*return*/]; | ||
} | ||
@@ -108,2 +143,1 @@ }); | ||
} | ||
exports.searchVideo = searchVideo; |
@@ -11,6 +11,6 @@ import { HTTP } from '@ionic-native/http/ngx'; | ||
parseJSON(source: any, varName: any, json: any): any; | ||
gotConfig(id: any, additional: any, info: any, tubeService: any): Promise<any>; | ||
gotConfig(id: any, additional: any, info: any, tubeService: any, httpClient: any): Promise<any>; | ||
generateClientPlaybackNonce(length: any): string; | ||
fetchIosJsonPlayer(videoId: any, tubeService: any): Promise<any>; | ||
fetchAndroidJsonPlayer(videoId: any, tubeService: any): Promise<any>; | ||
fetchIosJsonPlayer(videoId: any, tubeService: any, httpClient: any): Promise<any>; | ||
fetchAndroidJsonPlayer(videoId: any, tubeService: any, httpClient: any): Promise<any>; | ||
parseFormats(info: any): any[]; | ||
@@ -17,0 +17,0 @@ tryParseBetween: (body: any, left: any, right: any, prepend?: string, append?: string) => any; |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -12,8 +35,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); | ||
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -39,13 +62,14 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.YTubeService = void 0; | ||
var querystring_1 = __importDefault(require("querystring")); | ||
var urllib = __importStar(require("url")); | ||
var jsonClosingChars = /^[)\]}'\s]+/; | ||
@@ -85,3 +109,3 @@ // tslint:disable-next-line:one-variable-per-declaration | ||
return null; | ||
return JSON.parse("" + prepend + data + append); | ||
return JSON.parse("".concat(prepend).concat(data).concat(append)); | ||
} | ||
@@ -96,5 +120,5 @@ catch (e) { | ||
if (!jsonStr) { | ||
throw Error("Could not find " + varName + " in " + source); | ||
throw Error("Could not find ".concat(varName, " in ").concat(source)); | ||
} | ||
return tubeService.parseJSON(source, varName, tubeService.cutAfterJS("" + prependJSON + jsonStr)); | ||
return tubeService.parseJSON(source, varName, tubeService.cutAfterJS("".concat(prependJSON).concat(jsonStr))); | ||
}; | ||
@@ -115,3 +139,3 @@ ; | ||
if (!open) { | ||
throw new Error("Can't cut unsupported JSON (need to begin with [ or { ) but got: " + mixedJson[0]); | ||
throw new Error("Can't cut unsupported JSON (need to begin with [ or { ) but got: ".concat(mixedJson[0])); | ||
} | ||
@@ -193,3 +217,3 @@ // States if the loop is currently inside an escaped js object | ||
catch (err) { | ||
throw Error("Error parsing " + varName + " in " + source + ": " + err); | ||
throw Error("Error parsing ".concat(varName, " in ").concat(source, ": ").concat(err)); | ||
} | ||
@@ -199,3 +223,3 @@ } | ||
; | ||
YTubeService.prototype.gotConfig = function (id, additional, info, tubeService) { | ||
YTubeService.prototype.gotConfig = function (id, additional, info, tubeService, httpClient) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -208,4 +232,4 @@ var funcs, _a, iosPlayerResponse, androidPlayerResponse, results; | ||
return [4 /*yield*/, Promise.all([ | ||
tubeService.fetchIosJsonPlayer(id, tubeService), | ||
tubeService.fetchAndroidJsonPlayer(id, tubeService), | ||
tubeService.fetchIosJsonPlayer(id, tubeService, httpClient), | ||
tubeService.fetchAndroidJsonPlayer(id, tubeService, httpClient), | ||
])]; | ||
@@ -221,3 +245,3 @@ case 1: | ||
results = _b.sent(); | ||
info.formats = Object.values(Object.assign.apply(Object, __spreadArray([{}], results))); | ||
info.formats = Object.values(Object.assign.apply(Object, __spreadArray([{}], results, false))); | ||
return [2 /*return*/, info]; | ||
@@ -233,5 +257,5 @@ } | ||
; | ||
YTubeService.prototype.fetchIosJsonPlayer = function (videoId, tubeService) { | ||
YTubeService.prototype.fetchIosJsonPlayer = function (videoId, tubeService, httpClient) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var payload, response, body, playErr; | ||
var payload, url, response, body, playErr; | ||
return __generator(this, function (_a) { | ||
@@ -267,10 +291,25 @@ switch (_a.label) { | ||
}; | ||
return [4 /*yield*/, this.httpClient.post("https://youtubei.googleapis.com/youtubei/v1/player?id=" + videoId + "&prettyPrint=false&t=" + tubeService.generateClientPlaybackNonce(12), JSON.stringify(payload), { | ||
'Content-Type': 'application/json', | ||
'User-Agent': "com.google.ios.youtube/" + IOS_CLIENT_VERSION + "(" + IOS_DEVICE_MODEL + "; U; CPU iOS " + IOS_USER_AGENT_VERSION + " like Mac OS X; en_US)", | ||
'X-Goog-Api-Format-Version': '2', | ||
url = urllib.format({ | ||
protocol: 'https', | ||
host: "youtubei.googleapis.com", | ||
pathname: "youtubei/v1/player", | ||
query: { | ||
id: videoId, | ||
prettyPrint: 'false', | ||
t: tubeService.generateClientPlaybackNonce(12), | ||
}, | ||
}); | ||
return [4 /*yield*/, httpClient.sendRequest(url, { | ||
method: 'post', | ||
serializer: 'json', | ||
data: payload, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'User-Agent': "com.google.ios.youtube/".concat(IOS_CLIENT_VERSION, "(").concat(IOS_DEVICE_MODEL, "; U; CPU iOS ").concat(IOS_USER_AGENT_VERSION, " like Mac OS X; en_US)"), | ||
'X-Goog-Api-Format-Version': '2', | ||
} | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
body = querystring_1.default.parse(response.data); | ||
body = response.data; | ||
playErr = tubeService.playError(body); | ||
@@ -291,5 +330,5 @@ if (playErr) | ||
; | ||
YTubeService.prototype.fetchAndroidJsonPlayer = function (videoId, tubeService) { | ||
YTubeService.prototype.fetchAndroidJsonPlayer = function (videoId, tubeService, httpClient) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var payload, response, body, playErr; | ||
var payload, url, response, body, playErr; | ||
return __generator(this, function (_a) { | ||
@@ -324,10 +363,25 @@ switch (_a.label) { | ||
}; | ||
return [4 /*yield*/, this.httpClient.post("https://youtubei.googleapis.com/youtubei/v1/player?id=" + videoId + "&prettyPrint=false&t=" + tubeService.generateClientPlaybackNonce(12), JSON.stringify(payload), { | ||
'Content-Type': 'application/json', | ||
'User-Agent': "com.google.android.youtube/" + ANDROID_CLIENT_VERSION + " (Linux; U; Android " + ANDROID_OS_VERSION + "; en_US) gzip", | ||
'X-Goog-Api-Format-Version': '2', | ||
url = urllib.format({ | ||
protocol: 'https', | ||
host: "youtubei.googleapis.com", | ||
pathname: "youtubei/v1/player", | ||
query: { | ||
id: videoId, | ||
prettyPrint: 'false', | ||
t: tubeService.generateClientPlaybackNonce(12), | ||
}, | ||
}); | ||
return [4 /*yield*/, httpClient.sendRequest(url, { | ||
method: 'post', | ||
serializer: 'json', | ||
data: payload, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'User-Agent': "com.google.android.youtube/".concat(ANDROID_CLIENT_VERSION, " (Linux; U; Android ").concat(ANDROID_OS_VERSION, "; en_US) gzip"), | ||
'X-Goog-Api-Format-Version': '2', | ||
} | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
body = querystring_1.default.parse(response.data); | ||
body = response.data; | ||
playErr = tubeService.playError(body); | ||
@@ -422,3 +476,3 @@ if (playErr) | ||
if (!open) { | ||
throw new Error("Can't cut unsupported JSON (need to begin with [ or { ) but got: " + mixedJson[0]); | ||
throw new Error("Can't cut unsupported JSON (need to begin with [ or { ) but got: ".concat(mixedJson[0])); | ||
} | ||
@@ -425,0 +479,0 @@ // States if the loop is currently in a string |
{ | ||
"name": "ionic-youtube-streams", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Fetch meta information about YouTube videos including stream urls in ionic apps", | ||
@@ -52,19 +52,19 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.23", | ||
"@types/node": "^15.6.1", | ||
"jest": "^27.0.1", | ||
"prettier": "^2.3.0", | ||
"ts-jest": "^27.0.1", | ||
"@types/jest": "^29.5.13", | ||
"@types/node": "^22.7.7", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.3", | ||
"ts-jest": "^29.2.5", | ||
"tslint": "^6.1.3", | ||
"tslint-config-prettier": "^1.18.0", | ||
"typescript": "^4.3.2" | ||
"typescript": "^5.6.3" | ||
}, | ||
"dependencies": { | ||
"@angular/core": "^12.0.2", | ||
"@ionic-native/core": "^5.33.0", | ||
"@ionic-native/http": "^5.33.0", | ||
"@angular/core": "^18.2.8", | ||
"@ionic-native/core": "^5.36.0", | ||
"@ionic-native/http": "^5.36.0", | ||
"querystring": "^0.2.1", | ||
"rxjs": "^7.1.0", | ||
"url": "^0.11.0" | ||
"rxjs": "^6.5.0", | ||
"url": "^0.11.4" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
196703
689
0
+ Added@angular/core@18.2.12(transitive)
+ Addedzone.js@0.14.10(transitive)
- Removed@angular/core@12.2.17(transitive)
- Removedrxjs@7.8.1(transitive)
- Removedzone.js@0.11.8(transitive)
Updated@angular/core@^18.2.8
Updated@ionic-native/core@^5.36.0
Updated@ionic-native/http@^5.36.0
Updatedrxjs@^6.5.0
Updatedurl@^0.11.4