mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -08:00
refactor: remove unnecessary console logs from Stalker events and portal import components
This commit is contained in:
1 parent
fdef4dcdff
commit
5904025e82
4 files changed
-273
No files matched your search
@@ -31,18 +31,6 @@ ipcMain.handle(
|
||||
try {
|
||||
const { url, macAddress, params, token, serialNumber } = payload;
|
||||
|
||||
console.log('[StalkerEvents] Incoming request');
|
||||
console.log('[StalkerEvents] Base URL:', url);
|
||||
console.log('[StalkerEvents] MAC Address:', macAddress);
|
||||
console.log(
|
||||
'[StalkerEvents] Params:',
|
||||
JSON.stringify(params, null, 2)
|
||||
);
|
||||
console.log(
|
||||
'[StalkerEvents] Token:',
|
||||
token ? token.substring(0, 10) + '...' : 'none'
|
||||
);
|
||||
|
||||
// Build URL with query parameters
|
||||
// Note: For 'cmd' parameter, we need to use encodeURI (not encodeURIComponent)
|
||||
// to preserve forward slashes, matching stalker-to-m3u implementation
|
||||
@@ -69,7 +57,6 @@ ipcMain.handle(
|
||||
|
||||
// Build final URL with manually constructed query string
|
||||
const fullUrl = `${urlObject.origin}${urlObject.pathname}?${queryParts.join('&')}`;
|
||||
console.log('[StalkerEvents] Full request URL:', fullUrl);
|
||||
|
||||
// Build cookie string matching the working curl example format
|
||||
// Format: mac=XX:XX:XX:XX:XX:XX; stb_lang=de_DE; timezone=Europe/Berlin; __cfduid=...
|
||||
@@ -103,14 +90,8 @@ ipcMain.handle(
|
||||
// Add Authorization header if token is provided
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
console.log('[StalkerEvents] Authorization header added');
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[StalkerEvents] Request headers:',
|
||||
JSON.stringify(headers, null, 2)
|
||||
);
|
||||
|
||||
// Determine timeout based on action type
|
||||
// create_link requests can take longer as server generates stream URL
|
||||
const isCreateLink = params.action === 'create_link';
|
||||
@@ -125,13 +106,7 @@ ipcMain.handle(
|
||||
validateStatus: (status) => status < 500, // Don't throw on 4xx errors
|
||||
};
|
||||
|
||||
console.log('[StalkerEvents] Sending request...');
|
||||
const response = await axios(config);
|
||||
console.log('[StalkerEvents] Response status:', response.status);
|
||||
console.log(
|
||||
'[StalkerEvents] Response data:',
|
||||
JSON.stringify(response.data, null, 2).substring(0, 500) + '...'
|
||||
);
|
||||
|
||||
// Check if response is successful
|
||||
if (response.status >= 400) {
|
||||
@@ -161,10 +136,6 @@ ipcMain.handle(
|
||||
'Failed to fetch data from Stalker portal',
|
||||
status: error.response?.status || 500,
|
||||
};
|
||||
console.error(
|
||||
'[StalkerEvents] Axios error response:',
|
||||
errorResponse
|
||||
);
|
||||
throw errorResponse;
|
||||
} else if (
|
||||
error &&
|
||||
|
||||
@@ -93,18 +93,6 @@ export class StalkerPortalImportComponent {
|
||||
const isFullStalkerPortal =
|
||||
this.isFullStalkerPortalUrl(originalUrl);
|
||||
|
||||
console.log('[StalkerImport] Starting import process');
|
||||
console.log('[StalkerImport] Original URL:', originalUrl);
|
||||
console.log('[StalkerImport] Transformed URL:', transformedUrl);
|
||||
console.log(
|
||||
'[StalkerImport] Is Full Stalker Portal:',
|
||||
isFullStalkerPortal
|
||||
);
|
||||
console.log(
|
||||
'[StalkerImport] MAC Address:',
|
||||
this.form.value.macAddress
|
||||
);
|
||||
|
||||
let stalkerToken: string | undefined;
|
||||
let stalkerAccountInfo: Playlist['stalkerAccountInfo'] | undefined;
|
||||
let stalkerSerialNumber: string | undefined;
|
||||
@@ -115,21 +103,10 @@ export class StalkerPortalImportComponent {
|
||||
|
||||
// For full stalker portal URLs, perform handshake and get profile
|
||||
if (isFullStalkerPortal) {
|
||||
console.log(
|
||||
'[StalkerImport] Full stalker portal detected, starting authentication...'
|
||||
);
|
||||
|
||||
// Use provided serial number or generate a new one
|
||||
stalkerSerialNumber =
|
||||
this.form.value.serialNumber?.trim() ||
|
||||
STALKER_SERIAL_NUMBER;
|
||||
console.log(
|
||||
'[StalkerImport] Using serial number:',
|
||||
stalkerSerialNumber,
|
||||
this.form.value.serialNumber?.trim()
|
||||
? '(user provided)'
|
||||
: '(auto-generated)'
|
||||
);
|
||||
|
||||
// Use provided device IDs if available (64 hex chars each)
|
||||
stalkerDeviceId1 =
|
||||
@@ -140,34 +117,6 @@ export class StalkerPortalImportComponent {
|
||||
this.form.value.signature1?.trim() || undefined;
|
||||
stalkerSignature2 =
|
||||
this.form.value.signature2?.trim() || undefined;
|
||||
console.log(
|
||||
'[StalkerImport] Device ID 1:',
|
||||
stalkerDeviceId1
|
||||
? stalkerDeviceId1.substring(0, 16) +
|
||||
'... (user provided)'
|
||||
: '(auto-generated)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerImport] Device ID 2:',
|
||||
stalkerDeviceId2
|
||||
? stalkerDeviceId2.substring(0, 16) +
|
||||
'... (user provided)'
|
||||
: '(auto-generated)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerImport] Signature 1:',
|
||||
stalkerSignature1
|
||||
? stalkerSignature1.substring(0, 16) +
|
||||
'... (user provided)'
|
||||
: '(not provided)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerImport] Signature 2:',
|
||||
stalkerSignature2
|
||||
? stalkerSignature2.substring(0, 16) +
|
||||
'... (user provided)'
|
||||
: '(not provided)'
|
||||
);
|
||||
|
||||
try {
|
||||
const authResult =
|
||||
@@ -180,10 +129,6 @@ export class StalkerPortalImportComponent {
|
||||
);
|
||||
|
||||
stalkerToken = authResult.token;
|
||||
console.log(
|
||||
'[StalkerImport] Authentication successful, token received:',
|
||||
stalkerToken?.substring(0, 10) + '...'
|
||||
);
|
||||
|
||||
if (authResult.accountInfo) {
|
||||
stalkerAccountInfo = {
|
||||
@@ -193,10 +138,6 @@ export class StalkerPortalImportComponent {
|
||||
authResult.accountInfo.tariff_plan_name,
|
||||
status: authResult.accountInfo.status,
|
||||
};
|
||||
console.log(
|
||||
'[StalkerImport] Account info received:',
|
||||
stalkerAccountInfo
|
||||
);
|
||||
}
|
||||
|
||||
// Show success notification with account info if available
|
||||
@@ -223,10 +164,6 @@ export class StalkerPortalImportComponent {
|
||||
this.isLoading.set(false);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
'[StalkerImport] Simple portal URL, skipping authentication'
|
||||
);
|
||||
}
|
||||
|
||||
const playlist: Playlist = {
|
||||
@@ -242,12 +179,6 @@ export class StalkerPortalImportComponent {
|
||||
stalkerSignature2,
|
||||
} as Playlist;
|
||||
|
||||
console.log('[StalkerImport] Creating playlist with config:', {
|
||||
portalUrl: playlist.portalUrl,
|
||||
isFullStalkerPortal: playlist.isFullStalkerPortal,
|
||||
hasToken: !!playlist.stalkerToken,
|
||||
});
|
||||
|
||||
this.store.dispatch(PlaylistActions.addPlaylist({ playlist }));
|
||||
this.addClicked.emit();
|
||||
} finally {
|
||||
|
||||
@@ -477,16 +477,7 @@ export const StalkerStore = signalStore(
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[StalkerStore] VOD series seasons response:',
|
||||
response
|
||||
);
|
||||
|
||||
if (!response?.js?.data) {
|
||||
console.warn(
|
||||
'[StalkerStore] Invalid VOD series seasons response:',
|
||||
response
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -646,13 +637,6 @@ export const StalkerStore = signalStore(
|
||||
p: '1',
|
||||
};
|
||||
|
||||
console.log(
|
||||
'[StalkerStore] Fetching VOD series episodes for video_id:',
|
||||
videoId,
|
||||
'season_id:',
|
||||
seasonId
|
||||
);
|
||||
|
||||
let response: any;
|
||||
if (playlist.isFullStalkerPortal) {
|
||||
response = await stalkerSession.makeAuthenticatedRequest(
|
||||
@@ -667,16 +651,7 @@ export const StalkerStore = signalStore(
|
||||
});
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[StalkerStore] VOD series episodes response:',
|
||||
response
|
||||
);
|
||||
|
||||
if (!response?.js?.data) {
|
||||
console.warn(
|
||||
'[StalkerStore] Invalid VOD series episodes response:',
|
||||
response
|
||||
);
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -899,11 +874,6 @@ export const StalkerStore = signalStore(
|
||||
p: '1',
|
||||
};
|
||||
|
||||
console.log(
|
||||
'[StalkerStore] Fetching movie files for movie_id:',
|
||||
movieId
|
||||
);
|
||||
|
||||
let response: any;
|
||||
if (playlist.isFullStalkerPortal) {
|
||||
response = await stalkerSession.makeAuthenticatedRequest(
|
||||
@@ -918,12 +888,9 @@ export const StalkerStore = signalStore(
|
||||
});
|
||||
}
|
||||
|
||||
console.log('[StalkerStore] Movie files response:', response);
|
||||
|
||||
// Extract id from the first data item
|
||||
if (response?.js?.data?.[0]?.id) {
|
||||
const fileId = response.js.data[0].id;
|
||||
console.log('[StalkerStore] Found file id:', fileId);
|
||||
return String(fileId);
|
||||
}
|
||||
|
||||
@@ -947,16 +914,9 @@ export const StalkerStore = signalStore(
|
||||
cmdToUse.includes('/media/') &&
|
||||
!cmdToUse.includes('/media/file_')
|
||||
) {
|
||||
console.log(
|
||||
'[StalkerStore] Item has has_files, fetching file id...'
|
||||
);
|
||||
const fileId = await this.fetchMovieFileId(item.id);
|
||||
if (fileId) {
|
||||
cmdToUse = `/media/file_${fileId}.mpg`;
|
||||
console.log(
|
||||
'[StalkerStore] Transformed cmd with file id:',
|
||||
cmdToUse
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,7 +957,6 @@ export const StalkerStore = signalStore(
|
||||
}
|
||||
},
|
||||
addToRecentlyViewed(item: any) {
|
||||
console.log('Adding to recently viewed', item);
|
||||
playlistService
|
||||
.addPortalRecentlyViewed(this.currentPlaylist()?._id, {
|
||||
...item,
|
||||
|
||||
@@ -157,10 +157,6 @@ export class StalkerSessionService {
|
||||
};
|
||||
|
||||
const fullUrl = `${portalUrl}?type=stb&action=handshake&token=&prehash=${prehash}&JsHttpRequest=1-xml`;
|
||||
console.log('[StalkerSession] Performing handshake...');
|
||||
console.log('[StalkerSession] Handshake URL:', fullUrl);
|
||||
console.log('[StalkerSession] MAC Address:', macAddress);
|
||||
console.log('[StalkerSession] Prehash:', prehash);
|
||||
|
||||
try {
|
||||
const response: StalkerHandshakeResponse =
|
||||
@@ -170,20 +166,7 @@ export class StalkerSessionService {
|
||||
params,
|
||||
});
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] Handshake response:',
|
||||
JSON.stringify(response, null, 2)
|
||||
);
|
||||
|
||||
if (response?.js?.token) {
|
||||
console.log(
|
||||
'[StalkerSession] Token received:',
|
||||
response.js.token.substring(0, 10) + '...'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Random received:',
|
||||
response.js.random
|
||||
);
|
||||
return {
|
||||
token: response.js.token,
|
||||
random: response.js.random || generateRandom(),
|
||||
@@ -255,19 +238,6 @@ export class StalkerSessionService {
|
||||
JsHttpRequest: '1-xml',
|
||||
};
|
||||
|
||||
console.log('[StalkerSession] Getting profile...');
|
||||
console.log('[StalkerSession] Profile URL:', portalUrl);
|
||||
console.log('[StalkerSession] Token:', token.substring(0, 10) + '...');
|
||||
console.log('[StalkerSession] Serial Number:', serialNumber);
|
||||
console.log(
|
||||
'[StalkerSession] Device ID:',
|
||||
deviceId1.substring(0, 16) + '...'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Signature:',
|
||||
signature1 ? signature1.substring(0, 16) + '...' : '(empty)'
|
||||
);
|
||||
|
||||
try {
|
||||
const response: StalkerProfileResponse =
|
||||
await this.dataService.sendIpcEvent(STALKER_REQUEST, {
|
||||
@@ -278,11 +248,6 @@ export class StalkerSessionService {
|
||||
serialNumber,
|
||||
});
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] Profile response:',
|
||||
JSON.stringify(response, null, 2)
|
||||
);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('[StalkerSession] Get profile error:', error);
|
||||
@@ -308,10 +273,6 @@ export class StalkerSessionService {
|
||||
JsHttpRequest: '1-xml',
|
||||
};
|
||||
|
||||
console.log('[StalkerSession] Performing do_auth...');
|
||||
console.log('[StalkerSession] do_auth URL:', portalUrl);
|
||||
console.log('[StalkerSession] Token:', token.substring(0, 10) + '...');
|
||||
|
||||
try {
|
||||
const response = await this.dataService.sendIpcEvent(
|
||||
STALKER_REQUEST,
|
||||
@@ -323,18 +284,11 @@ export class StalkerSessionService {
|
||||
}
|
||||
);
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] do_auth response:',
|
||||
JSON.stringify(response, null, 2)
|
||||
);
|
||||
|
||||
// do_auth returns { js: true } on success
|
||||
if (response?.js === true) {
|
||||
console.log('[StalkerSession] do_auth successful');
|
||||
return true;
|
||||
}
|
||||
|
||||
console.warn('[StalkerSession] do_auth returned:', response?.js);
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.error('[StalkerSession] do_auth error:', error);
|
||||
@@ -358,50 +312,14 @@ export class StalkerSessionService {
|
||||
token: string;
|
||||
accountInfo?: StalkerProfileResponse['js']['account_info'];
|
||||
}> {
|
||||
console.log('[StalkerSession] Starting full authentication flow...');
|
||||
console.log('[StalkerSession] Portal URL:', portalUrl);
|
||||
console.log('[StalkerSession] MAC Address:', macAddress);
|
||||
console.log('[StalkerSession] Serial Number:', serialNumber);
|
||||
console.log(
|
||||
'[StalkerSession] Device ID 1:',
|
||||
deviceId1
|
||||
? deviceId1.substring(0, 16) + '... (provided)'
|
||||
: '(will be auto-generated)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Device ID 2:',
|
||||
deviceId2
|
||||
? deviceId2.substring(0, 16) + '... (provided)'
|
||||
: '(will be auto-generated)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Signature 1:',
|
||||
signature1
|
||||
? signature1.substring(0, 16) + '... (provided)'
|
||||
: '(empty)'
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Signature 2:',
|
||||
signature2
|
||||
? signature2.substring(0, 16) + '... (provided)'
|
||||
: '(empty)'
|
||||
);
|
||||
|
||||
// Step 1: Handshake to get token and random
|
||||
console.log('[StalkerSession] Step 1: Performing handshake...');
|
||||
const { token, random } = await this.performHandshake(
|
||||
portalUrl,
|
||||
macAddress
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Step 1 complete: Token and random obtained'
|
||||
);
|
||||
|
||||
// Step 2: Get profile to activate token and get account info
|
||||
// The random from handshake must be used in auth_second_step
|
||||
console.log(
|
||||
'[StalkerSession] Step 2: Getting profile with handshake random (activates token)...'
|
||||
);
|
||||
try {
|
||||
const profileResponse = await this.getProfile(
|
||||
portalUrl,
|
||||
@@ -425,10 +343,6 @@ export class StalkerSessionService {
|
||||
throw new Error(`Profile error: ${errorMsg}`);
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] Step 2 complete: Profile obtained, token activated'
|
||||
);
|
||||
console.log('[StalkerSession] Authentication successful!');
|
||||
return {
|
||||
token,
|
||||
accountInfo: profileResponse?.js?.account_info,
|
||||
@@ -448,30 +362,14 @@ export class StalkerSessionService {
|
||||
async ensureToken(
|
||||
playlist: Playlist
|
||||
): Promise<{ token: string | null; serialNumber?: string }> {
|
||||
console.log(
|
||||
'[StalkerSession] Ensuring token for playlist:',
|
||||
playlist._id
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Is full stalker portal:',
|
||||
playlist.isFullStalkerPortal
|
||||
);
|
||||
|
||||
// If not a full stalker portal, no token needed
|
||||
if (!playlist.isFullStalkerPortal) {
|
||||
console.log(
|
||||
'[StalkerSession] Not a full stalker portal, no token needed'
|
||||
);
|
||||
return { token: null };
|
||||
}
|
||||
|
||||
// Check in-memory cache first (valid for current session only)
|
||||
const cachedToken = this.getCachedToken(playlist._id);
|
||||
if (cachedToken) {
|
||||
console.log(
|
||||
'[StalkerSession] Using cached token:',
|
||||
cachedToken.substring(0, 10) + '...'
|
||||
);
|
||||
return { token: cachedToken };
|
||||
}
|
||||
|
||||
@@ -496,21 +394,8 @@ export class StalkerSessionService {
|
||||
let serialNumber = playlist.stalkerSerialNumber;
|
||||
if (!serialNumber) {
|
||||
serialNumber = STALKER_SERIAL_NUMBER;
|
||||
console.log(
|
||||
'[StalkerSession] Generated new serial number:',
|
||||
serialNumber
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
'[StalkerSession] Using stored serial number:',
|
||||
serialNumber
|
||||
);
|
||||
}
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] No cached token, performing full authentication...'
|
||||
);
|
||||
|
||||
// Create the authentication promise and store it to prevent concurrent auth attempts
|
||||
// Use async/await wrapper to properly clean up on both success and failure
|
||||
const authPromise = (async () => {
|
||||
@@ -520,9 +405,6 @@ export class StalkerSessionService {
|
||||
playlist.macAddress,
|
||||
serialNumber
|
||||
);
|
||||
console.log(
|
||||
'[StalkerSession] Authentication complete, token cached'
|
||||
);
|
||||
this.setCachedToken(playlist._id, token);
|
||||
return { token, serialNumber };
|
||||
} finally {
|
||||
@@ -586,11 +468,6 @@ export class StalkerSessionService {
|
||||
const { token } = await this.ensureToken(playlist);
|
||||
const serialNumber = playlist.stalkerSerialNumber;
|
||||
|
||||
console.log(
|
||||
'[StalkerSession] Making authenticated request:',
|
||||
params['action']
|
||||
);
|
||||
|
||||
try {
|
||||
const response = await this.dataService.sendIpcEvent(
|
||||
STALKER_REQUEST,
|
||||
@@ -605,15 +482,7 @@ export class StalkerSessionService {
|
||||
|
||||
// Check for authorization failure in response
|
||||
if (this.isAuthorizationError(response)) {
|
||||
console.warn(
|
||||
'[StalkerSession] Authorization error detected in response:',
|
||||
response
|
||||
);
|
||||
|
||||
if (retryOnAuthFailure && playlist.isFullStalkerPortal) {
|
||||
console.log(
|
||||
'[StalkerSession] Clearing token and retrying with fresh auth...'
|
||||
);
|
||||
// Clear cached token to force re-authentication
|
||||
this.clearCachedToken(playlist._id);
|
||||
// Retry once with fresh authentication
|
||||
@@ -635,9 +504,6 @@ export class StalkerSessionService {
|
||||
retryOnAuthFailure &&
|
||||
playlist.isFullStalkerPortal
|
||||
) {
|
||||
console.log(
|
||||
'[StalkerSession] Clearing token and retrying with fresh auth (caught error)...'
|
||||
);
|
||||
// Clear cached token and retry with new handshake
|
||||
this.clearCachedToken(playlist._id);
|
||||
return this.makeAuthenticatedRequest<T>(
|
||||
|
||||
Reference in new issue
Block a user