Comparing version 0.0.33 to 0.0.34
@@ -67,2 +67,3 @@ export declare const DEBUG = false; | ||
export declare const ENDPOINT_RATING = "https://returnyoutubedislikeapi.com/Votes"; | ||
export declare const ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS = "https://sponsor.ajay.app/api/skipSegments"; | ||
export declare const ERROR_DATA_INVALID_FORMAT: Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ERROR_DATA_INVALID_FORMAT = exports.ENDPOINT_RATING = exports.ENDPOINT_WATCHPAGE = 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.ERROR_DATA_INVALID_FORMAT = exports.ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS = exports.ENDPOINT_RATING = exports.ENDPOINT_WATCHPAGE = 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; | ||
@@ -70,2 +70,3 @@ exports.DEFAULT_API_KEY = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"; | ||
exports.ENDPOINT_RATING = "https://returnyoutubedislikeapi.com/Votes"; | ||
exports.ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS = "https://sponsor.ajay.app/api/skipSegments"; | ||
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"); |
@@ -266,3 +266,4 @@ "use strict"; | ||
}); | ||
const resJSON = yield JSON.parse(res.data); | ||
if (res.status == 200) | ||
this.subscribed = true; | ||
return res.status == 200; | ||
@@ -284,3 +285,4 @@ }); | ||
}); | ||
const resJSON = yield JSON.parse(res.data); | ||
if (res.status == 200) | ||
this.subscribed = false; | ||
return res.status == 200; | ||
@@ -287,0 +289,0 @@ }); |
@@ -10,2 +10,3 @@ export interface HTTPClient { | ||
url: string; | ||
noCache?: boolean; | ||
} | ||
@@ -12,0 +13,0 @@ export interface HTTPResponse { |
@@ -149,3 +149,4 @@ "use strict"; | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -168,3 +169,4 @@ return res.status == 200; | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -171,0 +173,0 @@ return res.status == 200; |
@@ -1,2 +0,2 @@ | ||
import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread, Format } from "../main"; | ||
import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread, Format, SponsorBlockSegment } from "../main"; | ||
export declare class Video { | ||
@@ -21,3 +21,2 @@ videoId?: any; | ||
canLike?: boolean; | ||
hasLiked?: boolean; | ||
currentUserIsOwner?: boolean; | ||
@@ -28,2 +27,4 @@ commentThreadList?: CommentSectionContinuatedList; | ||
dislikeCount?: number; | ||
likeState?: "NONE" | "DISLIKE" | "LIKE"; | ||
sponsorSegments?: Array<SponsorBlockSegment>; | ||
httpclient: WrappedHTTPClient; | ||
@@ -39,2 +40,3 @@ error: boolean; | ||
loadRatings(): Promise<void>; | ||
loadSponsorSegments(): Promise<never[] | undefined>; | ||
getCommentThreadList(): Promise<ContinuatedList | undefined>; | ||
@@ -41,0 +43,0 @@ like(): Promise<boolean>; |
@@ -166,4 +166,10 @@ "use strict"; | ||
const dislikeButton = buttons[1].toggleButtonRenderer; | ||
if (likeButton && dislikeButton) | ||
this.hasLiked = likeButton.isToggled && !dislikeButton.isToggled; | ||
if (likeButton && dislikeButton) { | ||
if (!likeButton.isToggled && !dislikeButton.isToggled) | ||
this.likeState = "NONE"; | ||
else if (likeButton.isToggled && !dislikeButton.isToggled) | ||
this.likeState = "LIKE"; | ||
else if (!likeButton.isToggled && dislikeButton.isToggled) | ||
this.likeState = "DISLIKE"; | ||
} | ||
if (likeButton) | ||
@@ -187,2 +193,3 @@ this.likeCount = helpers_1.default.getNumberFromText(helpers_1.default.recursiveSearchForKey("simpleText", helpers_1.default.recursiveSearchForKey("defaultText", likeButton)[0]).join("")); | ||
yield this.loadRatings(); | ||
yield this.loadSponsorSegments(); | ||
}); | ||
@@ -255,2 +262,17 @@ } | ||
} | ||
loadSponsorSegments() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const segmentResponse = yield this.httpclient.request({ | ||
url: constants_1.ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS, | ||
method: HTTPClient_1.HTTPRequestMethod.GET, | ||
params: { | ||
videoID: this.videoId | ||
} | ||
}); | ||
if (segmentResponse.status != 200) | ||
return this.sponsorSegments = []; | ||
const segmentJSON = yield JSON.parse(segmentResponse.data); | ||
this.sponsorSegments = segmentJSON; | ||
}); | ||
} | ||
getCommentThreadList() { | ||
@@ -277,5 +299,7 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? true : this.hasLiked; | ||
if (res.status == 200) | ||
this.likeState = "LIKE"; | ||
return res.status == 200; | ||
@@ -295,5 +319,7 @@ }); | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? false : this.hasLiked; | ||
if (res.status == 200) | ||
this.likeState = "DISLIKE"; | ||
return res.status == 200; | ||
@@ -313,5 +339,7 @@ }); | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? undefined : this.hasLiked; | ||
if (res.status == 200) | ||
this.likeState = "NONE"; | ||
return res.status == 200; | ||
@@ -331,3 +359,4 @@ }); | ||
createCommentParams: commentParams | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -334,0 +363,0 @@ const resJSON = JSON.parse(res.data); |
@@ -22,2 +22,3 @@ import { Explorer } from "./fetchers/Explorer"; | ||
import { default as IYoutube } from "./IYoutube"; | ||
import { SponsorBlockSegment } from "./interfaces/SponsorBlockSegment"; | ||
import { HTTPRequestOptions, HTTPRequestMethod, HTTPResponse } from "./interfaces/HTTPClient"; | ||
@@ -48,2 +49,3 @@ export { IYoutube as IYoutube }; | ||
export { HTTPResponse as HTTPResponse }; | ||
export { SponsorBlockSegment as SponsorBlockSegment }; | ||
export declare const nodeDefault: () => Promise<IYoutube>; |
{ | ||
"name": "iyoutube", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"description": "The ultimate unofficial YouTube API Client for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "output/main.js", |
@@ -39,2 +39,3 @@ <h1 align="center">IYoutube</h1> | ||
- @Anarios for the Return-YT-Dislike API (https://github.com/Anarios/return-youtube-dislike) | ||
- @Ajayyy for the Sponsorblock API (https://sponsor.ajay.app/) | ||
@@ -41,0 +42,0 @@ #### Disclaimers |
@@ -71,4 +71,5 @@ export const DEBUG = false; | ||
export const ENDPOINT_RATING = "https://returnyoutubedislikeapi.com/Votes"; | ||
export const ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS = "https://sponsor.ajay.app/api/skipSegments"; | ||
/* 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"); |
@@ -351,3 +351,3 @@ import { ENDPOINT_BROWSE, ENDPOINT_SUBSCRIBE, ENDPOINT_UNSUBSCRIBE } from "../constants"; | ||
}); | ||
const resJSON = await JSON.parse(res.data); | ||
if(res.status == 200) this.subscribed = true; | ||
return res.status == 200; | ||
@@ -368,3 +368,3 @@ } | ||
}); | ||
const resJSON = await JSON.parse(res.data); | ||
if(res.status == 200) this.subscribed = false; | ||
return res.status == 200; | ||
@@ -371,0 +371,0 @@ } |
@@ -11,2 +11,3 @@ export interface HTTPClient { | ||
url: string, | ||
noCache?: boolean | ||
} | ||
@@ -13,0 +14,0 @@ |
@@ -174,3 +174,4 @@ import helpers from "../fetchers/helpers"; | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -192,3 +193,4 @@ return res.status == 200; | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -195,0 +197,0 @@ return res.status == 200; |
@@ -1,4 +0,4 @@ | ||
import { DEFAULT_CLIENT_VERSION, DEFAULT_USER_AGENT, ENDPOINT_COMMENT_CREATE, ENDPOINT_DISLIKE, ENDPOINT_LIKE, ENDPOINT_NEXT, ENDPOINT_PLAYER, ENDPOINT_RATING, ENDPOINT_REMOVELIKE, ENDPOINT_WATCHPAGE } from "../constants"; | ||
import { DEFAULT_CLIENT_VERSION, DEFAULT_USER_AGENT, ENDPOINT_COMMENT_CREATE, ENDPOINT_DISLIKE, ENDPOINT_LIKE, ENDPOINT_NEXT, ENDPOINT_PLAYER, ENDPOINT_RATING, ENDPOINT_REMOVELIKE, ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS, ENDPOINT_WATCHPAGE } from "../constants"; | ||
import helpers from "../fetchers/helpers"; | ||
import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread, Format } from "../main"; | ||
import { CommentSectionContinuatedList, ContinuatedList, WrappedHTTPClient, Channel, Thumbnail, CaptionTrack, CommentThread, Format, SponsorBlockSegment } from "../main"; | ||
import { HTTPRequestMethod } from "./HTTPClient"; | ||
@@ -27,3 +27,2 @@ import * as formatsChipher from "../formatsChipher"; | ||
canLike?: boolean; | ||
hasLiked?: boolean; | ||
currentUserIsOwner?: boolean; | ||
@@ -34,2 +33,4 @@ commentThreadList?: CommentSectionContinuatedList; | ||
dislikeCount?: number; | ||
likeState?: "NONE" | "DISLIKE" | "LIKE"; | ||
sponsorSegments?: Array<SponsorBlockSegment>; | ||
@@ -221,5 +222,9 @@ httpclient: WrappedHTTPClient; | ||
const dislikeButton = buttons[1].toggleButtonRenderer; | ||
if(likeButton && dislikeButton) | ||
this.hasLiked = likeButton.isToggled && !dislikeButton.isToggled; | ||
if(likeButton && dislikeButton) { | ||
if(!likeButton.isToggled && !dislikeButton.isToggled) this.likeState = "NONE"; | ||
else if(likeButton.isToggled && !dislikeButton.isToggled) this.likeState = "LIKE"; | ||
else if(!likeButton.isToggled && dislikeButton.isToggled) this.likeState = "DISLIKE"; | ||
} | ||
if(likeButton) | ||
@@ -246,2 +251,3 @@ this.likeCount = helpers.getNumberFromText(helpers.recursiveSearchForKey("simpleText", helpers.recursiveSearchForKey("defaultText", likeButton)[0]).join("")); | ||
await this.loadRatings(); | ||
await this.loadSponsorSegments(); | ||
} | ||
@@ -321,2 +327,17 @@ | ||
async loadSponsorSegments() { | ||
const segmentResponse = await this.httpclient.request({ | ||
url: ENDPOINT_SPONSORBLOCK_SKIPSEGMENTS, | ||
method: HTTPRequestMethod.GET, | ||
params: { | ||
videoID: this.videoId | ||
} | ||
}); | ||
if(segmentResponse.status != 200) return this.sponsorSegments = []; | ||
const segmentJSON = await JSON.parse(segmentResponse.data); | ||
this.sponsorSegments = segmentJSON; | ||
} | ||
async getCommentThreadList():Promise<ContinuatedList | undefined> { | ||
@@ -339,5 +360,7 @@ if(!this.commentThreadList) { | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? true : this.hasLiked; | ||
if(res.status == 200) this.likeState = "LIKE"; | ||
return res.status == 200; | ||
@@ -355,5 +378,7 @@ } | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? false : this.hasLiked; | ||
if(res.status == 200) this.likeState = "DISLIKE"; | ||
return res.status == 200; | ||
@@ -371,5 +396,8 @@ } | ||
} | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
this.hasLiked = res.status == 200 ? undefined : this.hasLiked; | ||
if(res.status == 200) this.likeState = "NONE"; | ||
return res.status == 200; | ||
@@ -388,3 +416,4 @@ } | ||
createCommentParams: commentParams | ||
} | ||
}, | ||
noCache: true | ||
}); | ||
@@ -391,0 +420,0 @@ const resJSON = JSON.parse(res.data); |
@@ -22,2 +22,3 @@ import { Explorer } from "./fetchers/Explorer"; | ||
import { default as IYoutube } from "./IYoutube"; | ||
import { SponsorBlockSegment } from "./interfaces/SponsorBlockSegment"; | ||
import { HTTPRequestOptions, HTTPRequestMethod, HTTPResponse } from "./interfaces/HTTPClient"; | ||
@@ -52,2 +53,3 @@ | ||
export { HTTPResponse as HTTPResponse } | ||
export { SponsorBlockSegment as SponsorBlockSegment } | ||
@@ -54,0 +56,0 @@ //Skips Webpack checks |
244376
112
4933
46