Skip to content

Refactor link handlersΒ #1360

@Stypox

Description

@Stypox

The interface of link handlers and link handler factories is strange, hard to debug, and it's doing something extremely simple (checking if a URL matches and extracting stuff from it) in a highly overcomplicated way. It could be refactored like this in my opinion:

  • have a base interface Link (the shorter the name the better, current names are huge)
  • The interface has only a few extractor related methods, e.g. getExtractor() returns the extractor corresponding to the link.
  • The interface also has a few app-facing public methods that are meant to be used only by the app (and not by other parts of the extractor). For example, a getUniqueId() method that returns a stable and unique ID for each resource, so it can be used as a primary key in NewPipe's database.
  • Each extractor has a corresponding Link implementation. Every Link's constructor takes a URL and builds an instance of Link, but throws an exception if the URL does not match the expected link format.
  • Each Link implementor may also have other constructors, e.g. YoutubeSearchLink would have a constructor that takes the query and any search filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codequalityImprovements to the codebase to improve the code qualityhelp wantedHelp is wanted in fixing this issuemultiserviceIssues related to multiple services

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions