Skip to content

Commit

Permalink
chore: Clean up so unneeded private properties (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored Dec 1, 2023
1 parent b60930a commit b50e200
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/core/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { FetchFunction } from '../types/PlatformShim.js';
*/
export default class Player {
#nsig_sc;
#nsig_cache;
#sig_sc;
#sig_sc_timestamp;
#player_id;
Expand All @@ -22,8 +21,6 @@ export default class Player {
this.#sig_sc_timestamp = signature_timestamp;

this.#player_id = player_id;

this.#nsig_cache = new Map<string, string>();
}

static async create(cache: ICache | undefined, fetch: FetchFunction = Platform.shim.fetch): Promise<Player> {
Expand Down
16 changes: 7 additions & 9 deletions src/parser/classes/misc/Author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import type TextRun from './TextRun.js';
import Thumbnail from './Thumbnail.js';

export default class Author {
#nav_text;

id: string;
name: string;
thumbnails: Thumbnail[];
Expand All @@ -21,22 +19,22 @@ export default class Author {
url: string;

constructor(item: RawNode, badges?: any, thumbs?: any, id?: string) {
this.#nav_text = new Text(item);
const nav_text = new Text(item);

this.id = id || (this.#nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.browseId || this.#nav_text?.endpoint?.payload?.browseId || 'N/A';
this.name = this.#nav_text?.text || 'N/A';
this.id = id || (nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.browseId || nav_text?.endpoint?.payload?.browseId || 'N/A';
this.name = nav_text?.text || 'N/A';
this.thumbnails = thumbs ? Thumbnail.fromResponse(thumbs) : [];
this.endpoint = ((this.#nav_text?.runs?.[0] as TextRun) as TextRun)?.endpoint || this.#nav_text?.endpoint;
this.endpoint = ((nav_text?.runs?.[0] as TextRun) as TextRun)?.endpoint || nav_text?.endpoint;
this.badges = Array.isArray(badges) ? Parser.parseArray(badges) : observe([] as YTNode[]);
this.is_moderator = this.badges?.some((badge: any) => badge.icon_type == 'MODERATOR');
this.is_verified = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED');
this.is_verified_artist = this.badges?.some((badge: any) => badge.style == 'BADGE_STYLE_TYPE_VERIFIED_ARTIST');

// @TODO: Refactor this mess.
this.url =
(this.#nav_text?.runs?.[0] as TextRun)?.endpoint?.metadata?.api_url === '/browse' &&
`${Constants.URLS.YT_BASE}${(this.#nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.canonicalBaseUrl || `/u/${(this.#nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.browseId}`}` ||
`${Constants.URLS.YT_BASE}${this.#nav_text?.endpoint?.payload?.canonicalBaseUrl || `/u/${this.#nav_text?.endpoint?.payload?.browseId}`}`;
(nav_text?.runs?.[0] as TextRun)?.endpoint?.metadata?.api_url === '/browse' &&
`${Constants.URLS.YT_BASE}${(nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.canonicalBaseUrl || `/u/${(nav_text?.runs?.[0] as TextRun)?.endpoint?.payload?.browseId}`}` ||
`${Constants.URLS.YT_BASE}${nav_text?.endpoint?.payload?.canonicalBaseUrl || `/u/${nav_text?.endpoint?.payload?.browseId}`}`;
}

get best_thumbnail(): Thumbnail | undefined {
Expand Down

0 comments on commit b50e200

Please sign in to comment.