mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-05 01:39:08 +00:00
verbose logs cleanup
This commit is contained in:
parent
674dbcf818
commit
2314d1db86
9 changed files with 265 additions and 266 deletions
|
|
@ -132,9 +132,10 @@ const StreamCard = memo(({
|
||||||
showAlert('Already Downloading', 'This download has already started for this exact link.');
|
showAlert('Already Downloading', 'This download has already started for this exact link.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch { }
|
||||||
// Show immediate feedback on both platforms
|
// 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 parent: any = stream as any;
|
||||||
const inferredTitle = parentTitle || stream.name || stream.title || parent.metaName || 'Content';
|
const inferredTitle = parentTitle || stream.name || stream.title || parent.metaName || 'Content';
|
||||||
const inferredType: 'movie' | 'series' = parentType || (parent.kind === 'series' || parent.type === 'series' ? 'series' : 'movie');
|
const inferredType: 'movie' | 'series' = parentType || (parent.kind === 'series' || parent.type === 'series' ? 'series' : 'movie');
|
||||||
|
|
@ -172,99 +173,101 @@ const StreamCard = memo(({
|
||||||
tmdbId: tmdbId,
|
tmdbId: tmdbId,
|
||||||
});
|
});
|
||||||
showAlert('Download Started', 'Your download has been added to the queue.');
|
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]);
|
}, [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;
|
const isDebrid = streamInfo.isDebrid;
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[
|
style={[
|
||||||
styles.streamCard,
|
styles.streamCard,
|
||||||
isLoading && styles.streamCardLoading,
|
isLoading && styles.streamCardLoading,
|
||||||
isDebrid && styles.streamCardHighlighted
|
isDebrid && styles.streamCardHighlighted
|
||||||
]}
|
]}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={handleLongPress}
|
onLongPress={handleLongPress}
|
||||||
disabled={isLoading}
|
disabled={isLoading}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
>
|
>
|
||||||
{/* Scraper Logo */}
|
{/* Scraper Logo */}
|
||||||
{showLogos && scraperLogo && (
|
{showLogos && scraperLogo && (
|
||||||
<View style={styles.scraperLogoContainer}>
|
<View style={styles.scraperLogoContainer}>
|
||||||
{scraperLogo.toLowerCase().endsWith('.svg') || scraperLogo.toLowerCase().includes('.svg?') ? (
|
{scraperLogo.toLowerCase().endsWith('.svg') || scraperLogo.toLowerCase().includes('.svg?') ? (
|
||||||
<Image
|
<Image
|
||||||
source={{ uri: scraperLogo }}
|
source={{ uri: scraperLogo }}
|
||||||
style={styles.scraperLogo}
|
style={styles.scraperLogo}
|
||||||
resizeMode="contain"
|
resizeMode="contain"
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<FastImage
|
<FastImage
|
||||||
source={{ uri: scraperLogo }}
|
source={{ uri: scraperLogo }}
|
||||||
style={styles.scraperLogo}
|
style={styles.scraperLogo}
|
||||||
resizeMode={FastImage.resizeMode.contain}
|
resizeMode={FastImage.resizeMode.contain}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<View style={styles.streamDetails}>
|
<View style={styles.streamDetails}>
|
||||||
<View style={styles.streamNameRow}>
|
<View style={styles.streamNameRow}>
|
||||||
<View style={styles.streamTitleContainer}>
|
<View style={styles.streamTitleContainer}>
|
||||||
<Text style={[styles.streamName, { color: theme.colors.highEmphasis }]}>
|
<Text style={[styles.streamName, { color: theme.colors.highEmphasis }]}>
|
||||||
{streamInfo.displayName}
|
{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>
|
</Text>
|
||||||
{streamInfo.subTitle && (
|
|
||||||
<Text style={[styles.streamAddonName, { color: theme.colors.mediumEmphasis }]}>
|
|
||||||
{streamInfo.subTitle}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
</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>
|
||||||
|
|
||||||
|
<View style={styles.streamMetaRow}>
|
||||||
|
{streamInfo.isDolby && (
|
||||||
|
<QualityBadge type="VISION" />
|
||||||
|
)}
|
||||||
|
|
||||||
{settings?.enableDownloads !== false && (
|
{streamInfo.size && (
|
||||||
<TouchableOpacity
|
<View style={[styles.chip, { backgroundColor: theme.colors.darkGray }]}>
|
||||||
style={[styles.streamAction, { marginLeft: 8, backgroundColor: theme.colors.elevation2 }]}
|
<Text style={[styles.chipText, { color: theme.colors.white }]}>💾 {streamInfo.size}</Text>
|
||||||
onPress={handleDownload}
|
</View>
|
||||||
activeOpacity={0.7}
|
)}
|
||||||
>
|
|
||||||
<MaterialIcons
|
{streamInfo.isDebrid && (
|
||||||
name="download"
|
<View style={[styles.chip, { backgroundColor: theme.colors.success }]}>
|
||||||
size={20}
|
<Text style={[styles.chipText, { color: theme.colors.white }]}>DEBRID</Text>
|
||||||
color={theme.colors.highEmphasis}
|
</View>
|
||||||
/>
|
)}
|
||||||
</TouchableOpacity>
|
</View>
|
||||||
)}
|
</View>
|
||||||
</TouchableOpacity>
|
|
||||||
|
|
||||||
|
{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>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,7 @@ const AppleTVHero: React.FC<AppleTVHeroProps> = ({
|
||||||
if (url) {
|
if (url) {
|
||||||
const bestUrl = TrailerService.getBestFormatUrl(url);
|
const bestUrl = TrailerService.getBestFormatUrl(url);
|
||||||
setTrailerUrl(bestUrl);
|
setTrailerUrl(bestUrl);
|
||||||
logger.info('[AppleTVHero] Trailer URL loaded:', bestUrl);
|
// logger.info('[AppleTVHero] Trailer URL loaded:', bestUrl);
|
||||||
} else {
|
} else {
|
||||||
logger.info('[AppleTVHero] No trailer found for:', currentItem.name);
|
logger.info('[AppleTVHero] No trailer found for:', currentItem.name);
|
||||||
setTrailerUrl(null);
|
setTrailerUrl(null);
|
||||||
|
|
@ -997,7 +997,7 @@ const AppleTVHero: React.FC<AppleTVHeroProps> = ({
|
||||||
{/* Background Images with Crossfade */}
|
{/* Background Images with Crossfade */}
|
||||||
<View style={styles.backgroundContainer}>
|
<View style={styles.backgroundContainer}>
|
||||||
{/* Current Image - Always visible as base */}
|
{/* Current Image - Always visible as base */}
|
||||||
<Animated.View style={[styles.imageWrapper, backgroundParallaxStyle]}>
|
<Animated.View style={[styles.imageWrapper, backgroundParallaxStyle, { opacity: thumbnailOpacity }]}>
|
||||||
<FastImage
|
<FastImage
|
||||||
source={{
|
source={{
|
||||||
uri: bannerUrl,
|
uri: bannerUrl,
|
||||||
|
|
@ -1441,7 +1441,7 @@ const styles = StyleSheet.create({
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
height: 40,
|
height: 400, // Increased to cover action buttons with dark background
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
},
|
},
|
||||||
// Loading & Empty States
|
// Loading & Empty States
|
||||||
|
|
|
||||||
|
|
@ -351,7 +351,6 @@ const CompactCommentCard: React.FC<{
|
||||||
onPressIn={() => setIsPressed(true)}
|
onPressIn={() => setIsPressed(true)}
|
||||||
onPressOut={() => setIsPressed(false)}
|
onPressOut={() => setIsPressed(false)}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log('CompactCommentCard: TouchableOpacity pressed for comment:', comment.id);
|
|
||||||
onPress();
|
onPress();
|
||||||
}}
|
}}
|
||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
|
|
@ -789,26 +788,21 @@ export const CommentsSection: React.FC<CommentsSectionProps> = ({
|
||||||
}, [loading]);
|
}, [loading]);
|
||||||
|
|
||||||
// Debug logging
|
// Debug logging
|
||||||
console.log('CommentsSection: Comments data:', comments);
|
// Debug logging removed per user request
|
||||||
console.log('CommentsSection: Comments length:', comments?.length);
|
|
||||||
console.log('CommentsSection: Loading:', loading);
|
|
||||||
console.log('CommentsSection: Error:', error);
|
|
||||||
|
|
||||||
const renderComment = useCallback(({ item }: { item: TraktContentComment }) => {
|
const renderComment = useCallback(({ item }: { item: TraktContentComment }) => {
|
||||||
// Safety check for null/undefined items
|
// Safety check for null/undefined items
|
||||||
if (!item || !item.id) {
|
if (!item || !item.id) {
|
||||||
console.log('CommentsSection: Invalid comment item:', item);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('CommentsSection: Rendering comment:', item.id);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CompactCommentCard
|
<CompactCommentCard
|
||||||
comment={item}
|
comment={item}
|
||||||
theme={currentTheme}
|
theme={currentTheme}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log('CommentsSection: Comment pressed:', item.id);
|
|
||||||
onCommentPress?.(item);
|
onCommentPress?.(item);
|
||||||
}}
|
}}
|
||||||
isSpoilerRevealed={true}
|
isSpoilerRevealed={true}
|
||||||
|
|
|
||||||
|
|
@ -925,7 +925,7 @@ const HeroSection: React.FC<HeroSectionProps> = memo(({
|
||||||
// Handle trailer preload completion
|
// Handle trailer preload completion
|
||||||
const handleTrailerPreloaded = useCallback(() => {
|
const handleTrailerPreloaded = useCallback(() => {
|
||||||
setTrailerPreloaded(true);
|
setTrailerPreloaded(true);
|
||||||
logger.info('HeroSection', 'Trailer preloaded successfully');
|
// logger.info('HeroSection', 'Trailer preloaded successfully');
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Handle smooth transition when trailer is ready to play
|
// Handle smooth transition when trailer is ready to play
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
|
||||||
// Only show loading spinner if not hidden
|
// Only show loading spinner if not hidden
|
||||||
loadingOpacity.value = hideLoadingSpinner ? 0 : 1;
|
loadingOpacity.value = hideLoadingSpinner ? 0 : 1;
|
||||||
onLoadStart?.();
|
onLoadStart?.();
|
||||||
logger.info('TrailerPlayer', 'Video load started');
|
// logger.info('TrailerPlayer', 'Video load started');
|
||||||
}, [loadingOpacity, onLoadStart, hideLoadingSpinner, isComponentMounted]);
|
}, [loadingOpacity, onLoadStart, hideLoadingSpinner, isComponentMounted]);
|
||||||
|
|
||||||
const handleLoad = useCallback((data: OnLoadData) => {
|
const handleLoad = useCallback((data: OnLoadData) => {
|
||||||
|
|
@ -262,7 +262,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
|
||||||
loadingOpacity.value = withTiming(0, { duration: 300 });
|
loadingOpacity.value = withTiming(0, { duration: 300 });
|
||||||
setDuration(data.duration * 1000); // Convert to milliseconds
|
setDuration(data.duration * 1000); // Convert to milliseconds
|
||||||
onLoad?.();
|
onLoad?.();
|
||||||
logger.info('TrailerPlayer', 'Video loaded successfully');
|
// logger.info('TrailerPlayer', 'Video loaded successfully');
|
||||||
}, [loadingOpacity, onLoad, isComponentMounted]);
|
}, [loadingOpacity, onLoad, isComponentMounted]);
|
||||||
|
|
||||||
const handleError = useCallback((error: any) => {
|
const handleError = useCallback((error: any) => {
|
||||||
|
|
@ -420,7 +420,7 @@ const TrailerPlayer = React.forwardRef<any, TrailerPlayerProps>(({
|
||||||
</Animated.View>
|
</Animated.View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Video controls overlay */}
|
{/* Video controls overlay */}
|
||||||
{!hideControls && (
|
{!hideControls && (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.videoOverlay}
|
style={styles.videoOverlay}
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
|
||||||
});
|
});
|
||||||
setDownloads(restored);
|
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%
|
if (d.progress <= prev || d.progress - prev < 2) return; // notify every 2%
|
||||||
lastNotifyRef.current.set(d.id, d.progress);
|
lastNotifyRef.current.set(d.id, d.progress);
|
||||||
await notificationService.notifyDownloadProgress(d.title, d.progress, d.downloadedBytes, d.totalBytes);
|
await notificationService.notifyDownloadProgress(d.title, d.progress, d.downloadedBytes, d.totalBytes);
|
||||||
} catch {}
|
} catch { }
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const notifyCompleted = useCallback(async (d: DownloadItem) => {
|
const notifyCompleted = useCallback(async (d: DownloadItem) => {
|
||||||
try {
|
try {
|
||||||
if (appStateRef.current === 'active') return;
|
if (appStateRef.current === 'active') return;
|
||||||
await notificationService.notifyDownloadComplete(d.title);
|
await notificationService.notifyDownloadComplete(d.title);
|
||||||
} catch {}
|
} catch { }
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mmkvStorage.setItem(STORAGE_KEY, JSON.stringify(downloads)).catch(() => {});
|
mmkvStorage.setItem(STORAGE_KEY, JSON.stringify(downloads)).catch(() => { });
|
||||||
}, [downloads]);
|
}, [downloads]);
|
||||||
|
|
||||||
const updateDownload = useCallback((id: string, updater: (d: DownloadItem) => DownloadItem) => {
|
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}`;
|
const fileUri = extension ? `${baseDir}downloads/${uniqueId}.${extension}` : `${baseDir}downloads/${uniqueId}`;
|
||||||
|
|
||||||
// Ensure directory exists
|
// Ensure directory exists
|
||||||
await FileSystem.makeDirectoryAsync(`${baseDir}downloads`, { intermediates: true }).catch(() => {});
|
await FileSystem.makeDirectoryAsync(`${baseDir}downloads`, { intermediates: true }).catch(() => { });
|
||||||
|
|
||||||
const createdAt = Date.now();
|
const createdAt = Date.now();
|
||||||
const newItem: DownloadItem = {
|
const newItem: DownloadItem = {
|
||||||
|
|
@ -515,8 +515,8 @@ export const DownloadsProvider: React.FC<{ children: React.ReactNode }> = ({ chi
|
||||||
resumablesRef.current.set(compoundId, resumable);
|
resumablesRef.current.set(compoundId, resumable);
|
||||||
lastBytesRef.current.set(compoundId, { bytes: 0, time: Date.now() });
|
lastBytesRef.current.set(compoundId, { bytes: 0, time: Date.now() });
|
||||||
|
|
||||||
try {
|
// Start download in background (non-blocking) to allow UI success alert
|
||||||
const result = await resumable.downloadAsync();
|
resumable.downloadAsync().then(async (result) => {
|
||||||
|
|
||||||
// Check if download was paused during download
|
// Check if download was paused during download
|
||||||
const currentItem = downloadsRef.current.find(d => d.id === compoundId);
|
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);
|
if (done) notifyCompleted({ ...done, status: 'completed', progress: 100, fileUri: result.uri } as DownloadItem);
|
||||||
resumablesRef.current.delete(compoundId);
|
resumablesRef.current.delete(compoundId);
|
||||||
lastBytesRef.current.delete(compoundId);
|
lastBytesRef.current.delete(compoundId);
|
||||||
} catch (e: any) {
|
}).catch(async (e: any) => {
|
||||||
// If user paused, keep paused state, else error
|
// If user paused, keep paused state, else error
|
||||||
const current = downloadsRef.current.find(d => d.id === compoundId);
|
const current = downloadsRef.current.find(d => d.id === compoundId);
|
||||||
if (current && current.status === 'paused') {
|
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() }));
|
updateDownload(compoundId, (d) => ({ ...d, status: 'error', updatedAt: Date.now() }));
|
||||||
// Keep resumable for potential retry
|
// Keep resumable for potential retry
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}, [updateDownload, resumeDownload]);
|
}, [updateDownload, resumeDownload]);
|
||||||
|
|
||||||
const pauseDownload = useCallback(async (id: string) => {
|
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);
|
const resumable = resumablesRef.current.get(id);
|
||||||
try {
|
try {
|
||||||
if (resumable) {
|
if (resumable) {
|
||||||
try { await resumable.pauseAsync(); } catch {}
|
try { await resumable.pauseAsync(); } catch { }
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
resumablesRef.current.delete(id);
|
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);
|
const item = downloadsRef.current.find(d => d.id === id);
|
||||||
if (item?.fileUri) {
|
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));
|
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 removeDownload = useCallback(async (id: string) => {
|
||||||
const item = downloadsRef.current.find(d => d.id === id);
|
const item = downloadsRef.current.find(d => d.id === id);
|
||||||
if (item?.fileUri && item.status === 'completed') {
|
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));
|
setDownloads(prev => prev.filter(d => d.id !== id));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export const useTraktComments = ({
|
||||||
const traktService = TraktService.getInstance();
|
const traktService = TraktService.getInstance();
|
||||||
let fetchedComments: TraktContentComment[] = [];
|
let fetchedComments: TraktContentComment[] = [];
|
||||||
|
|
||||||
console.log(`[useTraktComments] Loading comments for ${type} - IMDb: ${imdbId}, TMDB: ${tmdbId}, page: ${pageNum}`);
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'movie':
|
case 'movie':
|
||||||
|
|
@ -87,10 +87,10 @@ export const useTraktComments = ({
|
||||||
setComments(prevComments => {
|
setComments(prevComments => {
|
||||||
if (append) {
|
if (append) {
|
||||||
const newComments = [...prevComments, ...fetchedComments];
|
const newComments = [...prevComments, ...fetchedComments];
|
||||||
console.log(`[useTraktComments] Appended ${fetchedComments.length} comments, total: ${newComments.length}`);
|
|
||||||
return newComments;
|
return newComments;
|
||||||
} else {
|
} else {
|
||||||
console.log(`[useTraktComments] Loaded ${fetchedComments.length} comments`);
|
|
||||||
return fetchedComments;
|
return fetchedComments;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export class TrailerService {
|
||||||
// Try local server first, fallback to XPrime if it fails
|
// Try local server first, fallback to XPrime if it fails
|
||||||
const localResult = await this.getTrailerFromLocalServer(title, year, tmdbId, type);
|
const localResult = await this.getTrailerFromLocalServer(title, year, tmdbId, type);
|
||||||
if (localResult) {
|
if (localResult) {
|
||||||
logger.info('TrailerService', 'Returning trailer URL from local server');
|
// logger.info('TrailerService', 'Returning trailer URL from local server');
|
||||||
return localResult;
|
return localResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,23 +88,25 @@ export class TrailerService {
|
||||||
signal: controller.signal,
|
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);
|
clearTimeout(timeoutId);
|
||||||
|
|
||||||
const elapsed = Date.now() - startTime;
|
const elapsed = Date.now() - startTime;
|
||||||
const contentType = response.headers.get('content-type') || 'unknown';
|
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
|
// Read body as text first so we can log it even on non-200s
|
||||||
let rawText = '';
|
let rawText = '';
|
||||||
try {
|
try {
|
||||||
rawText = await response.text();
|
rawText = await response.text();
|
||||||
if (rawText) {
|
if (rawText) {
|
||||||
|
/*
|
||||||
const preview = rawText.length > 200 ? `${rawText.slice(0, 200)}...` : rawText;
|
const preview = rawText.length > 200 ? `${rawText.slice(0, 200)}...` : rawText;
|
||||||
logger.info('TrailerService', `Local server body preview: ${preview}`);
|
logger.info('TrailerService', `Local server body preview: ${preview}`);
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
logger.info('TrailerService', 'Local server body is empty');
|
// logger.info('TrailerService', 'Local server body is empty');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
||||||
|
|
@ -120,8 +122,8 @@ export class TrailerService {
|
||||||
let data: any = null;
|
let data: any = null;
|
||||||
try {
|
try {
|
||||||
data = rawText ? JSON.parse(rawText) : null;
|
data = rawText ? JSON.parse(rawText) : null;
|
||||||
const keys = typeof data === 'object' && data !== null ? Object.keys(data).join(',') : typeof data;
|
// const keys = typeof data === 'object' && data !== null ? Object.keys(data).join(',') : typeof data;
|
||||||
logger.info('TrailerService', `Local server JSON parsed. Keys/Type: ${keys}`);
|
// logger.info('TrailerService', `Local server JSON parsed. Keys/Type: ${keys}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
const msg = e instanceof Error ? `${e.name}: ${e.message}` : String(e);
|
||||||
logger.warn('TrailerService', `Failed to parse local server JSON: ${msg}`);
|
logger.warn('TrailerService', `Failed to parse local server JSON: ${msg}`);
|
||||||
|
|
@ -133,7 +135,7 @@ export class TrailerService {
|
||||||
return null;
|
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;
|
return data.url;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error && error.name === 'AbortError') {
|
if (error instanceof Error && error.name === 'AbortError') {
|
||||||
|
|
@ -248,13 +250,13 @@ export class TrailerService {
|
||||||
|
|
||||||
// Special check for Google Video CDN (YouTube direct streaming URLs)
|
// Special check for Google Video CDN (YouTube direct streaming URLs)
|
||||||
const isGoogleVideoCDN = hostname.includes('googlevideo.com') ||
|
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
|
// Check for video file extensions or streaming formats
|
||||||
const hasVideoFormat = /\.(mp4|m3u8|mpd|webm|mov|avi|mkv)$/i.test(urlObj.pathname) ||
|
const hasVideoFormat = /\.(mp4|m3u8|mpd|webm|mov|avi|mkv)$/i.test(urlObj.pathname) ||
|
||||||
url.includes('formats=') ||
|
url.includes('formats=') ||
|
||||||
url.includes('manifest') ||
|
url.includes('manifest') ||
|
||||||
url.includes('playlist');
|
url.includes('playlist');
|
||||||
|
|
||||||
return isValidDomain || hasVideoFormat || isGoogleVideoCDN;
|
return isValidDomain || hasVideoFormat || isGoogleVideoCDN;
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -288,7 +290,7 @@ export class TrailerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the original URL if no format optimization is needed
|
// 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;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1463,7 +1463,7 @@ export class TraktService {
|
||||||
if (matchingResult) {
|
if (matchingResult) {
|
||||||
const traktId = matchingResult[type]?.ids?.trakt;
|
const traktId = matchingResult[type]?.ids?.trakt;
|
||||||
if (traktId) {
|
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;
|
return traktId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1471,7 +1471,7 @@ export class TraktService {
|
||||||
// Fallback: try the first result if type filtering didn't work
|
// Fallback: try the first result if type filtering didn't work
|
||||||
const traktId = data[0][type]?.ids?.trakt;
|
const traktId = data[0][type]?.ids?.trakt;
|
||||||
if (traktId) {
|
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;
|
return traktId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2860,7 +2860,7 @@ export class TraktService {
|
||||||
if (data && data.length > 0) {
|
if (data && data.length > 0) {
|
||||||
const traktId = data[0][type === 'show' ? 'show' : type]?.ids?.trakt;
|
const traktId = data[0][type === 'show' ? 'show' : type]?.ids?.trakt;
|
||||||
if (traktId) {
|
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;
|
return traktId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2893,7 +2893,7 @@ export class TraktService {
|
||||||
|
|
||||||
const endpoint = `/movies/${traktId}/comments?page=${page}&limit=${limit}`;
|
const endpoint = `/movies/${traktId}/comments?page=${page}&limit=${limit}`;
|
||||||
const result = await this.apiRequest<TraktContentComment[]>(endpoint, 'GET');
|
const result = await this.apiRequest<TraktContentComment[]>(endpoint, 'GET');
|
||||||
console.log(`[TraktService] Movie comments response:`, result);
|
// console.log(`[TraktService] Movie comments response:`, result);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[TraktService] Failed to get movie comments:', error);
|
logger.error('[TraktService] Failed to get movie comments:', error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue