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

iyoutube

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iyoutube - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

0

output/adapters/NodeFetchClientAdapter.d.ts

@@ -0,0 +0,0 @@ import { HTTPClient, HTTPRequestOptions } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { StorageAdapter } from "../interfaces/StorageAdapter";

@@ -0,0 +0,0 @@ "use strict";

2

output/Authenticator.d.ts
import { HTTPClient } from "./interfaces/HTTPClient";
import { StorageAdapter } from "./interfaces/StorageAdapter";
export declare class Authenticator {
#private;
httpClient: HTTPClient;
storageAdapter: StorageAdapter;
token: any;
constructor(httpclient: HTTPClient, storage: StorageAdapter);

@@ -8,0 +8,0 @@ init(): Promise<void>;

@@ -11,14 +11,2 @@ "use strict";

};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Authenticator_token;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -32,3 +20,3 @@ exports.Authenticator = void 0;

constructor(httpclient, storage) {
_Authenticator_token.set(this, {
this.token = {
access: "NULL",

@@ -38,3 +26,3 @@ refresh: "NULL",

expireDate: new Date()
});
};
this.httpClient = httpclient;

@@ -52,5 +40,5 @@ this.storageAdapter = storage;

if (str) {
__classPrivateFieldSet(this, _Authenticator_token, JSON.parse(str), "f");
this.token = JSON.parse(str);
if (constants_1.DEBUG)
console.log(constants_1.CONSOLE_COLORS.bright + constants_1.CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Now using Token from Storage (expires: " + new Date(__classPrivateFieldGet(this, _Authenticator_token, "f").expireDate).toLocaleString() + ")", constants_1.CONSOLE_COLORS.reset);
console.log(constants_1.CONSOLE_COLORS.bright + constants_1.CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Now using Token from Storage (expires: " + new Date(this.token.expireDate).toLocaleString() + ")", constants_1.CONSOLE_COLORS.reset);
}

@@ -61,3 +49,3 @@ }

requiresLogin() {
return Object.values(__classPrivateFieldGet(this, _Authenticator_token, "f")).includes("NULL");
return Object.values(this.token).includes("NULL");
}

@@ -100,3 +88,3 @@ getNewLoginCode() {

}
__classPrivateFieldSet(this, _Authenticator_token, { type: null, access: null, refresh: res.refresh_token, expireDate: null }, "f");
this.token = { type: null, access: null, refresh: res.refresh_token, expireDate: null };
if (constants_1.DEBUG)

@@ -109,3 +97,3 @@ console.log(constants_1.CONSOLE_COLORS.bright + constants_1.CONSOLE_COLORS.fg.yellow + "[AUTHENTICATOR] Authentication Method successfull: Device Code", constants_1.CONSOLE_COLORS.reset);

return __awaiter(this, void 0, void 0, function* () {
if (__classPrivateFieldGet(this, _Authenticator_token, "f").access == null || (Date.now() - __classPrivateFieldGet(this, _Authenticator_token, "f").expireDate) > 0) {
if (this.token.access == null || (Date.now() - this.token.expireDate) > 0) {
let res = yield this.httpClient.request({

@@ -118,14 +106,14 @@ method: HTTPClient_1.HTTPRequestMethod.POST,

grant_type: "refresh_token",
refresh_token: __classPrivateFieldGet(this, _Authenticator_token, "f").refresh
refresh_token: this.token.refresh
})
});
res = JSON.parse(res.data);
__classPrivateFieldSet(this, _Authenticator_token, { type: res.token_type, access: res.access_token, refresh: __classPrivateFieldGet(this, _Authenticator_token, "f").refresh, expireDate: (new Date().getTime() + 1000 * res.expires_in) }, "f");
this.token = { type: res.token_type, access: res.access_token, refresh: this.token.refresh, expireDate: (new Date().getTime() + 1000 * res.expires_in) };
if (constants_1.DEBUG)
console.log(constants_1.CONSOLE_COLORS.bright + constants_1.CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Refreshed the Access Token using the refresh Token", constants_1.CONSOLE_COLORS.reset);
yield this.storageAdapter.set(TOKEN_FILE, JSON.stringify(Object.assign({}, __classPrivateFieldGet(this, _Authenticator_token, "f"))));
yield this.storageAdapter.set(TOKEN_FILE, JSON.stringify(Object.assign({}, this.token)));
if (constants_1.DEBUG)
console.log(constants_1.CONSOLE_COLORS.bright + constants_1.CONSOLE_COLORS.fg.yellow + "[AUTHENTICATOR] Current Token written to Storage", constants_1.CONSOLE_COLORS.reset);
}
return __classPrivateFieldGet(this, _Authenticator_token, "f");
return this.token;
});

@@ -141,3 +129,2 @@ }

exports.Authenticator = Authenticator;
_Authenticator_token = new WeakMap();
const TOKEN_FILE = "IYoutubeTokens.json";

@@ -0,0 +0,0 @@ export declare const DEBUG = false;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

@@ -0,0 +0,0 @@ import { ContinuatedList, WrappedHTTPClient } from "../main";

@@ -5,5 +5,7 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

export declare class ContinuatedList {
#private;
results: Array<Video | Channel | Playlist | Comment | CommentThread>;
endReached: boolean;
requestOptions: HTTPRequestOptions;
httpclient: WrappedHTTPClient;
dataprocessor: Function;
continuationToken: string;

@@ -10,0 +12,0 @@ onlyContinuation: boolean;

@@ -11,14 +11,2 @@ "use strict";

};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _ContinuatedList_requestOptions, _ContinuatedList_httpclient, _ContinuatedList_dataprocessor;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -31,10 +19,7 @@ exports.ContinuatedList = void 0;

this.endReached = false;
_ContinuatedList_requestOptions.set(this, void 0);
_ContinuatedList_httpclient.set(this, void 0);
_ContinuatedList_dataprocessor.set(this, void 0);
this.continuationToken = "";
this.onlyContinuation = false;
__classPrivateFieldSet(this, _ContinuatedList_requestOptions, requestOptions, "f");
__classPrivateFieldSet(this, _ContinuatedList_httpclient, httpclient, "f");
__classPrivateFieldSet(this, _ContinuatedList_dataprocessor, dataprocessor, "f");
this.requestOptions = requestOptions;
this.httpclient = httpclient;
this.dataprocessor = dataprocessor;
this.results = new Array();

@@ -48,3 +33,3 @@ if (this.onlyContinuation)

return [];
var joinedData = __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").data;
var joinedData = this.requestOptions.data;
if (!joinedData)

@@ -59,8 +44,8 @@ joinedData = {};

}
var res = yield __classPrivateFieldGet(this, _ContinuatedList_httpclient, "f").request({
method: __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").method,
url: __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").url,
var res = yield this.httpclient.request({
method: this.requestOptions.method,
url: this.requestOptions.url,
data: joinedData,
headers: __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").headers ? __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").headers : {},
params: __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").params ? __classPrivateFieldGet(this, _ContinuatedList_requestOptions, "f").params : {},
headers: this.requestOptions.headers ? this.requestOptions.headers : {},
params: this.requestOptions.params ? this.requestOptions.params : {},
});

@@ -73,4 +58,4 @@ const resJSON = yield JSON.parse(res.data);

this.endReached = true;
let items = yield __classPrivateFieldGet(this, _ContinuatedList_dataprocessor, "f").call(this, resJSON);
items = helpers_1.default.processRendererItems(items, __classPrivateFieldGet(this, _ContinuatedList_httpclient, "f"));
let items = yield this.dataprocessor(resJSON);
items = helpers_1.default.processRendererItems(items, this.httpclient);
this.results = this.results.concat(items);

@@ -100,2 +85,1 @@ return items;

exports.ContinuatedList = ContinuatedList;
_ContinuatedList_requestOptions = new WeakMap(), _ContinuatedList_httpclient = new WeakMap(), _ContinuatedList_dataprocessor = new WeakMap();

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Channel } from "../interfaces/Channel";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../main";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { WrappedHTTPClient } from "../WrappedHTTPClient";

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

/// <reference types="node" />
import { Channel } from "diagnostics_channel";
import { Channel } from "../main";
import { ContinuatedList } from "./ContinuatedList";

@@ -4,0 +3,0 @@ import { Playlist } from "../interfaces/Playlist";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface CaptionTrack {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { ContinuatedList, Thumbnail, ChannelBadge, WrappedHTTPClient } from "../main";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface ChannelBadge {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { Thumbnail } from "../main";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
import { Channel, WrappedHTTPClient } from "../main";
export declare class Comment {
#private;
httpclient: WrappedHTTPClient;

@@ -12,2 +11,6 @@ commentId?: string;

publishedText?: string;
likeActionToken?: string;
dislikeActionToken?: string;
removeLikeActionToken?: string;
removeDislikeActionToken?: string;
canPerformLikeActions?: boolean;

@@ -14,0 +17,0 @@ constructor(httpclient: WrappedHTTPClient);

@@ -11,14 +11,2 @@ "use strict";

};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Comment_likeActionToken, _Comment_dislikeActionToken, _Comment_removeLikeActionToken, _Comment_removeDislikeActionToken;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -32,6 +20,2 @@ exports.Comment = void 0;

constructor(httpclient) {
_Comment_likeActionToken.set(this, void 0);
_Comment_dislikeActionToken.set(this, void 0);
_Comment_removeLikeActionToken.set(this, void 0);
_Comment_removeDislikeActionToken.set(this, void 0);
this.httpclient = httpclient;

@@ -59,10 +43,10 @@ }

if (dislikeButton)
__classPrivateFieldSet(this, _Comment_dislikeActionToken, helpers_1.default.recursiveSearchForKey("action", dislikeButton)[0], "f");
__classPrivateFieldSet(this, _Comment_removeDislikeActionToken, helpers_1.default.recursiveSearchForKey("action", dislikeButton)[1], "f");
this.dislikeActionToken = helpers_1.default.recursiveSearchForKey("action", dislikeButton)[0];
this.removeDislikeActionToken = helpers_1.default.recursiveSearchForKey("action", dislikeButton)[1];
const likeButton = helpers_1.default.recursiveSearchForKey("likeButton", actionButtonContainer);
if (likeButton) {
__classPrivateFieldSet(this, _Comment_likeActionToken, helpers_1.default.recursiveSearchForKey("action", likeButton)[0], "f");
__classPrivateFieldSet(this, _Comment_removeLikeActionToken, helpers_1.default.recursiveSearchForKey("action", likeButton)[1], "f");
this.likeActionToken = helpers_1.default.recursiveSearchForKey("action", likeButton)[0];
this.removeLikeActionToken = helpers_1.default.recursiveSearchForKey("action", likeButton)[1];
}
this.canPerformLikeActions = !(!__classPrivateFieldGet(this, _Comment_dislikeActionToken, "f") && !__classPrivateFieldGet(this, _Comment_likeActionToken, "f"));
this.canPerformLikeActions = !(!this.dislikeActionToken && !this.likeActionToken);
}

@@ -78,3 +62,3 @@ }

data: {
actions: [__classPrivateFieldGet(this, _Comment_likeActionToken, "f")]
actions: [this.likeActionToken]
}

@@ -94,3 +78,3 @@ });

data: {
actions: [__classPrivateFieldGet(this, _Comment_dislikeActionToken, "f")]
actions: [this.dislikeActionToken]
}

@@ -104,8 +88,8 @@ });

return __awaiter(this, void 0, void 0, function* () {
let removeToken = __classPrivateFieldGet(this, _Comment_removeLikeActionToken, "f");
let removeToken = this.removeLikeActionToken;
if (this.hasLiked === true) {
removeToken = __classPrivateFieldGet(this, _Comment_removeLikeActionToken, "f");
removeToken = this.removeLikeActionToken;
}
else if (this.hasLiked === false) {
removeToken = __classPrivateFieldGet(this, _Comment_removeDislikeActionToken, "f");
removeToken = this.removeDislikeActionToken;
}

@@ -128,2 +112,1 @@ else {

exports.Comment = Comment;
_Comment_likeActionToken = new WeakMap(), _Comment_dislikeActionToken = new WeakMap(), _Comment_removeLikeActionToken = new WeakMap(), _Comment_removeDislikeActionToken = new WeakMap();

@@ -0,0 +0,0 @@ import { WrappedHTTPClient, Comment, CommentThreadRepliesContinuatedList } from "../main";

@@ -20,3 +20,1 @@ "use strict";

exports.CommentThread = CommentThread;
"Eg0SC3d0OXk2djdGTkFZGAYyfhpLEhpVZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZyICCAAqGFVDWHVxU0JsSEFFNlh3LXllSkEwVHVudzILd3Q5eTZ2N0ZOQVlAAUgKQi9jb21tZW50LXJlcGxpZXMtaXRlbS1VZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZw%3D%3D";
"Eg0SC3d0OXk2djdGTkFZGAYyswIKsAFHQUl5WGdvOElQYnYzT0hKd19jQ01qRVF0TnlGczdXZTdRSVlfX19fX19fX19fOV9JQUVvQlRBS09oWTVSMVkyYW5GbmQxVklNemxIVmpkVE1WSlZZeTF6RWg0SUJSSWFWV2Q0U0hjM2FVMU5VVTE0YkZobVUwUjFSalJCWVVGQ1FXYzZJQWdCRWh3MU9sVm5lRWgzTjJsTlRWRk5lR3hZWmxORWRVWTBRV0ZCUWtGbhpLEhpVZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZyICCAAqGFVDWHVxU0JsSEFFNlh3LXllSkEwVHVudzILd3Q5eTZ2N0ZOQVlAAUgyKApCL2NvbW1lbnQtcmVwbGllcy1pdGVtLVVneEh3N2lNTVFNeGxYZlNEdUY0QWFBQkFn";

@@ -0,0 +0,0 @@ export interface HTTPClient {

@@ -0,0 +0,0 @@ "use strict";

import { PlaylistContinuatedList } from "../fetchers/PlaylistContinuatedList";
import { Video, Thumbnail, Channel, WrappedHTTPClient } from "../main";
import { Video, Thumbnail, ContinuatedList, Channel, WrappedHTTPClient } from "../main";
export declare class Playlist {
#private;
playlistId?: string;

@@ -18,2 +17,4 @@ title?: string;

httpclient: WrappedHTTPClient;
continuatedList?: ContinuatedList;
likeParam?: string;
constructor(httpclient: WrappedHTTPClient);

@@ -20,0 +21,0 @@ fromPlaylistRenderer(obj: any): void;

@@ -11,14 +11,2 @@ "use strict";

};
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _Playlist_continuatedList, _Playlist_likeParam;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -33,4 +21,2 @@ exports.Playlist = void 0;

constructor(httpclient) {
_Playlist_continuatedList.set(this, void 0);
_Playlist_likeParam.set(this, void 0);
this.httpclient = httpclient;

@@ -101,3 +87,3 @@ }

this.canLike = true;
__classPrivateFieldSet(this, _Playlist_likeParam, helpers_1.default.recursiveSearchForKey("removeLikeParams", likeButtonContainer).join(""), "f");
this.likeParam = helpers_1.default.recursiveSearchForKey("removeLikeParams", likeButtonContainer).join("");
}

@@ -117,6 +103,6 @@ else

getContinuatedList() {
if (__classPrivateFieldGet(this, _Playlist_continuatedList, "f"))
return __classPrivateFieldGet(this, _Playlist_continuatedList, "f");
if (this.continuatedList)
return this.continuatedList;
if (this.playlistId) {
__classPrivateFieldSet(this, _Playlist_continuatedList, new PlaylistContinuatedList_1.PlaylistContinuatedList(this.playlistId, this.httpclient), "f");
this.continuatedList = new PlaylistContinuatedList_1.PlaylistContinuatedList(this.playlistId, this.httpclient);
return this.getContinuatedList();

@@ -128,3 +114,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _Playlist_likeParam, "f") || !this.canLike)
if (!this.likeParam || !this.canLike)
throw new Error("Cannot add or remove Playlist because not all Data is loaded or it is not possible");

@@ -136,3 +122,3 @@ const res = yield this.httpclient.request({

data: {
params: __classPrivateFieldGet(this, _Playlist_likeParam, "f"),
params: this.likeParam,
target: {

@@ -148,3 +134,3 @@ playlistId: this.playlistId

return __awaiter(this, void 0, void 0, function* () {
if (!__classPrivateFieldGet(this, _Playlist_likeParam, "f") || !this.canLike)
if (!this.likeParam || !this.canLike)
throw new Error("Cannot add or remove Playlist because not all Data is loaded or its forbidden");

@@ -156,3 +142,3 @@ const res = yield this.httpclient.request({

data: {
params: __classPrivateFieldGet(this, _Playlist_likeParam, "f"),
params: this.likeParam,
target: {

@@ -168,2 +154,1 @@ playlistId: this.playlistId

exports.Playlist = Playlist;
_Playlist_continuatedList = new WeakMap(), _Playlist_likeParam = new WeakMap();

@@ -0,0 +0,0 @@ export interface StorageAdapter {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ export interface Thumbnail {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread } from "../main";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Authenticator } from "./Authenticator";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Explorer } from "./fetchers/Explorer";

@@ -0,0 +0,0 @@ "use strict";

import { IYoutube } from "./main";
declare const _default: IYoutube;
export default _default;

@@ -0,0 +0,0 @@ "use strict";

import { IYoutube } from "./main";
declare const _default: IYoutube;
export default _default;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { HTTPClient, HTTPMap, HTTPRequestOptions } from "./interfaces/HTTPClient";

@@ -0,0 +0,0 @@ "use strict";

{
"name": "iyoutube",
"version": "0.0.20",
"version": "0.0.21",
"description": "The ultimate unofficial YouTube API Client for Javascript",

@@ -5,0 +5,0 @@ "main": "output/main.js",

@@ -0,0 +0,0 @@ <h1 align="center">IYoutube</h1>

@@ -0,0 +0,0 @@ import { HTTPClient, HTTPRequestOptions } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ import { StorageAdapter } from "../interfaces/StorageAdapter";

@@ -13,3 +13,3 @@ import { CONSOLE_COLORS, DEBUG } from "./constants";

#token:any = {
token:any = {
access: "NULL",

@@ -33,4 +33,4 @@ refresh: "NULL",

if(str) {
this.#token = JSON.parse(str);
if(DEBUG) console.log(CONSOLE_COLORS.bright + CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Now using Token from Storage (expires: " + new Date(this.#token.expireDate).toLocaleString() + ")", CONSOLE_COLORS.reset);
this.token = JSON.parse(str);
if(DEBUG) console.log(CONSOLE_COLORS.bright + CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Now using Token from Storage (expires: " + new Date(this.token.expireDate).toLocaleString() + ")", CONSOLE_COLORS.reset);
}

@@ -41,3 +41,3 @@ }

requiresLogin() {
return Object.values(this.#token).includes("NULL");
return Object.values(this.token).includes("NULL");
}

@@ -79,3 +79,3 @@

this.#token = { type: null, access: null, refresh: res.refresh_token, expireDate: null };
this.token = { type: null, access: null, refresh: res.refresh_token, expireDate: null };
if(DEBUG) console.log(CONSOLE_COLORS.bright + CONSOLE_COLORS.fg.yellow + "[AUTHENTICATOR] Authentication Method successfull: Device Code", CONSOLE_COLORS.reset);

@@ -86,3 +86,3 @@ await this.getToken();

async getToken() {
if(this.#token.access == null || (Date.now() - this.#token.expireDate) > 0) {
if(this.token.access == null || (Date.now() - this.token.expireDate) > 0) {
let res:any = await this.httpClient.request({

@@ -95,12 +95,12 @@ method: HTTPRequestMethod.POST,

grant_type: "refresh_token",
refresh_token: this.#token.refresh
refresh_token: this.token.refresh
})
});
res = JSON.parse(res.data);
this.#token = { type: res.token_type, access: res.access_token, refresh: this.#token.refresh, expireDate: (new Date().getTime() + 1000 * res.expires_in) };
this.token = { type: res.token_type, access: res.access_token, refresh: this.token.refresh, expireDate: (new Date().getTime() + 1000 * res.expires_in) };
if(DEBUG) console.log(CONSOLE_COLORS.bright + CONSOLE_COLORS.fg.green + "[AUTHENTICATOR] Refreshed the Access Token using the refresh Token", CONSOLE_COLORS.reset);
await this.storageAdapter.set(TOKEN_FILE, JSON.stringify({...this.#token }));
await this.storageAdapter.set(TOKEN_FILE, JSON.stringify({...this.token }));
if(DEBUG) console.log(CONSOLE_COLORS.bright + CONSOLE_COLORS.fg.yellow + "[AUTHENTICATOR] Current Token written to Storage", CONSOLE_COLORS.reset);
}
return this.#token;
return this.token;
}

@@ -107,0 +107,0 @@

@@ -0,0 +0,0 @@ export const DEBUG = false;

@@ -0,0 +0,0 @@ import { ENDPOINT_NEXT } from "../constants";

@@ -0,0 +0,0 @@ import { ENDPOINT_NEXT } from "../constants";

@@ -11,5 +11,5 @@ import helpers from "./helpers";

#requestOptions: HTTPRequestOptions;
#httpclient: WrappedHTTPClient;
#dataprocessor: Function;
requestOptions: HTTPRequestOptions;
httpclient: WrappedHTTPClient;
dataprocessor: Function;
continuationToken = "";

@@ -19,5 +19,5 @@ onlyContinuation = false;

constructor(requestOptions: HTTPRequestOptions, dataprocessor: Function, httpclient : WrappedHTTPClient, onlyContinuation?:boolean) {
this.#requestOptions = requestOptions;
this.#httpclient = httpclient;
this.#dataprocessor = dataprocessor;
this.requestOptions = requestOptions;
this.httpclient = httpclient;
this.dataprocessor = dataprocessor;
this.results = new Array();

@@ -29,3 +29,3 @@ if(this.onlyContinuation) this.onlyContinuation = onlyContinuation as boolean;

if(this.endReached) return [];
var joinedData = this.#requestOptions.data;
var joinedData = this.requestOptions.data;
if(!joinedData) joinedData = {};

@@ -39,8 +39,8 @@ if(this.continuationToken != "") {

var res = await this.#httpclient.request({
method: this.#requestOptions.method,
url: this.#requestOptions.url,
var res = await this.httpclient.request({
method: this.requestOptions.method,
url: this.requestOptions.url,
data: joinedData,
headers: this.#requestOptions.headers ? this.#requestOptions.headers : {},
params: this.#requestOptions.params ? this.#requestOptions.params : {},
headers: this.requestOptions.headers ? this.requestOptions.headers : {},
params: this.requestOptions.params ? this.requestOptions.params : {},
});

@@ -53,4 +53,4 @@ const resJSON = await JSON.parse(res.data);

let items = await this.#dataprocessor(resJSON);
items = helpers.processRendererItems(items, this.#httpclient);
let items = await this.dataprocessor(resJSON);
items = helpers.processRendererItems(items, this.httpclient);
this.results = this.results.concat(items);

@@ -57,0 +57,0 @@ return items;

@@ -0,0 +0,0 @@ import { HTTPRequestMethod } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ import { Channel } from "../interfaces/Channel";

@@ -0,0 +0,0 @@ import { HTTPRequestMethod } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ import { HTTPRequestMethod } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ import { HTTPRequestMethod } from "../interfaces/HTTPClient";

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

import { Channel } from "diagnostics_channel";
import { Channel } from "../main";
import { ContinuatedList } from "./ContinuatedList";

@@ -3,0 +3,0 @@ import { HTTPRequestMethod } from "../interfaces/HTTPClient";

@@ -0,0 +0,0 @@ export interface CaptionTrack {

@@ -0,0 +0,0 @@ import { ENDPOINT_BROWSE, ENDPOINT_SUBSCRIBE, ENDPOINT_UNSUBSCRIBE } from "../constants";

@@ -0,0 +0,0 @@ export interface ChannelBadge {

@@ -0,0 +0,0 @@ import { Thumbnail } from "../main";

@@ -17,6 +17,6 @@ import { Channel, WrappedHTTPClient } from "../main";

#likeActionToken?:string;
#dislikeActionToken?:string;
#removeLikeActionToken?:string;
#removeDislikeActionToken?:string;
likeActionToken?:string;
dislikeActionToken?:string;
removeLikeActionToken?:string;
removeDislikeActionToken?:string;
canPerformLikeActions?:boolean;

@@ -54,12 +54,12 @@

if(dislikeButton)
this.#dislikeActionToken = helpers.recursiveSearchForKey("action", dislikeButton)[0];
this.#removeDislikeActionToken = helpers.recursiveSearchForKey("action", dislikeButton)[1];
this.dislikeActionToken = helpers.recursiveSearchForKey("action", dislikeButton)[0];
this.removeDislikeActionToken = helpers.recursiveSearchForKey("action", dislikeButton)[1];
const likeButton = helpers.recursiveSearchForKey("likeButton", actionButtonContainer);
if(likeButton) {
this.#likeActionToken = helpers.recursiveSearchForKey("action", likeButton)[0];
this.#removeLikeActionToken = helpers.recursiveSearchForKey("action", likeButton)[1];
this.likeActionToken = helpers.recursiveSearchForKey("action", likeButton)[0];
this.removeLikeActionToken = helpers.recursiveSearchForKey("action", likeButton)[1];
}
this.canPerformLikeActions = !(!this.#dislikeActionToken && !this.#likeActionToken);
this.canPerformLikeActions = !(!this.dislikeActionToken && !this.likeActionToken);
}

@@ -74,3 +74,3 @@ }

data: {
actions: [this.#likeActionToken]
actions: [this.likeActionToken]
}

@@ -88,3 +88,3 @@ });

data: {
actions: [this.#dislikeActionToken]
actions: [this.dislikeActionToken]
}

@@ -97,7 +97,7 @@ });

async removeLike() {
let removeToken = this.#removeLikeActionToken;
let removeToken = this.removeLikeActionToken;
if(this.hasLiked === true) {
removeToken = this.#removeLikeActionToken;
removeToken = this.removeLikeActionToken;
} else if(this.hasLiked === false) {
removeToken = this.#removeDislikeActionToken;
removeToken = this.removeDislikeActionToken;
} else {

@@ -104,0 +104,0 @@ console.warn("[IYOUTUBE | COMMENT] Removal of Like without knowing if it's present!");

@@ -23,5 +23,2 @@ import helpers from "../fetchers/helpers";

}
}
"Eg0SC3d0OXk2djdGTkFZGAYyfhpLEhpVZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZyICCAAqGFVDWHVxU0JsSEFFNlh3LXllSkEwVHVudzILd3Q5eTZ2N0ZOQVlAAUgKQi9jb21tZW50LXJlcGxpZXMtaXRlbS1VZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZw%3D%3D"
"Eg0SC3d0OXk2djdGTkFZGAYyswIKsAFHQUl5WGdvOElQYnYzT0hKd19jQ01qRVF0TnlGczdXZTdRSVlfX19fX19fX19fOV9JQUVvQlRBS09oWTVSMVkyYW5GbmQxVklNemxIVmpkVE1WSlZZeTF6RWg0SUJSSWFWV2Q0U0hjM2FVMU5VVTE0YkZobVUwUjFSalJCWVVGQ1FXYzZJQWdCRWh3MU9sVm5lRWgzTjJsTlRWRk5lR3hZWmxORWRVWTBRV0ZCUWtGbhpLEhpVZ3hIdzdpTU1RTXhsWGZTRHVGNEFhQUJBZyICCAAqGFVDWHVxU0JsSEFFNlh3LXllSkEwVHVudzILd3Q5eTZ2N0ZOQVlAAUgyKApCL2NvbW1lbnQtcmVwbGllcy1pdGVtLVVneEh3N2lNTVFNeGxYZlNEdUY0QWFBQkFn"
}

@@ -0,0 +0,0 @@ export interface HTTPClient {

@@ -23,4 +23,4 @@ import helpers from "../fetchers/helpers";

#continuatedList?: ContinuatedList;
#likeParam?: string;
continuatedList?: ContinuatedList;
likeParam?: string;

@@ -110,3 +110,3 @@ constructor(httpclient : WrappedHTTPClient) {

this.canLike = true;
this.#likeParam = helpers.recursiveSearchForKey("removeLikeParams", likeButtonContainer).join("");
this.likeParam = helpers.recursiveSearchForKey("removeLikeParams", likeButtonContainer).join("");
} else this.canLike = false;

@@ -125,6 +125,6 @@

getContinuatedList():PlaylistContinuatedList {
if(this.#continuatedList) return this.#continuatedList;
if(this.continuatedList) return this.continuatedList;
if(this.playlistId) {
this.#continuatedList = new PlaylistContinuatedList(this.playlistId, this.httpclient);
this.continuatedList = new PlaylistContinuatedList(this.playlistId, this.httpclient);
return this.getContinuatedList();

@@ -137,3 +137,3 @@ }

async like() {
if(!this.#likeParam || !this.canLike) throw new Error("Cannot add or remove Playlist because not all Data is loaded or it is not possible");
if(!this.likeParam || !this.canLike) throw new Error("Cannot add or remove Playlist because not all Data is loaded or it is not possible");

@@ -145,3 +145,3 @@ const res = await this.httpclient.request({

data: {
params: this.#likeParam,
params: this.likeParam,
target: {

@@ -156,3 +156,3 @@ playlistId: this.playlistId

async removeLike() {
if(!this.#likeParam || !this.canLike) throw new Error("Cannot add or remove Playlist because not all Data is loaded or its forbidden");
if(!this.likeParam || !this.canLike) throw new Error("Cannot add or remove Playlist because not all Data is loaded or its forbidden");

@@ -164,3 +164,3 @@ const res = await this.httpclient.request({

data: {
params: this.#likeParam,
params: this.likeParam,
target: {

@@ -167,0 +167,0 @@ playlistId: this.playlistId

@@ -0,0 +0,0 @@ export interface StorageAdapter {

@@ -0,0 +0,0 @@ export interface Thumbnail {

@@ -0,0 +0,0 @@ import { ENDPOINT_COMMENT_CREATE, ENDPOINT_DISLIKE, ENDPOINT_LIKE, ENDPOINT_NEXT, ENDPOINT_PLAYER, ENDPOINT_REMOVELIKE } from "../constants";

@@ -0,0 +0,0 @@ import { Authenticator } from "./Authenticator";

@@ -0,0 +0,0 @@ import { Explorer } from "./fetchers/Explorer";

@@ -0,0 +0,0 @@ import { NodeFetchClientAdapter } from "./adapters/NodeFetchClientAdapter";

@@ -0,0 +0,0 @@ import { CONSOLE_COLORS, DEBUG, DEFAULT_API_KEY, DEFAULT_CLIENT_NAME, DEFAULT_CLIENT_VERSION, DEFAULT_CONTEXT, DEFAULT_USER_AGENT } from "./constants";

@@ -0,0 +0,0 @@ /* Import Library */

@@ -0,0 +0,0 @@ ## Todo

@@ -0,0 +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