Comparing version 0.0.27 to 0.0.28
@@ -64,2 +64,3 @@ export declare const DEBUG = false; | ||
export declare const ENDPOINT_COMMENT_CREATE = "https://www.youtube.com/youtubei/v1/comment/create_comment"; | ||
export declare const ENDPOINT_SEARCH_SUGGEST = "https://clients1.google.com/complete/search"; | ||
export declare const ERROR_DATA_INVALID_FORMAT: Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ERROR_DATA_INVALID_FORMAT = exports.ENDPOINT_COMMENT_CREATE = exports.ENDPOINT_PLAYER = exports.ENDPOINT_COMMENT_ACTION = exports.ENDPOINT_NEXT = exports.ENDPOINT_ADDTOPLAYLIST = exports.ENDPOINT_UNSUBSCRIBE = exports.ENDPOINT_SUBSCRIBE = exports.ENDPOINT_REMOVELIKE = exports.ENDPOINT_DISLIKE = exports.ENDPOINT_LIKE = exports.ENDPOINT_SEARCH = exports.ENDPOINT_BROWSE = exports.CONSOLE_COLORS = exports.DEFAULT_CONTEXT = exports.DEFAULT_USER_AGENT = exports.DEFAULT_CLIENT_NAME = exports.DEFAULT_CLIENT_VERSION = exports.DEFAULT_API_KEY = exports.DEBUG = void 0; | ||
exports.ERROR_DATA_INVALID_FORMAT = exports.ENDPOINT_SEARCH_SUGGEST = exports.ENDPOINT_COMMENT_CREATE = exports.ENDPOINT_PLAYER = exports.ENDPOINT_COMMENT_ACTION = exports.ENDPOINT_NEXT = exports.ENDPOINT_ADDTOPLAYLIST = exports.ENDPOINT_UNSUBSCRIBE = exports.ENDPOINT_SUBSCRIBE = exports.ENDPOINT_REMOVELIKE = exports.ENDPOINT_DISLIKE = exports.ENDPOINT_LIKE = exports.ENDPOINT_SEARCH = exports.ENDPOINT_BROWSE = exports.CONSOLE_COLORS = exports.DEFAULT_CONTEXT = exports.DEFAULT_USER_AGENT = exports.DEFAULT_CLIENT_NAME = exports.DEFAULT_CLIENT_VERSION = exports.DEFAULT_API_KEY = exports.DEBUG = void 0; | ||
exports.DEBUG = false; | ||
@@ -67,2 +67,3 @@ exports.DEFAULT_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"; | ||
exports.ENDPOINT_COMMENT_CREATE = "https://www.youtube.com/youtubei/v1/comment/create_comment"; | ||
exports.ENDPOINT_SEARCH_SUGGEST = "https://clients1.google.com/complete/search"; | ||
exports.ERROR_DATA_INVALID_FORMAT = new Error("The Data recieved from the Google API seems to have an invalid format. It might be that Google updated their APIs and this Method no longer Works"); |
@@ -10,2 +10,7 @@ import { Channel } from "../interfaces/Channel"; | ||
declare function processRendererItems(arr: Array<any>, httpclient: WrappedHTTPClient): (Video | Channel | Playlist | Comment | CommentThread | undefined)[]; | ||
export declare function getVideoDefaultThumbnail(videoId: string): { | ||
url: string; | ||
height: number; | ||
width: number; | ||
}; | ||
declare const _default: { | ||
@@ -16,3 +21,4 @@ recursiveSearchForPair: typeof recursiveSearchForPair; | ||
processRendererItems: typeof processRendererItems; | ||
getVideoDefaultThumbnail: typeof getVideoDefaultThumbnail; | ||
}; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getVideoDefaultThumbnail = void 0; | ||
const Channel_1 = require("../interfaces/Channel"); | ||
@@ -114,2 +115,10 @@ const Playlist_1 = require("../interfaces/Playlist"); | ||
} | ||
function getVideoDefaultThumbnail(videoId) { | ||
return { | ||
url: "https://i.ytimg.com/vi/" + videoId + "/maxresdefault.jpg", | ||
height: 1, | ||
width: 1 | ||
}; | ||
} | ||
exports.getVideoDefaultThumbnail = getVideoDefaultThumbnail; | ||
exports.default = { | ||
@@ -119,3 +128,4 @@ recursiveSearchForPair: recursiveSearchForPair, | ||
getNumberFromText: getNumberFromText, | ||
processRendererItems: processRendererItems | ||
processRendererItems: processRendererItems, | ||
getVideoDefaultThumbnail: getVideoDefaultThumbnail, | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { ContinuatedList, Thumbnail, Badge, WrappedHTTPClient } from "../main"; | ||
import { ContinuatedList, Thumbnail, Badge, Video, WrappedHTTPClient } from "../main"; | ||
import { ChannelLink } from "./ChannelLink"; | ||
@@ -22,2 +22,3 @@ export declare class Channel { | ||
otherChannels?: Array<Channel>; | ||
featuredVideo?: Video; | ||
httpclient: WrappedHTTPClient; | ||
@@ -35,2 +36,3 @@ constructor(httpclient: WrappedHTTPClient); | ||
loadAll(): Promise<void>; | ||
loadDetailsFromOverviewPage(): Promise<void>; | ||
loadDetailsFromAboutPage(): Promise<void>; | ||
@@ -37,0 +39,0 @@ loadDetailsFromChannelsPages(): Promise<void>; |
@@ -132,2 +132,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.loadDetailsFromOverviewPage(); | ||
yield this.loadDetailsFromAboutPage(); | ||
@@ -137,2 +138,30 @@ yield this.loadDetailsFromChannelsPages(); | ||
} | ||
loadDetailsFromOverviewPage() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const channelOverview = yield this.httpclient.request({ | ||
method: HTTPClient_1.HTTPRequestMethod.POST, | ||
url: constants_1.ENDPOINT_BROWSE, | ||
data: { | ||
browseId: this.channelId, | ||
} | ||
}); | ||
const overviewJSON = yield JSON.parse(channelOverview.data); | ||
__classPrivateFieldGet(this, _Channel_instances, "m", _Channel_parseC4FromHeader).call(this, overviewJSON); | ||
let overviewTabRenderer = helpers_1.default.recursiveSearchForKey("tabRenderer", overviewJSON); | ||
overviewTabRenderer = overviewTabRenderer.find((a) => a.title.toLowerCase() == "home"); | ||
const featuredRenderer = helpers_1.default.recursiveSearchForKey("channelFeaturedContentRenderer", overviewTabRenderer)[0]; | ||
if (featuredRenderer) { | ||
const videoRenderer = helpers_1.default.recursiveSearchForKey("videoRenderer", featuredRenderer)[0]; | ||
if (videoRenderer) { | ||
this.featuredVideo = new main_1.Video(this.httpclient); | ||
this.featuredVideo.fromVideoRenderer(videoRenderer); | ||
} | ||
} | ||
const videoPlayerRenderer = helpers_1.default.recursiveSearchForKey("channelVideoPlayerRenderer", overviewTabRenderer)[0]; | ||
if (videoPlayerRenderer) { | ||
this.featuredVideo = new main_1.Video(this.httpclient); | ||
this.featuredVideo.fromVideoPlayerRenderer(videoPlayerRenderer); | ||
} | ||
}); | ||
} | ||
loadDetailsFromAboutPage() { | ||
@@ -139,0 +168,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -28,2 +28,3 @@ import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread } from "../main"; | ||
fromVideoRenderer(obj: any): void; | ||
fromVideoPlayerRenderer(obj: any): void; | ||
fromGridRenderer(obj: any): void; | ||
@@ -30,0 +31,0 @@ fromPlaylistVideoRenderer(obj: any): void; |
@@ -47,3 +47,3 @@ "use strict"; | ||
if (timeTextContainer) | ||
this.publishedText = helpers_1.default.recursiveSearchForKey("simpleText", timeTextContainer)[0]; | ||
this.publishedText = helpers_1.default.recursiveSearchForKey("simpleText", timeTextContainer).join(""); | ||
if (helpers_1.default.recursiveSearchForKey("ownerText", obj).length > 0) { | ||
@@ -54,2 +54,13 @@ this.owner = new main_1.Channel(this.httpclient); | ||
} | ||
fromVideoPlayerRenderer(obj) { | ||
this.fromVideoRenderer(obj); | ||
const timeTextContainer = helpers_1.default.recursiveSearchForKey("publishedTimeText", obj)[0]; | ||
if (timeTextContainer) | ||
this.publishedText = helpers_1.default.recursiveSearchForKey("text", timeTextContainer).join(""); | ||
const descriptionContainer = helpers_1.default.recursiveSearchForKey("description", obj)[0]; | ||
if (descriptionContainer) { | ||
this.description = helpers_1.default.recursiveSearchForKey("text", descriptionContainer).join(""); | ||
} | ||
this.thumbnails = [helpers_1.default.getVideoDefaultThumbnail(this.videoId)]; | ||
} | ||
fromGridRenderer(obj) { | ||
@@ -56,0 +67,0 @@ this.fromVideoRenderer(obj); |
@@ -10,3 +10,3 @@ import { Authenticator } from "./Authenticator"; | ||
import { Playlist } from "./interfaces/Playlist"; | ||
import { Channel, Video } from "./main"; | ||
import { Channel, SearchProposal, Video } from "./main"; | ||
export default class IYoutube { | ||
@@ -22,2 +22,3 @@ rawHttpClient: HTTPClient; | ||
search(term: string, type: SearchType): Promise<ContinuatedList>; | ||
searchProposals(term: string): Promise<Array<SearchProposal>>; | ||
getPlaylist(playlistId: string): Promise<Playlist>; | ||
@@ -24,0 +25,0 @@ getChannel(channelId: string): Promise<Channel>; |
@@ -47,2 +47,20 @@ "use strict"; | ||
} | ||
searchProposals(term) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.throwErrorIfNotReady(); | ||
const url = new URL(constants_1.ENDPOINT_SEARCH_SUGGEST); | ||
url.searchParams.set("client", "youtube"); | ||
url.searchParams.set("gs_ri", "youtube"); | ||
url.searchParams.set("ds", "yt"); | ||
url.searchParams.set("q", term); | ||
const result = yield this.rawHttpClient.request({ | ||
url: url.toString(), | ||
method: HTTPClient_1.HTTPRequestMethod.GET, | ||
}); | ||
const resultJSONText = result.data.split("(")[1].split(")")[0]; | ||
const resultsJSON = yield JSON.parse(resultJSONText)[1]; | ||
const finalResults = resultsJSON.map((a) => ({ text: a[0] })); | ||
return finalResults; | ||
}); | ||
} | ||
getPlaylist(playlistId) { | ||
@@ -49,0 +67,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -19,2 +19,3 @@ import { Explorer } from "./fetchers/Explorer"; | ||
import { List } from "./interfaces/List"; | ||
import { SearchProposal } from "./interfaces/SearchProposal"; | ||
import { default as IYoutube } from "./IYoutube"; | ||
@@ -40,2 +41,3 @@ export { IYoutube as IYoutube }; | ||
export { List as List }; | ||
export { SearchProposal as SearchProposal }; | ||
export declare const nodeDefault: () => Promise<IYoutube>; |
{ | ||
"name": "iyoutube", | ||
"version": "0.0.27", | ||
"version": "0.0.28", | ||
"description": "The ultimate unofficial YouTube API Client for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "output/main.js", |
@@ -68,4 +68,5 @@ export const DEBUG = false; | ||
export const ENDPOINT_COMMENT_CREATE = "https://www.youtube.com/youtubei/v1/comment/create_comment"; | ||
export const ENDPOINT_SEARCH_SUGGEST = "https://clients1.google.com/complete/search"; | ||
/* Error */ | ||
export const ERROR_DATA_INVALID_FORMAT = new Error("The Data recieved from the Google API seems to have an invalid format. It might be that Google updated their APIs and this Method no longer Works"); |
@@ -127,2 +127,9 @@ import { Channel } from "../interfaces/Channel"; | ||
export function getVideoDefaultThumbnail(videoId:string) { | ||
return { | ||
url: "https://i.ytimg.com/vi/" + videoId + "/maxresdefault.jpg", | ||
height: 1, | ||
width: 1 | ||
} | ||
} | ||
export default { | ||
@@ -132,3 +139,4 @@ recursiveSearchForPair: recursiveSearchForPair, | ||
getNumberFromText: getNumberFromText, | ||
processRendererItems: processRendererItems | ||
processRendererItems: processRendererItems, | ||
getVideoDefaultThumbnail: getVideoDefaultThumbnail, | ||
} |
import { ENDPOINT_BROWSE, ENDPOINT_SUBSCRIBE, ENDPOINT_UNSUBSCRIBE } from "../constants"; | ||
import { ContinuatedList, Thumbnail, Badge, WrappedHTTPClient } from "../main"; | ||
import { ContinuatedList, Thumbnail, Badge, Video, WrappedHTTPClient } from "../main"; | ||
import helpers from "../fetchers/helpers" | ||
@@ -26,2 +26,3 @@ import { HTTPRequestMethod } from "./HTTPClient"; | ||
otherChannels?: Array<Channel>; | ||
featuredVideo?: Video; | ||
@@ -165,2 +166,3 @@ httpclient: WrappedHTTPClient; | ||
async loadAll() { | ||
await this.loadDetailsFromOverviewPage(); | ||
await this.loadDetailsFromAboutPage(); | ||
@@ -170,2 +172,32 @@ await this.loadDetailsFromChannelsPages(); | ||
async loadDetailsFromOverviewPage() { | ||
const channelOverview = await this.httpclient.request({ | ||
method: HTTPRequestMethod.POST, | ||
url: ENDPOINT_BROWSE, | ||
data: { | ||
browseId: this.channelId, | ||
} | ||
}); | ||
const overviewJSON = await JSON.parse(channelOverview.data); | ||
this.#parseC4FromHeader(overviewJSON); | ||
let overviewTabRenderer = helpers.recursiveSearchForKey("tabRenderer", overviewJSON); | ||
overviewTabRenderer = overviewTabRenderer.find((a:any) => a.title.toLowerCase() == "home"); | ||
const featuredRenderer = helpers.recursiveSearchForKey("channelFeaturedContentRenderer", overviewTabRenderer)[0]; | ||
if(featuredRenderer) { | ||
const videoRenderer = helpers.recursiveSearchForKey("videoRenderer", featuredRenderer)[0]; | ||
if(videoRenderer) { | ||
this.featuredVideo = new Video(this.httpclient); | ||
this.featuredVideo.fromVideoRenderer(videoRenderer); | ||
} | ||
} | ||
const videoPlayerRenderer = helpers.recursiveSearchForKey("channelVideoPlayerRenderer", overviewTabRenderer)[0]; | ||
if(videoPlayerRenderer) { | ||
this.featuredVideo = new Video(this.httpclient); | ||
this.featuredVideo.fromVideoPlayerRenderer(videoPlayerRenderer); | ||
} | ||
} | ||
async loadDetailsFromAboutPage() { | ||
@@ -172,0 +204,0 @@ const channelAbout = await this.httpclient.request({ |
@@ -76,3 +76,3 @@ import { ENDPOINT_COMMENT_CREATE, ENDPOINT_DISLIKE, ENDPOINT_LIKE, ENDPOINT_NEXT, ENDPOINT_PLAYER, ENDPOINT_REMOVELIKE } from "../constants"; | ||
if(timeTextContainer) | ||
this.publishedText = helpers.recursiveSearchForKey("simpleText", timeTextContainer)[0]; | ||
this.publishedText = helpers.recursiveSearchForKey("simpleText", timeTextContainer).join(""); | ||
@@ -85,2 +85,17 @@ if(helpers.recursiveSearchForKey("ownerText", obj).length > 0) { | ||
fromVideoPlayerRenderer(obj: any) { | ||
this.fromVideoRenderer(obj); | ||
const timeTextContainer = helpers.recursiveSearchForKey("publishedTimeText", obj)[0]; | ||
if(timeTextContainer) | ||
this.publishedText = helpers.recursiveSearchForKey("text", timeTextContainer).join(""); | ||
const descriptionContainer = helpers.recursiveSearchForKey("description", obj)[0]; | ||
if(descriptionContainer) { | ||
this.description = helpers.recursiveSearchForKey("text", descriptionContainer).join(""); | ||
} | ||
this.thumbnails = [helpers.getVideoDefaultThumbnail(this.videoId)]; | ||
} | ||
fromGridRenderer(obj:any) { | ||
@@ -87,0 +102,0 @@ /* Structure is nearly same */ |
@@ -11,4 +11,4 @@ import { Authenticator } from "./Authenticator"; | ||
import { Playlist } from "./interfaces/Playlist"; | ||
import { DEBUG, ENDPOINT_BROWSE } from "./constants"; | ||
import { Channel, Video } from "./main"; | ||
import { DEBUG, ENDPOINT_BROWSE, ENDPOINT_SEARCH_SUGGEST } from "./constants"; | ||
import { Channel, SearchProposal, Video } from "./main"; | ||
import helpers from "./fetchers/helpers"; | ||
@@ -50,2 +50,21 @@ | ||
async searchProposals(term: string):Promise<Array<SearchProposal>> { | ||
this.throwErrorIfNotReady(); | ||
const url = new URL(ENDPOINT_SEARCH_SUGGEST); | ||
url.searchParams.set("client", "youtube"); | ||
url.searchParams.set("gs_ri", "youtube"); | ||
url.searchParams.set("ds", "yt"); | ||
url.searchParams.set("q", term); | ||
const result = await this.rawHttpClient.request({ | ||
url: url.toString(), | ||
method: HTTPRequestMethod.GET, | ||
}); | ||
const resultJSONText = result.data.split("(")[1].split(")")[0]; | ||
const resultsJSON = await JSON.parse(resultJSONText)[1]; | ||
const finalResults = resultsJSON.map((a:any) => ({ text: a[0] })); | ||
return finalResults; | ||
} | ||
async getPlaylist(playlistId: string):Promise<Playlist> { | ||
@@ -52,0 +71,0 @@ this.throwErrorIfNotReady(); |
@@ -19,2 +19,3 @@ import { Explorer } from "./fetchers/Explorer"; | ||
import { List } from "./interfaces/List"; | ||
import { SearchProposal } from "./interfaces/SearchProposal"; | ||
import { default as IYoutube } from "./IYoutube"; | ||
@@ -44,2 +45,3 @@ | ||
export { List as List } | ||
export { SearchProposal as SearchProposal } | ||
@@ -46,0 +48,0 @@ //Skips Webpack checks |
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
222069
103
4467