diff --git a/local-scrapers-repo b/local-scrapers-repo index 4584f97..14cf821 160000 --- a/local-scrapers-repo +++ b/local-scrapers-repo @@ -1 +1 @@ -Subproject commit 4584f97614bc10382bd5f37edb762ee73dc7bc1c +Subproject commit 14cf821b7b126a418c7fb671719f151037948140 diff --git a/src/screens/ScraperSettingsScreen.tsx b/src/screens/ScraperSettingsScreen.tsx index 4cbab12..b1126d3 100644 --- a/src/screens/ScraperSettingsScreen.tsx +++ b/src/screens/ScraperSettingsScreen.tsx @@ -150,6 +150,10 @@ const createStyles = (colors: any) => StyleSheet.create({ fontSize: 12, color: colors.mediumGray, }, + scraperLanguage: { + fontSize: 12, + color: colors.mediumGray, + }, settingRow: { flexDirection: 'row', justifyContent: 'space-between', @@ -646,6 +650,14 @@ const ScraperSettingsScreen: React.FC = () => { {scraper.supportedTypes.join(', ')} + {scraper.contentLanguage && Array.isArray(scraper.contentLanguage) && scraper.contentLanguage.length > 0 && ( + <> + + + {scraper.contentLanguage.map(lang => lang.toUpperCase()).join(', ')} + + + )} { + // Ensure contentLanguage is an array (migration for older scrapers) + if (!scraper.contentLanguage) { + scraper.contentLanguage = ['en']; // Default to English + } else if (typeof scraper.contentLanguage === 'string') { + scraper.contentLanguage = [scraper.contentLanguage]; // Convert string to array + } this.installedScrapers.set(scraper.id, scraper); }); } @@ -85,6 +92,17 @@ class LocalScraperService { // Load scraper code from cache await this.loadScraperCode(); + // Auto-refresh repository on app startup if URL is configured + if (this.repositoryUrl) { + try { + logger.log('[LocalScraperService] Auto-refreshing repository on startup'); + await this.performRepositoryRefresh(); + } catch (error) { + logger.error('[LocalScraperService] Auto-refresh failed on startup:', error); + // Don't fail initialization if auto-refresh fails + } + } + this.initialized = true; logger.log('[LocalScraperService] Initialized with', this.installedScrapers.size, 'scrapers'); } catch (error) { @@ -115,7 +133,11 @@ class LocalScraperService { // Fetch and install scrapers from repository async refreshRepository(): Promise { await this.ensureInitialized(); - + await this.performRepositoryRefresh(); + } + + // Internal method to refresh repository without initialization check + private async performRepositoryRefresh(): Promise { if (!this.repositoryUrl) { throw new Error('No repository URL configured'); } @@ -160,10 +182,19 @@ class LocalScraperService { const scraperCode = response.data; // Store scraper info and code - this.installedScrapers.set(scraperInfo.id, { + const updatedScraperInfo = { ...scraperInfo, enabled: this.installedScrapers.get(scraperInfo.id)?.enabled ?? true // Preserve enabled state - }); + }; + + // Ensure contentLanguage is an array (migration for older scrapers) + if (!updatedScraperInfo.contentLanguage) { + updatedScraperInfo.contentLanguage = ['en']; // Default to English + } else if (typeof updatedScraperInfo.contentLanguage === 'string') { + updatedScraperInfo.contentLanguage = [updatedScraperInfo.contentLanguage]; // Convert string to array + } + + this.installedScrapers.set(scraperInfo.id, updatedScraperInfo); this.scraperCode.set(scraperInfo.id, scraperCode);