Skip to content

Commit

Permalink
Merge pull request #44 from suryavaddiraju/development
Browse files Browse the repository at this point in the history
v2.0.11
  • Loading branch information
suryavaddiraju committed May 14, 2024
2 parents f207082 + 3e35064 commit 2797685
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion lib/postinstall.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ if (!fs.existsSync(binaryPath)) {
fs.closeSync(fs.openSync(binaryPath, 'w'));
const file = fs.createWriteStream(binaryPath);
download(url,file);
fs.chmodSync("./lib/cli-wrapper.mjs", 0o755);
fs.chmodSync(binaryPath, 0o755);
};
25 changes: 19 additions & 6 deletions lib/workings.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import axios from 'axios';
import {wrapper} from 'axios-cookiejar-support';
import { CookieJar } from 'tough-cookie';
import { writeFileSync } from 'fs';
import { writeFileSync } from 'node:fs';
import {dirname,join} from "node:path";
import * as cheerio from 'cheerio';
import querystring from 'querystring';
import { exec } from 'child_process';
import { URL } from 'url';
import { execFile } from 'node:child_process';
import { URL,fileURLToPath } from 'node:url';
import {verify_booking_params, initialize_booking_variables, input, base64DecodeUnicode} from './utils.mjs';
import { psg_input_wait, sleep_for_login, sleep_for_availability_check} from "./time_work.mjs";
import {headers as main_headers} from './browser_headers.mjs';
Expand Down Expand Up @@ -68,10 +69,22 @@ class IRCTC{
return "Sign Button Clicked Successfully";
}
async answer_captcha(){
let imagePath = './captcha.jpg';
let imagePath = 'captcha.jpg';
this.log_data("Proceeding for Captcha Answering");
writeFileSync(imagePath, this.captchaQuestion, 'base64');
exec('viu captcha.jpg -t', (error, stdout, stderr) => {
writeFileSync("./"+imagePath, this.captchaQuestion, 'base64');
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const path_l = join(__dirname, "..","bin");
const files = readdirSync(path_l);
let path_n = "";
if (files.length === 0) {
throw new Error("Platform not supported, Request you to manually download the viu binary file from rust standard installation page and place it inside this bin folder located in. "+path_l)
}
else{
path_n = files[0];
}
const binaryPath = join(path_l, path_n);
execFile(binaryPath, [imagePath,"-t"], (error, stdout, stderr) => {
console.log(`${stdout}\nEnter the Captcha Answer below in this terminal`);
console.log(stderr);
if (error !== null) {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "irctc-api",
"description": "An exclusive NodeJs only package built on top of IRCTC Website APIs to book train tickets, managing user profile faster and simpler from anywhere in the world",
"version": "2.0.10",
"version": "2.0.11",
"scripts": {
"postinstall": "node ./lib/postinstall.mjs",
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -11,9 +11,6 @@
"url": "https://github.com/suryavaddiraju/irctc-api.git"
},
"license": "Apache-2.0",
"bin": {
"viu": "./lib/cli-wrapper.mjs"
},
"keywords": [
"irctc",
"api",
Expand Down

0 comments on commit 2797685

Please sign in to comment.