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(Channel): add support for sorting the playlist tab #295

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

LuanRT
Copy link
Owner

@LuanRT LuanRT commented Jan 27, 2023

Description

Adds support for sorting the playlist tab, see #290 for more details.

Usage

import { Innertube, UniversalCache } from 'youtubei.js';

(async () => {
  const yt = await Innertube.create({ cache: new UniversalCache(), generate_session_locally: true });

  const channel = await yt.getChannel('UCez-2shYlHQY3LfILBuDYqQ');

  let playlists_tab = await channel.getPlaylists();

  /**
   * Channels such as UCez-2shYlHQY3LfILBuDYqQ have their playlists organized into various categories. 
   * In this case, sorting is only possible after a category is selected.
   */
  if (!playlists_tab.memo.has('SortFilterSubMenu')) {
    console.info('Content type filters:', playlists_tab.content_type_filters);
    playlists_tab = await playlists_tab.applyContentTypeFilter('Created playlists');
  }

  console.info('Sort filters:', playlists_tab.sort_filters);

  const sorted_playlist_tab = await playlists_tab.applySort('Last video added');

  console.log(sorted_playlist_tab);
})();

Closes #290.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings

@LuanRT LuanRT added the enhancement New feature or request label Jan 27, 2023
@LuanRT LuanRT merged commit 50ef712 into main Jan 27, 2023
@LuanRT LuanRT deleted the feat/channel-playlist-sorting branch January 27, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for sorting the channel playlists tab
1 participant