mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-11 22:17:21 +03:00
Removed use of Invidious API.
Resolves https://github.com/ajayyy/SponsorBlock/issues/189.
This commit is contained in:
@@ -68,7 +68,7 @@ The result is in `dist`.
|
|||||||
|
|
||||||
# Credit
|
# Credit
|
||||||
|
|
||||||
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) is used to grab the time the video was published.
|
The awesome [Invidious API](https://github.com/omarroth/invidious/wiki/API) used to be used.
|
||||||
|
|
||||||
Original code from [YTSponsorSkip](https://github.com/OfficialNoob/YTSponsorSkip), but not much of the code is left.
|
Original code from [YTSponsorSkip](https://github.com/OfficialNoob/YTSponsorSkip), but not much of the code is left.
|
||||||
|
|
||||||
|
|||||||
@@ -444,12 +444,19 @@ function sponsorsLookup(id: string, channelIDPromise?) {
|
|||||||
|
|
||||||
//check if this video was uploaded recently
|
//check if this video was uploaded recently
|
||||||
//use the invidious api to get the time published
|
//use the invidious api to get the time published
|
||||||
sendRequestToCustomServer('GET', "https://invidio.us/api/v1/videos/" + id + '?fields=published', function(xmlhttp, error) {
|
sendRequestToCustomServer('GET', "https://www.youtube.com/get_video_info?video_id=" + id, function(xmlhttp, error) {
|
||||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
let unixTimePublished = JSON.parse(xmlhttp.responseText).published;
|
let decodedData = decodeURIComponent(xmlhttp.responseText).match(/(?<=player_response=)[^&]*/)[0];
|
||||||
|
|
||||||
|
if (decodedData === undefined) {
|
||||||
|
console.error("[SB] Failed at getting video upload date info from YouTube.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dateUploaded = JSON.parse(decodedData).microformat.playerMicroformatRenderer.uploadDate;
|
||||||
|
|
||||||
//if less than 3 days old
|
//if less than 3 days old
|
||||||
if ((Date.now() / 1000) - unixTimePublished < 259200) {
|
if (Date.now() - new Date(dateUploaded).getTime() < 259200000) {
|
||||||
//TODO lower when server becomes better
|
//TODO lower when server becomes better
|
||||||
setTimeout(() => sponsorsLookup(id, channelIDPromise), 180000);
|
setTimeout(() => sponsorsLookup(id, channelIDPromise), 180000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user