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

Can we migrate this script to node script #9

Open
duongnv1996 opened this issue Nov 10, 2023 · 3 comments
Open

Can we migrate this script to node script #9

duongnv1996 opened this issue Nov 10, 2023 · 3 comments

Comments

@duongnv1996
Copy link

Hi there,
Thank for your awsome work.

This script only run in console window, so that we must open browser to run script.
Now Can we migrate this to node js framework. I mean we just input the tiktok user id, node js will convert this script then run all thing to fetch videos then download it.
That's my idea.

Thank again for your script

@Dinoosauro
Copy link
Owner

Hi, thanks a lot for the idea!
Currently this script relies on video extraction from the DOM, so a browser is necessary. However, I think that it's possible to automate this process by using something like Selenium or Puppeteer: a browser controlled by a Node script will open the page, then the TikTok script will be injected to fetch the video URLs, and then the Node script will manage to download everything. I'll try to do something like this in these days

@duongnv1996
Copy link
Author

I hope to see it

Dinoosauro added a commit that referenced this issue Nov 19, 2023
This can be used to change the value of the script while it's running, or if the script needs to be injected from another script. Useful for #9
Dinoosauro added a commit that referenced this issue Nov 19, 2023
This can be used to change the value of the script while it's running, or if the script needs to be injected from another script. Useful for #9
@Dinoosauro
Copy link
Owner

I've created a Node.JS module that can be imported to do this. Puppeteer will be used, so the webpage will still be rendered, but it could be useful for automation.

The module gives only an array of Video URLs, adapting them to be downloaded with yt-dlp could be done by calling the yt-dlp process for each video. I would do something like this:

const script = require("./script")("https://www.tiktok.com/@mrbeast");

let webpage = await script.create();
let videoArray = await webpage.start();
videoArray.forEach((video) => {
require("child_process").execSync(`yt-dlp ${video}`);
})

If you want to take a look to the module, I've uploaded in another repository, so that maybe in the following days I can upload it to NPM and simplify both the download and the eventual updates: https://github.com/Dinoosauro/node-tiktok-to-ytdlp/tree/main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants