Fix formatting
This commit is contained in:
parent
d394f265c5
commit
10501b41a4
@ -1,14 +1,14 @@
|
|||||||
import { createHash } from "crypto";
|
import { createHash } from 'crypto';
|
||||||
import Utils from "../utils/utils.js";
|
import Utils from '../utils/utils.js';
|
||||||
import DebugInfo from "../models/DebugInfo.js";
|
import DebugInfo from '../models/DebugInfo.js';
|
||||||
|
|
||||||
const baseUrl = "https://www.nomerogram.ru/api/v1.1";
|
const baseUrl = 'https://www.nomerogram.ru/api/v1.1';
|
||||||
|
|
||||||
const secretSuffix = "queivoo1ieNgae2e";
|
const secretSuffix = 'queivoo1ieNgae2e';
|
||||||
const appId = "p15";
|
const appId = 'p15';
|
||||||
const deviceId = "01b854631cb28e175ffbcccf6114acc3";
|
const deviceId = '01b854631cb28e175ffbcccf6114acc3';
|
||||||
const from = "search";
|
const from = 'search';
|
||||||
const userAgent = "Nomerogram/2.18 (iPhone; iOS 13.7; Scale/2.00)";
|
const userAgent = 'Nomerogram/2.18 (iPhone; iOS 13.7; Scale/2.00)';
|
||||||
|
|
||||||
class NomerogramProvider {
|
class NomerogramProvider {
|
||||||
static async getGroups(number) {
|
static async getGroups(number) {
|
||||||
@ -17,24 +17,24 @@ class NomerogramProvider {
|
|||||||
let secretSource =
|
let secretSource =
|
||||||
appId + number + deviceId + from + timestamp + secretSuffix;
|
appId + number + deviceId + from + timestamp + secretSuffix;
|
||||||
|
|
||||||
let hash = createHash("sha256");
|
let hash = createHash('sha256');
|
||||||
hash.update(secretSource);
|
hash.update(secretSource);
|
||||||
let secret = hash.digest("hex");
|
let secret = hash.digest('hex');
|
||||||
|
|
||||||
let url = `${baseUrl}/group/list?from=${from}&carplate=${number}×tamp=${timestamp}&secret=${secret}&app_id=${appId}&device_id=${deviceId}`;
|
let url = `${baseUrl}/group/list?from=${from}&carplate=${number}×tamp=${timestamp}&secret=${secret}&app_id=${appId}&device_id=${deviceId}`;
|
||||||
let result = await fetch(url, {
|
let result = await fetch(url, {
|
||||||
signal: AbortSignal.timeout(5000),
|
signal: AbortSignal.timeout(5000),
|
||||||
headers: { "User-Agent": userAgent },
|
headers: { 'User-Agent': userAgent },
|
||||||
});
|
});
|
||||||
let json = await result.json();
|
let json = await result.json();
|
||||||
|
|
||||||
if (!json.success) {
|
if (!json.success) {
|
||||||
console.log("Nomerogram error: ", json.message);
|
console.log('Nomerogram error: ', json.message);
|
||||||
throw Error(json.message);
|
throw Error(json.message);
|
||||||
//return [];
|
//return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Nomerogram found ads: ", json.data.groups.length);
|
console.log('Nomerogram found ads: ', json.data.groups.length);
|
||||||
return json.data.groups.flatMap((g) => {
|
return json.data.groups.flatMap((g) => {
|
||||||
return g.photos.map((p) => {
|
return g.photos.map((p) => {
|
||||||
return {
|
return {
|
||||||
@ -45,7 +45,7 @@ class NomerogramProvider {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.log("Nomerogram error: ", ex.message);
|
console.log('Nomerogram error: ', ex.message);
|
||||||
ex.debugInfo = { nomerogram: DebugInfo.fromError(ex.message) };
|
ex.debugInfo = { nomerogram: DebugInfo.fromError(ex.message) };
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user