ybd-project / ytdl-core

Fast and secure YouTube downloader for JavaScript and TypeScript
MIT License
28 stars 5 forks source link

Package compatilibity #16

Closed ToddyTheNoobDud closed 2 months ago

ToddyTheNoobDud commented 2 months ago

So im making an fork of @distube/youtube, Which use this project as the ytdl main code, to make youtube work normally again

I wish to get some help from the owners, like after 5.1.1 the validateURL function + createAgent stopped working. What alternatives i can use for that? (for my package, i used GetBasicInfo function, to make it work again)

And an feature request would be: Add an auto save poToken for an .txt or something, and after restarts or something it can be re-added again, wasting less time

ybd-project commented 2 months ago

Thank you very much. We will implement this in the next version. Regarding ValidateURL and createAgent, can you provide specific code?

ToddyTheNoobDud commented 2 months ago

Create agent part:

// before 5.1.1.
  constructor(options = {}) {
    super();
    checkInvalidKey(options, ["cookies", "ytdlOptions"], "YouTubePlugin");
    this.cookies = this.#cookies = options.cookies ? clone(options.cookies) : void 0;
    this.#ytdlOptions = options?.ytdlOptions ? clone(options.ytdlOptions) : {};
    this.#ytdlOptions.agent = ytdl.createAgent(this.cookies) // this one
  }
// after 5.1.1
  constructor(options = {}) {
    super();
    checkInvalidKey(options, ["cookies", "ytdlOptions"], "YouTubePlugin");
    this.cookies = this.#cookies = options.cookies ? clone(options.cookies) : void 0;
    this.#ytdlOptions = options?.ytdlOptions ? clone(options.ytdlOptions) : {};
    this.#ytdlOptions.agent = this.cookies ? ytdl.createAgent(this.cookies) : undefined; // this one
  }

Validate url part:

// after 5.1.1
  validate(url) {
    return ytdl.getBasicInfo(url);
  }
  // before 5.1.1
   validate(url) {
    return ytdl.validateURL(url) || ytpl.validateID(url);
  }
ToddyTheNoobDud commented 2 months ago

Forgot to mention, but if you try to use @distube/soundcloud, It always returns 'Not an youtube domain', so soundcloud cannot be used with this

ybd-project commented 2 months ago

Is there an error in the validateUrl function? It is working in my environment.

And as for the caching of potoken and visitorData, I don't think it makes much sense, because with the new usage (YtdlCore class), these don't need to be specified multiple times. (If potoken etc. is passed as an option when the class is initialized, it will be the default option for subsequent executions of the getFullInfo function, etc.)

ybd-project commented 2 months ago

Has the problem been resolved? If I do not receive a reply for a day, I will close this issue.

ybd-project commented 2 months ago

I am closing this issue because a day has passed since the above post. If you have any more questions, please create a new issue. Thank you.