refactor!: finish parser migration

Finally! :)

This removes all code related to the old parser.

#65
This commit is contained in:
LuanRT
2022-07-11 06:19:10 -03:00
parent 947fd7895b
commit 68cb841c00
285 changed files with 492 additions and 1680 deletions

View File

@@ -19,6 +19,7 @@ const NotificationsMenu = require('./parser/youtube/NotificationsMenu');
const YTMusic = require('./core/Music');
const FilterableFeed = require('./core/FilterableFeed');
const TabbedFeed = require('./core/TabbedFeed');
const Feed = require('./core/Feed');
const EventEmitter = require('events');
const { PassThrough } = BROWSER ? require('stream-browserify') : require('stream');
@@ -32,7 +33,6 @@ const {
generateRandomString
} = require('./utils/Utils');
const OldParser = require('./parser');
const Proto = require('./proto');
/** @namespace */
@@ -51,7 +51,7 @@ class Innertube {
* @param {string} [config.cookie]
* @param {boolean} [config.debug]
* @param {object} [config.proxy]
* @param {object} [config.http_ent]
* @param {object} [config.http_agent]
* @param {object} [config.https_agent]
*/
constructor(config) {
@@ -107,7 +107,6 @@ class Innertube {
/**
* Signs in to a google account.
*
* @param {object} credentials
* @param {string} credentials.access_token - Token used to sign in.
* @param {string} credentials.refresh_token - Token used to get a new access token.
@@ -133,7 +132,6 @@ class Innertube {
/**
* Signs out of an account.
*
* @returns {Promise.<{ success: boolean, status_code: number }>}
*/
async signOut() {
@@ -148,7 +146,6 @@ class Innertube {
/**
* Retrieves video info.
*
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
@@ -165,7 +162,6 @@ class Innertube {
/**
* Retrieves basic video info.
*
* @param {string} video_id
* @returns {Promise.<VideoInfo>}
*/
@@ -179,7 +175,6 @@ class Innertube {
/**
* Searches a given query.
*
* @param {string} query - search query.
* @param {object} [filters] - search filters.
* @param {string} [filters.upload_date] - filter videos by upload date, can be: any | last_hour | today | this_week | this_month | this_year
@@ -224,7 +219,6 @@ class Innertube {
/**
* Retrieves comments for a video.
*
* @param {string} video_id - the video id.
* @param {string} [sort_by] - can be: `TOP_COMMENTS` or `NEWEST_FIRST`.
* @returns {Promise.<Comments>}
@@ -243,7 +237,6 @@ class Innertube {
/**
* Retrieves YouTube's home feed (aka recommendations).
*
* @returns {Promise<FilterableFeed>}
*/
async getHomeFeed() {
@@ -253,7 +246,6 @@ class Innertube {
/**
* Returns the account's library.
*
* @returns {Promise.<Library>}
*/
async getLibrary() {
@@ -263,8 +255,7 @@ class Innertube {
/**
* Retrieves watch history.
* Which can also be achieved through {@link getLibrary()}.
*
* Which can also be achieved with {@link getLibrary()}.
* @returns {Promise.<History>}
*/
async getHistory() {
@@ -274,7 +265,6 @@ class Innertube {
/**
* Retrieves trending content.
*
* @returns {Promise<TabbedFeed>}
*/
async getTrending() {
@@ -284,23 +274,15 @@ class Innertube {
/**
* Retrieves subscriptions feed.
*
* @returns {Promise.<{ items: Array.<{ date: string, videos: object[] }>}>}
* @returns {Promise.<Feed>}
*/
async getSubscriptionsFeed() {
const response = await this.actions.browse('FEsubscriptions');
const subsfeed = new OldParser(this, response, {
client: 'YOUTUBE',
data_type: 'SUBSFEED'
}).parse();
return subsfeed;
return new Feed(this.actions, response.data);
}
/**
* Retrieves contents for a given channel. (WIP)
*
* Retrieves contents for a given channel.
* @param {string} id - channel id
* @returns {Promise<Channel>}
*/
@@ -312,7 +294,6 @@ class Innertube {
/**
* Retrieves notifications.
*
* @returns {Promise.<NotificationsMenu>}
*/
async getNotifications() {
@@ -322,7 +303,6 @@ class Innertube {
/**
* Retrieves unseen notifications count.
*
* @returns {Promise.<number>}
*/
async getUnseenNotificationsCount() {
@@ -332,7 +312,6 @@ class Innertube {
/**
* Retrieves the contents of a given playlist.
*
* @param {string} playlist_id - the id of the playlist.
* @returns {Promise.<Playlist>}
*/