verbose logs cleanup

This commit is contained in:
tapframe 2026-01-19 13:57:49 +05:30
parent 674dbcf818
commit 2314d1db86
9 changed files with 265 additions and 266 deletions

View file

@ -132,9 +132,10 @@ const StreamCard = memo(({
showAlert('Already Downloading', 'This download has already started for this exact link.');
return;
}
} catch {}
} catch { }
// Show immediate feedback on both platforms
showAlert('Starting Download', 'Download will be started.');
// Show immediate feedback on both platforms
// showAlert('Starting Download', 'Download will be started.');
const parent: any = stream as any;
const inferredTitle = parentTitle || stream.name || stream.title || parent.metaName || 'Content';
const inferredType: 'movie' | 'series' = parentType || (parent.kind === 'series' || parent.type === 'series' ? 'series' : 'movie');
@ -172,99 +173,101 @@ const StreamCard = memo(({
tmdbId: tmdbId,
});
showAlert('Download Started', 'Your download has been added to the queue.');
} catch {}
} catch (e: any) {
showAlert('Download Failed', e.message || 'Could not start download.');
}
}, [startDownload, stream.url, stream.headers, streamInfo.quality, showAlert, stream.name, stream.title, parentId, parentImdbId, parentTitle, parentType, parentSeason, parentEpisode, parentEpisodeTitle, parentPosterUrl, providerName]);
const isDebrid = streamInfo.isDebrid;
return (
<TouchableOpacity
style={[
styles.streamCard,
isLoading && styles.streamCardLoading,
isDebrid && styles.streamCardHighlighted
]}
onPress={onPress}
onLongPress={handleLongPress}
disabled={isLoading}
activeOpacity={0.7}
>
{/* Scraper Logo */}
{showLogos && scraperLogo && (
<View style={styles.scraperLogoContainer}>
{scraperLogo.toLowerCase().endsWith('.svg') || scraperLogo.toLowerCase().includes('.svg?') ? (
<Image
source={{ uri: scraperLogo }}
style={styles.scraperLogo}
resizeMode="contain"
/>
) : (
<FastImage
source={{ uri: scraperLogo }}
style={styles.scraperLogo}
resizeMode={FastImage.resizeMode.contain}
/>
)}
</View>
)}
style={[
styles.streamCard,
isLoading && styles.streamCardLoading,
isDebrid && styles.streamCardHighlighted
]}
onPress={onPress}
onLongPress={handleLongPress}
disabled={isLoading}
activeOpacity={0.7}
>
{/* Scraper Logo */}
{showLogos && scraperLogo && (
<View style={styles.scraperLogoContainer}>
{scraperLogo.toLowerCase().endsWith('.svg') || scraperLogo.toLowerCase().includes('.svg?') ? (
<Image
source={{ uri: scraperLogo }}
style={styles.scraperLogo}
resizeMode="contain"
/>
) : (
<FastImage
source={{ uri: scraperLogo }}
style={styles.scraperLogo}
resizeMode={FastImage.resizeMode.contain}
/>
)}
</View>
)}
<View style={styles.streamDetails}>
<View style={styles.streamNameRow}>
<View style={styles.streamTitleContainer}>
<Text style={[styles.streamName, { color: theme.colors.highEmphasis }]}>
{streamInfo.displayName}
<View style={styles.streamDetails}>
<View style={styles.streamNameRow}>
<View style={styles.streamTitleContainer}>
<Text style={[styles.streamName, { color: theme.colors.highEmphasis }]}>
{streamInfo.displayName}
</Text>
{streamInfo.subTitle && (
<Text style={[styles.streamAddonName, { color: theme.colors.mediumEmphasis }]}>
{streamInfo.subTitle}
</Text>
)}
</View>
{/* Show loading indicator if stream is loading */}
{isLoading && (
<View style={styles.loadingIndicator}>
<ActivityIndicator size="small" color={theme.colors.primary} />
<Text style={[styles.loadingText, { color: theme.colors.primary }]}>
{statusMessage || "Loading..."}
</Text>
{streamInfo.subTitle && (
<Text style={[styles.streamAddonName, { color: theme.colors.mediumEmphasis }]}>
{streamInfo.subTitle}
</Text>
)}
</View>
{/* Show loading indicator if stream is loading */}
{isLoading && (
<View style={styles.loadingIndicator}>
<ActivityIndicator size="small" color={theme.colors.primary} />
<Text style={[styles.loadingText, { color: theme.colors.primary }]}>
{statusMessage || "Loading..."}
</Text>
</View>
)}
</View>
<View style={styles.streamMetaRow}>
{streamInfo.isDolby && (
<QualityBadge type="VISION" />
)}
{streamInfo.size && (
<View style={[styles.chip, { backgroundColor: theme.colors.darkGray }]}>
<Text style={[styles.chipText, { color: theme.colors.white }]}>💾 {streamInfo.size}</Text>
</View>
)}
{streamInfo.isDebrid && (
<View style={[styles.chip, { backgroundColor: theme.colors.success }]}>
<Text style={[styles.chipText, { color: theme.colors.white }]}>DEBRID</Text>
</View>
)}
</View>
)}
</View>
<View style={styles.streamMetaRow}>
{streamInfo.isDolby && (
<QualityBadge type="VISION" />
)}
{settings?.enableDownloads !== false && (
<TouchableOpacity
style={[styles.streamAction, { marginLeft: 8, backgroundColor: theme.colors.elevation2 }]}
onPress={handleDownload}
activeOpacity={0.7}
>
<MaterialIcons
name="download"
size={20}
color={theme.colors.highEmphasis}
/>
</TouchableOpacity>
)}
</TouchableOpacity>
{streamInfo.size && (
<View style={[styles.chip, { backgroundColor: theme.colors.darkGray }]}>
<Text style={[styles.chipText, { color: theme.colors.white }]}>💾 {streamInfo.size}</Text>
</View>
)}
{streamInfo.isDebrid && (
<View style={[styles.chip, { backgroundColor: theme.colors.success }]}>
<Text style={[styles.chipText, { color: theme.colors.white }]}>DEBRID</Text>
</View>
)}
</View>
</View>
{settings?.enableDownloads !== false && (
<TouchableOpacity
style={[styles.streamAction, { marginLeft: 8, backgroundColor: theme.colors.elevation2 }]}
onPress={handleDownload}
activeOpacity={0.7}
>
<MaterialIcons
name="download"
size={20}
color={theme.colors.highEmphasis}
/>
</TouchableOpacity>
)}
</TouchableOpacity>
);
});

View file

@ -446,7 +446,7 @@ const AppleTVHero: React.FC<AppleTVHeroProps> = ({
if (url) {
const bestUrl = TrailerService.getBestFormatUrl(url);
setTrailerUrl(bestUrl);
logger.info('[AppleTVHero] Trailer URL loaded:', bestUrl);
// logger.info('[AppleTVHero] Trailer URL loaded:', bestUrl);
} else {
logger.info('[AppleTVHero] No trailer found for:', currentItem.name);
setTrailerUrl(null);
@ -997,7 +997,7 @@ const AppleTVHero: React.FC<AppleTVHeroProps> = ({
{/* Background Images with Crossfade */}
<View style={styles.backgroundContainer}>
{/* Current Image - Always visible as base */}
<Animated.View style={[styles.imageWrapper, backgroundParallaxStyle]}>
<Animated.View style={[styles.imageWrapper, backgroundParallaxStyle, { opacity: thumbnailOpacity }]}>
<FastImage
source={{
uri: bannerUrl,
@ -1441,7 +1441,7 @@ const styles = StyleSheet.create({
bottom: 0,
left: 0,
right: 0,
height: 40,
height: 400, // Increased to cover action buttons with dark background
pointerEvents: 'none',
},
// Loading & Empty States

View file

@ -351,7 +351,6 @@ const CompactCommentCard: React.FC<{
onPressIn={() => setIsPressed(true)}
onPressOut={() => setIsPressed(false)}
onPress={() => {
console.log('CompactCommentCard: TouchableOpacity pressed for comment:', comment.id);
onPress();
}}
activeOpacity={1}
@ -789,26 +788,21 @@ export const CommentsSection: React.FC<CommentsSectionProps> = ({
}, [loading]);
// Debug logging
console.log('CommentsSection: Comments data:', comments);
console.log('CommentsSection: Comments length:', comments?.length);
console.log('CommentsSection: Loading:', loading);
console.log('CommentsSection: Error:', error);
// Debug logging removed per user request
const renderComment = useCallback(({ item }: { item: TraktContentComment }) => {
// Safety check for null/undefined items
if (!item || !item.id) {
console.log('CommentsSection: Invalid comment item:', item);
return null;
}
console.log('CommentsSection: Rendering comment:', item.id);
return (
<CompactCommentCard
comment={item}
theme={currentTheme}
onPress={() => {
console.log('CommentsSection: Comment pressed:', item.id);
onCommentPress?.(item);
}}
isSpoilerRevealed={true}

View file

@ -925,7 +925,7 @@ const HeroSection: React.FC<HeroSectionProps> = memo(({
// Handle trailer preload completion
const handleTrailerPreloaded = useCallback(() => {
setTrailerPreloaded(true);
logger.info('HeroSection', 'Trailer preloaded successfully');
// logger.info('HeroSection', 'Trailer preloaded successfully');
}, []);
// Handle smooth transition when trailer is ready to play

View file

@ -252,7 +252,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
// Only show loading spinner if not hidden
loadingOpacity.value = hideLoadingSpinner ? 0 : 1;
onLoadStart?.();
logger.info('TrailerPlayer', 'Video load started');
// logger.info('TrailerPlayer', 'Video load started');
}, [loadingOpacity, onLoadStart, hideLoadingSpinner, isComponentMounted]);
const handleLoad = useCallback((data: OnLoadData) => {
@ -262,7 +262,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
loadingOpacity.value = withTiming(0, { duration: 300 });
setDuration(data.duration * 1000); // Convert to milliseconds
onLoad?.();
logger.info('TrailerPlayer', 'Video loaded successfully');
// logger.info('TrailerPlayer', 'Video loaded successfully');
}, [loadingOpacity, onLoad, isComponentMounted]);
const handleError = useCallback((error: any) => {
@ -420,7 +420,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
</Animated.View>
)}
{/* Video controls overlay */}
{/* Video controls overlay */}
{!hideControls && (
<TouchableOpacity
style={styles.videoOverlay}

View file

@ -183,7 +183,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
});
setDownloads(restored);
}
} catch {}
} catch { }
})();
}, []);
@ -209,18 +209,18 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
if (d.progress <= prev || d.progress - prev < 2) return; // notify every 2%
lastNotifyRef.current.set(d.id, d.progress);
await notificationService.notifyDownloadProgress(d.title, d.progress, d.downloadedBytes, d.totalBytes);
} catch {}
} catch { }
}, []);
const notifyCompleted = useCallback(async (d: DownloadItem) => {
try {
if (appStateRef.current === 'active') return;
await notificationService.notifyDownloadComplete(d.title);
} catch {}
} catch { }
}, []);
useEffect(() => {
mmkvStorage.setItem(STORAGE_KEY, JSON.stringify(downloads)).catch(() => {});
mmkvStorage.setItem(STORAGE_KEY, JSON.stringify(downloads)).catch(() => { });
}, [downloads]);
const updateDownload = useCallback((id: string, updater: (d: DownloadItem) => DownloadItem) => {
@ -443,7 +443,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
const fileUri = extension ? `${baseDir}downloads/${uniqueId}.${extension}` : `${baseDir}downloads/${uniqueId}`;
// Ensure directory exists
await FileSystem.makeDirectoryAsync(`${baseDir}downloads`, { intermediates: true }).catch(() => {});
await FileSystem.makeDirectoryAsync(`${baseDir}downloads`, { intermediates: true }).catch(() => { });
const createdAt = Date.now();
const newItem: DownloadItem = {
@ -515,8 +515,8 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
resumablesRef.current.set(compoundId, resumable);
lastBytesRef.current.set(compoundId, { bytes: 0, time: Date.now() });
try {
const result = await resumable.downloadAsync();
// Start download in background (non-blocking) to allow UI success alert
resumable.downloadAsync().then(async (result) => {
// Check if download was paused during download
const currentItem = downloadsRef.current.find(d => d.id === compoundId);
@ -581,7 +581,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
if (done) notifyCompleted({ ...done, status: 'completed', progress: 100, fileUri: result.uri } as DownloadItem);
resumablesRef.current.delete(compoundId);
lastBytesRef.current.delete(compoundId);
} catch (e: any) {
}).catch(async (e: any) => {
// If user paused, keep paused state, else error
const current = downloadsRef.current.find(d => d.id === compoundId);
if (current && current.status === 'paused') {
@ -634,7 +634,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
updateDownload(compoundId, (d) => ({ ...d, status: 'error', updatedAt: Date.now() }));
// Keep resumable for potential retry
}
}
});
}, [updateDownload, resumeDownload]);
const pauseDownload = useCallback(async (id: string) => {
@ -691,7 +691,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
const resumable = resumablesRef.current.get(id);
try {
if (resumable) {
try { await resumable.pauseAsync(); } catch {}
try { await resumable.pauseAsync(); } catch { }
}
} finally {
resumablesRef.current.delete(id);
@ -700,7 +700,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
const item = downloadsRef.current.find(d => d.id === id);
if (item?.fileUri) {
await FileSystem.deleteAsync(item.fileUri, { idempotent: true }).catch(() => {});
await FileSystem.deleteAsync(item.fileUri, { idempotent: true }).catch(() => { });
}
setDownloads(prev => prev.filter(d => d.id !== id));
}, []);
@ -708,7 +708,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
const removeDownload = useCallback(async (id: string) => {
const item = downloadsRef.current.find(d => d.id === id);
if (item?.fileUri && item.status === 'completed') {
await FileSystem.deleteAsync(item.fileUri, { idempotent: true }).catch(() => {});
await FileSystem.deleteAsync(item.fileUri, { idempotent: true }).catch(() => { });
}
setDownloads(prev => prev.filter(d => d.id !== id));
}, []);

View file

@ -60,7 +60,7 @@ export const useTraktComments = ({
const traktService = TraktService.getInstance();
let fetchedComments: TraktContentComment[] = [];
console.log(`[useTraktComments] Loading comments for ${type} - IMDb: ${imdbId}, TMDB: ${tmdbId}, page: ${pageNum}`);
switch (type) {
case 'movie':
@ -87,10 +87,10 @@ export const useTraktComments = ({
setComments(prevComments => {
if (append) {
const newComments = [...prevComments, ...fetchedComments];
console.log(`[useTraktComments] Appended ${fetchedComments.length} comments, total: ${newComments.length}`);
return newComments;
} else {
console.log(`[useTraktComments] Loaded ${fetchedComments.length} comments`);
return fetchedComments;
}
});

View file

@ -33,7 +33,7 @@ export class TrailerService {
// Try local server first, fallback to XPrime if it fails
const localResult = await this.getTrailerFromLocalServer(title, year, tmdbId, type);
if (localResult) {
logger.info('TrailerService', 'Returning trailer URL from local server');
// logger.info('TrailerService', 'Returning trailer URL from local server');
return localResult;
}
@ -88,23 +88,25 @@ export class TrailerService {
signal: controller.signal,
});
logger.info('TrailerService', `Fetch request completed. Response status: ${response.status}`);
// logger.info('TrailerService', `Fetch request completed. Response status: ${response.status}`);
clearTimeout(timeoutId);
const elapsed = Date.now() - startTime;
const contentType = response.headers.get('content-type') || 'unknown';
logger.info('TrailerService', `Local server response: status=${response.status} ok=${response.ok} content-type=${contentType} elapsedMs=${elapsed}`);
// logger.info('TrailerService', `Local server response: status=${response.status} ok=${response.ok} content-type=${contentType} elapsedMs=${elapsed}`);
// Read body as text first so we can log it even on non-200s
let rawText = '';
try {
rawText = await response.text();
if (rawText) {
/*
const preview = rawText.length > 200 ? `${rawText.slice(0, 200)}...` : rawText;
logger.info('TrailerService', `Local server body preview: ${preview}`);
*/
} else {
logger.info('TrailerService', 'Local server body is empty');
// logger.info('TrailerService', 'Local server body is empty');
}
} catch (e) {
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
@ -120,8 +122,8 @@ export class TrailerService {
let data: any = null;
try {
data = rawText ? JSON.parse(rawText) : null;
const keys = typeof data === 'object' && data !== null ? Object.keys(data).join(',') : typeof data;
logger.info('TrailerService', `Local server JSON parsed. Keys/Type: ${keys}`);
// const keys = typeof data === 'object' && data !== null ? Object.keys(data).join(',') : typeof data;
// logger.info('TrailerService', `Local server JSON parsed. Keys/Type: ${keys}`);
} catch (e) {
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
logger.warn('TrailerService', `Failed to parse local server JSON: ${msg}`);
@ -133,7 +135,7 @@ export class TrailerService {
return null;
}
logger.info('TrailerService', `Successfully found trailer: ${String(data.url).substring(0, 80)}...`);
// logger.info('TrailerService', `Successfully found trailer: ${String(data.url).substring(0, 80)}...`);
return data.url;
} catch (error) {
if (error instanceof Error && error.name === 'AbortError') {
@ -248,13 +250,13 @@ export class TrailerService {
// Special check for Google Video CDN (YouTube direct streaming URLs)
const isGoogleVideoCDN = hostname.includes('googlevideo.com') ||
hostname.includes('sn-') && hostname.includes('.googlevideo.com');
hostname.includes('sn-') && hostname.includes('.googlevideo.com');
// Check for video file extensions or streaming formats
const hasVideoFormat = /\.(mp4|m3u8|mpd|webm|mov|avi|mkv)$/i.test(urlObj.pathname) ||
url.includes('formats=') ||
url.includes('manifest') ||
url.includes('playlist');
url.includes('formats=') ||
url.includes('manifest') ||
url.includes('playlist');
return isValidDomain || hasVideoFormat || isGoogleVideoCDN;
} catch {
@ -288,7 +290,7 @@ export class TrailerService {
}
// Return the original URL if no format optimization is needed
logger.info('TrailerService', 'No format optimization applied');
// logger.info('TrailerService', 'No format optimization applied');
return url;
}

View file

@ -1463,7 +1463,7 @@ export class TraktService {
if (matchingResult) {
const traktId = matchingResult[type]?.ids?.trakt;
if (traktId) {
logger.log(`[TraktService] Found Trakt ID: ${traktId} for IMDb ID: ${fullImdbId}`);
// logger.log(`[TraktService] Found Trakt ID: ${traktId} for IMDb ID: ${fullImdbId}`);
return traktId;
}
}
@ -1471,7 +1471,7 @@ export class TraktService {
// Fallback: try the first result if type filtering didn't work
const traktId = data[0][type]?.ids?.trakt;
if (traktId) {
logger.log(`[TraktService] Found Trakt ID (fallback): ${traktId} for IMDb ID: ${fullImdbId}`);
// logger.log(`[TraktService] Found Trakt ID (fallback): ${traktId} for IMDb ID: ${fullImdbId}`);
return traktId;
}
}
@ -2860,7 +2860,7 @@ export class TraktService {
if (data && data.length > 0) {
const traktId = data[0][type === 'show' ? 'show' : type]?.ids?.trakt;
if (traktId) {
logger.log(`[TraktService] Found Trakt ID via TMDB: ${traktId} for TMDB ID: ${tmdbId}`);
// logger.log(`[TraktService] Found Trakt ID via TMDB: ${traktId} for TMDB ID: ${tmdbId}`);
return traktId;
}
}
@ -2893,7 +2893,7 @@ export class TraktService {
const endpoint = `/movies/${traktId}/comments?page=${page}&limit=${limit}`;
const result = await this.apiRequest<TraktContentComment[]>(endpoint, 'GET');
console.log(`[TraktService] Movie comments response:`, result);
// console.log(`[TraktService] Movie comments response:`, result);
return result;
} catch (error) {
logger.error('[TraktService] Failed to get movie comments:', error);