Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ytmusic): Add support for YouTube Music mood filters #404

Merged
merged 5 commits into from
May 23, 2023

Conversation

Buroni
Copy link
Contributor

@Buroni Buroni commented May 16, 2023

Fixes #297

Proposed changes

  • Add filters property and applyFilter method to ytmusic.HomeFeed, which allows results to be filtered by mood.

Testing

import { Innertube } from "youtubei.js";

const yt = await Innertube.create();

const home = await yt.music.getHomeFeed();

console.log(home.filters); // [ 'Workout', 'Relax', 'Energize', 'Commute', 'Focus' ]

console.log(await home.applyFilter('Relax')); // instance of `HomeFeed`

Notes

HomeFeed.applyFilter is almost exactly the same as Search.applyFilter. I'd like to avoid this code duplication by using an inherited base class in the ytmusic classes. I think this would also provide some structure to the classes in this directory, as they implement the same kinds of methods e.g. has_continuation, getContinuation, applyFilter, filters... However I didn't want to make an invasive change without discussion.

@Buroni Buroni changed the title Add support for YouTube Music mood filters feat(ytmusic): Add support for YouTube Music mood filters May 16, 2023
@LuanRT
Copy link
Owner

LuanRT commented May 20, 2023

HomeFeed.applyFilter is almost exactly the same as Search.applyFilter. I'd like to avoid this code duplication by using an inherited base class in the ytmusic classes. I think this would also provide some structure to the classes in this directory, as they implement the same kinds of methods e.g. has_continuation, getContinuation, applyFilter, filters... However I didn't want to make an invasive change without discussion.

This sounds great. But maybe it should be done in a separate PR? Also, there's already a class that does that for YouTube feeds (https://github.com/LuanRT/YouTube.js/blob/main/src/core/mixins/FilterableFeed.ts). But we don't use it for YouTube Music because there are a few differences that we'd have to account for.

@Buroni
Copy link
Contributor Author

Buroni commented May 21, 2023

@LuanRT Yep agreed it should be in a separate PR!

@LuanRT LuanRT merged commit 77b39c7 into LuanRT:main May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for YouTube Music mood filters
2 participants