Skip to content

Commit

Permalink
Fix metadata encoding on contribution stream page and optimize candid…
Browse files Browse the repository at this point in the history
…ate fetching.
  • Loading branch information
mhdzumair committed Jan 15, 2025
1 parent cfc764c commit 568294f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
20 changes: 15 additions & 5 deletions resources/js/scraperControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ function displayMatchResults(matches, torrentData) {

if (matches && matches.length > 0) {
matches.forEach(match => {
const safeMatchData = encodeURIComponent(JSON.stringify(match));
const safeTorrentData = encodeURIComponent(JSON.stringify(torrentData));
const safeMatchData = btoa(encodeURIComponent(JSON.stringify(match)));
const safeTorrentData = btoa(encodeURIComponent(JSON.stringify(torrentData)));

// Format runtime nicely
const runtime = match.runtime ? match.runtime.replace('min', '').trim() + ' minutes' : 'N/A';
Expand Down Expand Up @@ -792,9 +792,19 @@ function displayMatchResults(matches, torrentData) {
}

function selectMatchFromData(button) {
const match = JSON.parse(decodeURIComponent(button.getAttribute('data-match')));
const torrentData = JSON.parse(decodeURIComponent(button.getAttribute('data-torrent')));
selectMatch(match, torrentData);
try {
const matchData = button.getAttribute('data-match');
const torrentData = button.getAttribute('data-torrent');

// Decode using modern approach
const match = JSON.parse(decodeURIComponent(atob(matchData)));
const torrent = JSON.parse(decodeURIComponent(atob(torrentData)));

selectMatch(match, torrent);
} catch (error) {
console.error('Error parsing match data:', error);
showNotification('Error processing match data', 'error');
}
}

function formatTechnicalSpec(value, type) {
Expand Down
7 changes: 4 additions & 3 deletions scrapers/scraper_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ async def get_imdb_candidates() -> List[Dict[str, Any]]:
logging.error(f"Error searching IMDB: {e}")
return []

imdb_candidates = await get_imdb_candidates()
tmdb_candidates = await get_tmdb_candidates()
return tmdb_candidates + imdb_candidates
imdb_candidates, tmdb_candidates = await asyncio.gather(
get_imdb_candidates(), get_tmdb_candidates()
)
return imdb_candidates + tmdb_candidates


# Create a singleton instance with 30-minute cache TTL
Expand Down

0 comments on commit 568294f

Please sign in to comment.