├── README.md ├── index.cmd ├── index.js └── index.sh /README.md: -------------------------------------------------------------------------------- 1 | `index.cmd` is depended on [iikira](https://github.com/iikira)/[BaiduPCS-Go](https://github.com/iikira/BaiduPCS-Go). -------------------------------------------------------------------------------- /index.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: Set starting ID here 4 | set id=266700 5 | 6 | :bk 7 | echo %id% 8 | 9 | :: Invoke BaiduPCS-Go to test if the appid avaliable 10 | BaiduPCS-Go.exe config set -appid=%id% > nul 11 | BaiduPCS-Go.exe ls 12 | set /a id+=1 13 | 14 | goto bk 15 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const http = require('http'), 3 | BDUSS = ''; // Enter your BDUSS here 4 | 5 | var request = function(appid, callback) { 6 | http.get({ 7 | host : 'pcs.baidu.com', 8 | port : 80, 9 | path : '/rest/2.0/pcs/file?app_id=' + appid + '&method=list&path=%2F', 10 | method : 'GET', 11 | headers : { 12 | 'Cookie': 'BDUSS=' + BDUSS, 13 | 'User-Agent': 'netdisk;1.0' 14 | } 15 | }, function(res) { 16 | if (res.statusCode == 200) { 17 | callback(null, appid); 18 | } else { 19 | callback(null, null); 20 | } 21 | }).on('error', function(err) { 22 | callback(err, null); 23 | }); 24 | }; 25 | 26 | for (var i=266000; i<267000; i++) { // BUG: Too large span may cause timeout errors 27 | request(i, function(err, appid) { 28 | if (appid) { 29 | console.log('AppID ' + appid + ' is avalible.'); 30 | } 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /index.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################ 4 | # Usage: 5 | # chmod +x index.sh 6 | # ./index.sh 7 | ############################################################ 8 | 9 | # To get BDUSS by reading BaiduPCS-Go config file 10 | BDUSS=`cat $HOME/.config/BaiduPCS-Go/pcs_config.json | egrep bduss | tail -c 195 | head -c 192` 11 | 12 | for appid in $(seq $1 $2); do 13 | echo $appid # Can be deleted when need to run silently 14 | 15 | # To sent GET request to test if the AppID avaliable 16 | status=`curl --cookie "BDUSS=${BDUSS}" -I -o /dev/null -s -w %{http_code} http://pcs.baidu.com/rest/2.0/pcs/file?app_id=${appid}\&method=list\&path=%2F` 17 | if [[ $status -eq 200 ]]; then 18 | echo -e "\033[0;32mAppID ${appid} is avaliable!\033[0m" 19 | # To set BaiduPCS-Go AppID 20 | BaiduPCS-Go config set -appid=$appid 21 | exit 0 22 | fi 23 | done 24 | 25 | # None of AppID avaliable 26 | echo -e "\033[0;31mThere's no AppID avaliable between ${1} and ${2}!\033[0m" 27 | exit 1 28 | --------------------------------------------------------------------------------