mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 01:01:55 +01:00
Removed use of Invidious API.
Resolves https://github.com/ajayyy/SponsorBlock/issues/189.
This commit is contained in:
parent
2450457fe5
commit
657aff2167
2 changed files with 11 additions and 4 deletions
|
@ -68,7 +68,7 @@ The result is in `dist`.
|
|||
|
||||
# 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.
|
||||
|
||||
|
|
|
@ -444,12 +444,19 @@ function sponsorsLookup(id: string, channelIDPromise?) {
|
|||
|
||||
//check if this video was uploaded recently
|
||||
//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) {
|
||||
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 ((Date.now() / 1000) - unixTimePublished < 259200) {
|
||||
if (Date.now() - new Date(dateUploaded).getTime() < 259200000) {
|
||||
//TODO lower when server becomes better
|
||||
setTimeout(() => sponsorsLookup(id, channelIDPromise), 180000);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue