Skip to content

Commit

Permalink
removed conditional index in process link loop, reset github action s…
Browse files Browse the repository at this point in the history
…chedule to 2 AM GMT+8 (18:00 GMT), modified tools_explored_without_screenshot_url.json to include screenshot urls
  • Loading branch information
raymelon committed Dec 16, 2024
1 parent d8a64ad commit 35f62d9
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/screenshot-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Generate Screenshots
on:
schedule:
# Runs at 2 AM GMT+8 (18:00 UTC the previous day)
- cron: '18 20 * * *'
- cron: '0 18 * * *'
workflow_dispatch: # Allows manual triggering

permissions:
Expand Down
29 changes: 14 additions & 15 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,20 @@ async def process_links(input_file, output_file):
# Process each link
for index, item in enumerate(data.get('links', [])):
print(f'index: {index}')
if index >= 50:
if 'url' in item:
screenshot_url = get_screenshot_url_with_api(item['url'])
if screenshot_url:
item['screenshot_url'] = screenshot_url
else:
print(
f"Failed to get screenshot for {item['url']}. Trying to capture locally...")

# trying to capture screenshot locally
screenshot_url = await capture_and_save_screenshot_without_api(
item['url'], f"screenshots/{item['label']}.png")

repo_host = 'https://raw.githubusercontent.com/tokwalabs/tools-explored/refs/heads/main'
item['screenshot_url'] = f'{repo_host}/{screenshot_url}'
if 'url' in item:
screenshot_url = get_screenshot_url_with_api(item['url'])
if screenshot_url:
item['screenshot_url'] = screenshot_url
else:
print(
f"Failed to get screenshot for {item['url']}. Trying to capture locally...")

# trying to capture screenshot locally
screenshot_url = await capture_and_save_screenshot_without_api(
item['url'], f"screenshots/{item['label']}.png")

repo_host = 'https://raw.githubusercontent.com/tokwalabs/tools-explored/refs/heads/main'
item['screenshot_url'] = f'{repo_host}/{screenshot_url}'

# Save the processed data
save_json(data, output_file)
Expand Down
Loading

0 comments on commit 35f62d9

Please sign in to comment.