gatecrasher777/ytcog

Split out download fork to allow webpack compilation

pke opened this issue · 4 comments

pke commented

I am currently having trouble compiling the code with webpack. I only need the code to download video meta info which does not need the code to fork "dl.js" in video.js.
Could the video meta code live in a webpack compatible module?

In video.js comment out line 8, lines 383 - 589, lines 667-779.
In index.js comment out lines 18-50, lines 58-62

That will leave you without a download function, but you should have no problem getting the video meta info and streams,

I've only ever interfaced with the innertube api via a node server, but it ought to work in the browser provided you are able to overcome any CORS issues.

pke commented

I'll give it a try!

pke commented

This still errors when deploying to vercel.com and used in a next.js app.

2021-09-04T23:54:48.823Z	b6abd641-14f3-4abc-9570-a09f77b93341	ERROR	Error: Cannot find module './model'
Require stack:
- /var/task/node_modules/ytcog/lib/session.js
- /var/task/node_modules/ytcog/lib/index.js
- /var/task/.next/server/pages/api.js
- /var/task/node_modules/next/dist/server/next-server.js
- /var/task/___next_launcher.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
    at Function.Module._load (internal/modules/cjs/loader.js:745:27)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/var/task/node_modules/ytcog/lib/session.js:7:15)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/task/node_modules/ytcog/lib/session.js',
    '/var/task/node_modules/ytcog/lib/index.js',
    '/var/task/.next/server/pages/api.js',
    '/var/task/node_modules/next/dist/server/next-server.js',
    '/var/task/___next_launcher.js',
    '/var/runtime/UserFunction.js',
    '/var/runtime/index.js'
  ]
}

It's not finding the model.js module which is right there in the ytcog lib folder. Perhaps you need to somehow configure webpack, npm or next.js to look in the ytcog lib folder to resolve the filenames.