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

refactor!: replace unnecessary classes with pure functions #468

Merged
merged 21 commits into from
Aug 18, 2023

Conversation

Wykerd
Copy link
Collaborator

@Wykerd Wykerd commented Aug 9, 2023

As proposed on Discord by @absidue, this PR aims to replace Proto, FormatUtils, Parser and YTNodeGenerator with pure functions, allowing better bundler support.

Breaking Changes:

  • Remove YTNodeGenerator from import('youtubei.js').Generator and exposes its functions directly in import('youtubei.js').Generator
  • Remove Parser class in favour of namespaced pure functions
  • Remove Proto class in favour of namespaced pure functions
  • Merge duplicate classes AppendContinuationItemsAction into a single class (removes the items property in favour of contents)
  • Add better custom logging support to parser methods as per issue CompactMovie not found! #460, which does mean that the Parser#setParserErrorHandler function signature has changed slightly.
  • Remove FormatUtils class in favour of pure functions

Other changes:

  • Replace linkedom DASH manifest generation with a dependency free JSX implementation
  • Remove DOMParser requirement
  • Remove duplicate types used by FormatUtils

Additions:

  • MediaInfo#getStreamingInfo - gets the same data available in the Dash manifest as a js object

BREAKING CHANGES:
- Removes `YTNodeGenerator` from `import('youtubei.js').Generator` and exposes its functions directly in `import('youtubei.js').Generator`
- Remove Parser class in favour of pure functions
- Merge duplicate classes `AppendContinuationItemsAction` into a single class
- Move continuation parsers into a seperate file
- Add better custom logging support to parser methods as per issue #460
- Replace linkedom DASH manifest generation with a dependency free JSX implementation
- Remove FormatUtils class in favour of pure functions
- Remove DOMParser requirement
- Remove duplicate types
@Wykerd
Copy link
Collaborator Author

Wykerd commented Aug 9, 2023

I forgot to pull the latest changes before I refactored FormatUtils 💀

src/parser/parser.ts Outdated Show resolved Hide resolved
Wykerd and others added 4 commits August 11, 2023 11:36
Co-authored-by: LuanRT <[email protected]>
This allows users to access the same data available in the dash manifest while also simplifying the manifest generation
Remove redundant getAudioTrackGroups
General readability improvements in StreamingInfo.ts
Share response object between `getBitrate` and `getMimeType` as to not make duplicate requests
package.json Outdated Show resolved Hide resolved
@Wykerd Wykerd marked this pull request as ready for review August 15, 2023 18:27
@LuanRT LuanRT merged commit 87ed396 into main Aug 18, 2023
3 checks passed
@Wykerd Wykerd deleted the Wykerd-refactor-functional branch August 21, 2023 21:44
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.

3 participants