Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Use the baidu-pan-downloader with development and dynamic loading mode in Tampermonkey. #34

Closed
hongyi-zhao opened this issue Jan 7, 2022 · 41 comments

Comments

@hongyi-zhao
Copy link

On Ubuntu 20.04.3 LTS, I want to directly use the baidu-pan-downloader in development and dynamic loading mode without the help of Greasemonkey. The detailed steps are as follows:

$ node --version
v16.10.0
$ git clone https://github.com/dotennin/baidu-pan-downloader.git baidu-pan-downloader.git 
$ cd baidu-pan-downloader.git 
$ npm install
$ npm run build
#https://stackoverflow.com/questions/51706882/create-react-app-how-do-i-npm-start-with-a-specific-browser
# If available, the Chrome browser will be used first.
# To use a different, use the following environment variable setting:
$ BROWSER=firefox npm start

Through the above method, the Firefox browser will automatically open and navigate to https://pan.baidu.com/disk/home. But I'm still not sure whether the above method will let me directly use the baidu-pan-downloader in development and dynamic loading mode without the help of Greasemonkey.

Any hints/comments/explanations will be highly appreciated.

Regards,
HZ

@dotennin
Copy link
Owner

dotennin commented Jan 7, 2022

copy/install react-userscripts-dev.user.js to your Greasemonkey .

it will load the source from the port 5000 on your local.
BTW HMR function is not supported for now.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 7, 2022

An additional question first: At the build step of baidu-pan-downloader, I noticed the following message, but wasn't sure if it was harmful:

$ npm run build
[...]
Creating an optimized production build...
=============

WARNING: You are currently running a version of TypeScript which is not officially supported by typescript-estree.

You may find that it works just fine, or you may not.

SUPPORTED TYPESCRIPT VERSIONS: >=3.2.1 <3.6.0

YOUR TYPESCRIPT VERSION: 3.9.6

Please only submit bug reports when using the officially supported version.

=============
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Compiled with warnings.

./src/components/Button.tsx
  Line 9:5:    The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 11:12:  Script URL is a form of eval                                                                                                                                                                                                                                                                                                                                      no-script-url

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  97.45 KB  build/static/js/main.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  npm install -g serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy

copy/install react-userscripts-dev.user.js to your Greasemonkey.

I am not familiar with Greasemonkey, so I describe the steps as follows. If I am wrong, please correct me at any time:

  1. Start a supported browser, say, Firefox as follows
$ BROWSER=firefox npm start

Then install the Greasemonkey add-on and paste the react-userscripts-dev.user.js as a script and save it, as shown below:

image

Then log in to my Baidu network disk as follows:

image

But I still can't find the logo of baidu-pan-downloader, so don't know how to use it.

OTOH, even I don't use baidu-pan-downloader, I still can download the files from browser, as follows:

image

As you can see, I can download files from Baidu network disk without the help of baidu-pan-downloader, so why must I install it?

BTW HMR function is not supported for now.

What's HMR function and its role?

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

Some small files like .pdf .txt can be downloaded directly from the web side without any plugins or baidu client.
But looks like baidu-pan-downloader does not run successfully on your local.

An additional question first: At the build step of baidu-pan-downloader, I noticed the following message, but wasn't sure if it was harmful:

It just a warning message, which should not cause any problems

I am not familiar with Greasemonkey, so I describe the steps as follows. If I am wrong, please correct me at any time:

Currently I dun't know the availability of Greasemonkey please use Tampermonkey instead

What's HMR function and its role?

it's [Hot module replacement] exchanges, adds, or removes modules while an application is running, without a full reload for the development.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

Currently I dun't know the availability of Greasemonkey please use Tampermonkey instead

If so, you should remove the Greasemonkey related description from the README. Anyway, I also tried with Tampermonkey but it seems that baidu-pan-downloader still does not run successfully on my machine:

image

image

image

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

@hongyi-zhao Did you run npm start ? does it show any information ?

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

The Firefox shown above is opened automatically by the following command, running from the root directory of the locally cloned baidu-pan-downloader repository:

werner@X10DAi-00:~/Public/repo/github.com/dotennin/baidu-pan-downloader.git$ BROWSER=firefox npm start

After the above command completes, the terminal console will stay with the information shown below:

image

And I can also confirm the port 5000 is up:

$ lsof -i :5000
COMMAND     PID   USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
node    3341223 werner   23u  IPv4 5364946      0t0  TCP *:5000 (LISTEN)

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

@hongyi-zhao it's working for me.
does the console show any errors on your Firefox ?

@hongyi-zhao
Copy link
Author

See the following:

$ npm start &> ~/log
$ cat ~/log

> baidu-pan-downloader@3.3.1 start
> react-app-rewired start

ℹ 「wds」: Project is running at http://192.168.10.100/
ℹ 「wds」: webpack output is served from 
ℹ 「wds」: Content not from webpack is served from /home/werner/Public/repo/github.com/dotennin/baidu-pan-downloader.git/public
ℹ 「wds」: 404s will fallback to /
Starting the development server...

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Files successfully emitted, waiting for typecheck results...
Compiled with warnings.

./src/components/Button.tsx
  Line 9:5:    The href attribute requires a valid value to be accessible. Provide a valid, navigable address as the href value. If you cannot provide a valid href, but still need the element to resemble a link, use a button and change it with appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md  jsx-a11y/anchor-is-valid
  Line 11:12:  Script URL is a form of eval                                                                                                                                                                                                                                                                                                                                      no-script-url

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

@hongyi-zhao I mean the browser console(developer tool)

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

@hongyi-zhao it's working for me.

Can you show a screenshot of yours? This way, I can intuitively know what it should look like when it's working.

Now, I create a tampermonkey userscript using the dist/bundle.user.js built by me according to the guidance here, this way will not need npm start if I understand correct. But when my Baidu pan homepage is opened in Firefox, it still shows the following screen:

image

@hongyi-zhao I mean the browser console(developer tool)

Do you mean the following?

image

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

dun't know the specific reason, Userscript: Dev mode started should need to be displayed on your console.
image
image

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

dun't know the specific reason, Userscript: Dev mode started should need to be displayed on your console.

I should have pasted all the content of bundle.user.js for the normal mode or react-userscripts-dev.user.js for the development mode when creating the userscript in tampermonkey. And then restart the browser.

I now use the self built user script, i.e., dist/bundle.user.js, directly from tampermonkey, and have seen the following message in console of Firefox Web Developer Tools:

image

After further experimentation, this approach does seem to work, but the speed fluctuates:

image

What I observed is that suddenly there will be a very high speed, and then it will change to 0 speed, and go back and forth in turn. So I think it has been detected and blocked by Baidu.

OTOH, for a pdf file, though it can be downloaded rapidly by baidu-pan-downloader, but the result is compressed in a zip archive, which includes so many image files, such as tiff, jpeg, and so on, as shown below:

werner@X10DAi-00:~$ ls 数论导引(华罗庚+著).pdf.__________重命名我.zip -lh
-rw-rw-r-- 1 werner werner 15M Jan  8 17:08 数论导引(华罗庚+著).pdf.__________重命名我.zip
werner@X10DAi-00:~$ unar '数论导引(华罗庚+著).pdf.__________重命名我.zip'

werner@X10DAi-00:~/数论导引(华罗庚+著).pdf.__________重命名我$ ls
'Page 100, object 396.tiff'   'Page 400, object 1596.tiff'
'Page 101, object 400.tiff'   'Page 401, object 1600.tiff'
'Page 102, object 404.tiff'   'Page 402, object 1604.tiff'
'Page 103, object 408.tiff'   'Page 403, object 1608.tiff'
'Page 104, object 412.tiff'   'Page 404, object 1612.tiff'
'Page 105, object 416.tiff'   'Page 405, object 1616.tiff'
[...]

In this case, bidu-pan-downloader basically loses its use value.

BTW: What screen capture tool do you use to get the screenshots posted above?

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

Yeah , that's why I hardly update this plugin any more. the speed has been limited.
Now I have already changed to the share download mode. more or less the will be better although, you can pull the last changes and check it on your local. or just install bundle.user alone with Tampermonkey.

But still no idea to avoid the limitation from baidu cloud 😞

BTW: What screen capture tool do you use to get the screenshots posted above?

snipaste, it's a free software , but doens't sesm to be open source

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

OTOH, for a pdf file, though it can be downloaded rapidly by baidu-pan-downloader, but the result is compressed in a zip archive, which includes so many image files, such as tiff, jpeg, and so on, as shown below:

Yeah , some files with the suffix like .pdf .exe cannot be downloaded directly, and need to be renamed before .
That's why it does shows as . __________ rename me.zip suffix, please delete it

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

Now I have already changed to the share download mode.

I don't know what do you mean by saying the above. More specifically, the previous version already supplied two modes: locally direct connect and share download mode as shown below, denoted by 1 and 2:

image

snipaste, it's a free software

There is currently no Linux version of this tool, which makes it useless for me.

That's why it does shows as . __________ rename me.zip suffix, please delete it

Thank you. The following does the trick:

$ mv 'something.pdf. __________ rename me.zip' something.pdf

To summarize: In any case, any cloud storage is under the control of the provider itself. It seems meaningless to further study the technology behind this tool, which will only cause a waste of time. Further speaking, any further research and experimentation with other similar tools is not necessary too.

@hongyi-zhao hongyi-zhao changed the title Directly use the baidu-pan-downloader in development and dynamic loading mode without the help of Greasemonkey. Use the baidu-pan-downloader in development and dynamic loading mode with the help of Tampermonkey. Jan 8, 2022
@hongyi-zhao hongyi-zhao changed the title Use the baidu-pan-downloader in development and dynamic loading mode with the help of Tampermonkey. Use the baidu-pan-downloader in development and dynamic loading mode in Tampermonkey. Jan 8, 2022
@hongyi-zhao hongyi-zhao changed the title Use the baidu-pan-downloader in development and dynamic loading mode in Tampermonkey. Use the baidu-pan-downloader in development and dynamic loading mode in Tampermonkey. Jan 8, 2022
@hongyi-zhao hongyi-zhao changed the title Use the baidu-pan-downloader in development and dynamic loading mode in Tampermonkey. Use the baidu-pan-downloader with development and dynamic loading mode in Tampermonkey. Jan 8, 2022
@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

I don't know what do you mean by saying the above. More specifically, the previous version already supplied two modes: locally direct connect and share download mode as shown below, denoted by 1 and 2:

the default download mode was locally direct and I switched to share download mode for now


To summarize: In any case, any cloud storage is under the control of the provider itself. It seems meaningless to further study the technology behind this tool, which will only cause a waste of time. Further speaking, any further research and experimentation with other similar tools is not necessary too.

Yeah , agreed. To be honest , the only use of this plugin at this stage is to download smaller files that are (usually less than 200MB or smaller size) directly. without additional baidu client or the third-party downloader.
I can provide a SVIP tokens to unlimit the speed. but this is not a long term soution for me .

@dotennin dotennin closed this as completed Jan 8, 2022
@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 8, 2022

I can provide a SVIP tokens to unlimit the speed.

If you do, it means that you pay Baidu for the people who use this tool. If so, no matter what download method you use, say, by baidunetdisk client, the speed limit should already be unlocked, just as you described here. So what's the point of using this tool? The significance of this or such tools is that they can bypass Baidu's technical barriers for free. If this is very difficult or impossible to implement, then the point of such tools is lost.

@dotennin
Copy link
Owner

dotennin commented Jan 8, 2022

it can be used to provide unlimited link to multi users.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 9, 2022

If one SVIP can be used to provide unlimited link to multi users, I think Baidu may also be able to quickly spot and block abuse of this feature once you serve users based on it.

In nature, this is not a technology-based cracking, but a commercial service supplied by its provider. Such things should not be the core focus of such tools: It means compromise on commercial services and failure to break through technical barriers. But OTOH, let baidu-pan-downloader support this feature may be as a supplement to existing clients in the case of purchasing svip, because javascript is inherently cross-platform. This saves you the trouble of installing different versions of Baidu network disk clients for different operating systems.

To summarize again: Any hacking technique that breaks through the technical barriers of commercialized services cannot be done once and for all. Once abused, it will eventually be blocked and completely invalidated. But as a supplement and convenient replacement of existing official counterpart product, cross-platform implementation still has its value. Instead of providing a built-in svip token, let it automatically obtain the svip token of the current account, if it exists, otherwise, provide a setting option to let the user fill in their own svip token. See the views expressed in the comments here:

从合法使用的角度,通过付费开通百度网盘会员来加速下载是唯一正解。
这也是一个正常的商业逻辑,用户支付可获得更好的服务,而没有收入的服务迟早会关停。

所以建议大家不要使用任何第三方工具来突破限速。

Some additional side remarks and questions:

  1. Even I've logged in Baidu net disk website with my purchased svip account, as shown below:

image

The baidu-pan-downloader still cannot provide a wonderful and smooth download experience:

image

  1. On Ubuntu 20.04.3 LTS, the latest version of baidunetdisk often crashes while starting. So I try to install an earlier version according to the information here:
# First remove the previously installed version: 
#https://www.tecmint.com/sub-process-usr-bin-dpkg-returned-an-error-in-ubuntu/
$ sudo rm -fr /var/lib/dpkg/info/baidunetdisk.*
$ sudo apt update
$ sudo apt remove baidunetdisk
$ sudo gdebi baidunetdisk_3.5.0_amd64.deb

In the case of purchasing svip, baidunetdisk does provide an excellent user experience, which is unmatched by any third-party software. See my situation in the picture below for reference only:

image

BTW: How do I generate my SVIP token as an SVIP user?

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Baidu force the free user to install their client to download big file. This tool bypass that.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 10, 2022

As discussed here: It has been invalidated/blocked by Baidu currently.

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Just tested, it still work. You need to add the file to your drive first.

@hongyi-zhao
Copy link
Author

What do you mean by saying add the file to your drive? Do you have more detailed instructions on your exact steps?

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

You need a Baidu Pan account. Add the shared file to your Baidu Pan then download using this tool.

@hongyi-zhao
Copy link
Author

Strange. All my testings described here in this issue are done this way.

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Can you see the "+" icon at the bottom right in Baidu Pan website?

@hongyi-zhao
Copy link
Author

Yes. There is a + sign resided in a red circle in the bottom right corner of the screen. When I click on an item I want to download, then click the + sign, baidu-pan-downloader. But I've only observed stuttering downloads, almost constant pauses, making it impossible for me to use the tool at all.

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

So the tool did show the download speed? Is the download percentage go forward?
The file I test download is over 40% now for a 200MB++ file, It is expected for a free user.

@hongyi-zhao
Copy link
Author

Could you please give a screenshot?

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Screenshot 2022-01-10 at 16-54-45 百度网盘-全部文件

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 10, 2022

OK. See the following testing result on my machine with Firefox using the following script installed into tampermonkey:

$ curl -O https://raw.githubusercontent.com/dotennin/baidu-pan-downloader/master/dist/bundle.user.js -x socks5://127.0.0.1:18888

image

image

And as you can see, I've logged in with my Baidu SVIP account:

image

BTW: What screen capture tool do you use to get the screenshot posted above?

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Firefox has a built in screenshot tool, just right click and select Take Screenshot.

As mentioned by @dotennin, you will need to pull the one on Aug 31, 2020 or before to use the local direct download. I do not have SVIP so I cannot test this.

To do it, close the Baidu Pan website and click the link below, Tampermonkey should run. Click reinstall then open Baidu Pan website, now the local direct download button should work.

https://github.com/dotennin/baidu-pan-downloader/raw/b4f3f7dc8afda8b11b93b7e426f4611ade73df96/dist/bundle.user.js

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 10, 2022

I tried with it, but still observed an intermittent download speed:

image

image

@tvcat
Copy link
Collaborator

tvcat commented Jan 10, 2022

Can you see the generated link when you click the local direct download button?

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 11, 2022

When I click the local direct download:

image

When I click the share direct download:

image

Then, if I click OK button, nothing will be shown:

Although the download is intermittent, it does go on all the time:

image

@tvcat
Copy link
Collaborator

tvcat commented Jan 11, 2022

Try the latest update. There is a new option to change the download mode. Try both. Remember to refresh the Baidu Pan website after changing setting and before download.

I can't help further if it still not working as I do not have a SVIP account.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 11, 2022

Yes, I've tried the project’s latest Git master commit, but unfortunately, they all ran into the same problem. Anyway, I'm using the baidunetdisk with my SVIP account currently. Otherwise, it is a waste of resources: Isn't this a failure to live up to official expectations.
image

@tvcat
Copy link
Collaborator

tvcat commented Jan 11, 2022

It is still very usable for free account user to bypass the desktop client. This is a very hard thing to do as Baidu will keep changing to kill off this kind of bypass as this reduce their profit.

It is too harsh to call this a failure.

Maybe you can try Wine and install the Windows desktop client of Baidu Pan.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 11, 2022

Maybe you can try Wine and install the Windows desktop client of Baidu Pan.

Why do you suggest me try the Wine based solution, considering that this is a rather hard and low efficient way? As you can see, I'm using baidunetdisk installed by baidunetdisk_3.5.0_amd64.deb. I think this is the Linux counterpart of the Windows desktop client of Baidu Pan for Windows.

@tvcat
Copy link
Collaborator

tvcat commented Jan 11, 2022

Didn't know they has a Linux version. The latest is 4.3.0, maybe that fixed the crash issue.
or you can download the Windows client and install with Wine.

https://pan.baidu.com/download

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Jan 11, 2022

The latest is 4.3.0, maybe that fixed the crash issue.

On Ubuntu 20.04.3 LTS, The baidunetdisk_4.3.0_amd64.deb still crashes, but baidunetdisk_3.5.0_amd64.deb works well.

https://pan.baidu.com/download

The Linux version is already listed on this official download site.

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

No branches or pull requests

3 participants