avallete / yt-playlists-delete-enhancer

Add a button to remove videos watched with more than X percent from watch later playlist.
MIT License
17 stars 3 forks source link

Fix YouTube API requests #275

Closed dnicolson closed 3 months ago

dnicolson commented 4 months ago

Description

This replaces the YouTube API calls with functionality from https://github.com/LuanRT/YouTube.js.

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

Checklist:

Closing issues

Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).

codecov-commenter commented 4 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (0793980) to head (776bfc9). Report is 1 commits behind head on master.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/avallete/yt-playlists-delete-enhancer/pull/275/graphs/tree.svg?width=650&height=150&src=pr&token=MKKCMIN1VU&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau)](https://app.codecov.io/gh/avallete/yt-playlists-delete-enhancer/pull/275?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau) ```diff @@ Coverage Diff @@ ## master #275 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 8 8 Lines 52 52 Branches 7 7 ========================================= Hits 52 52 ``` ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/avallete/yt-playlists-delete-enhancer/pull/275?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/avallete/yt-playlists-delete-enhancer/pull/275?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau). Last update [1261110...776bfc9](https://app.codecov.io/gh/avallete/yt-playlists-delete-enhancer/pull/275?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Andrew+Valleteau).
dnicolson commented 3 months ago

Hi @avallete, if this gets merged, further optimizations like this are possible:

const youtube = await Innertube.create({
  cookie: document.cookie,
  fetch: (...args) => fetch(...args),
})

let playlist = await youtube.getPlaylist(playlistName);
let videoIds = playlist.videos.map(video => video.id);

while (playlist.has_continuation) {
  playlist = await playlist.getContinuation();
  videoIds = videoIds.concat(playlist.videos.map(video => video.id));
}

console.log(videoIds);
avallete commented 3 months ago

Hi @avallete, if this gets merged, further optimizations like this are possible:

const youtube = await Innertube.create({
  cookie: document.cookie,
  fetch: (...args) => fetch(...args),
})

let playlist = await youtube.getPlaylist(playlistName);
let videoIds = playlist.videos.map(video => video.id);

while (playlist.has_continuation) {
  playlist = await playlist.getContinuation();
  videoIds = videoIds.concat(playlist.videos.map(video => video.id));
}

console.log(videoIds);

Nice ! Looks good !