You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"code": "import requests\nfrom bs4 import BeautifulSoup\nimport json\n\n@node_entry\ndef scrape_meme_list() -> str:\n try:\n headers = {'User-Agent': 'Mozilla/5.0'}\n resp = requests.get('https://imgflip.com/memetemplates', headers=headers)\n resp.raise_for_status()\n soup = BeautifulSoup(resp.text, 'html.parser')\n memes = []\n for link in soup.select('.mt-box a.mt-title'):\n name = link.get_text(strip=True)\n href = link.get('href')\n if href and name:\n url = 'https://imgflip.com' + href\n memes.append({'name': name, 'url': url})\n # Return the list as a JSON string\n return json.dumps(memes)\n except Exception as e:\n return json.dumps([{'name': f'ERROR: {e}', 'url': ''}])",
11
+
"gui_code": "",
12
+
"gui_get_values_code": "",
13
+
"gui_state": {},
14
+
"colors": {
15
+
"title": "#2a2a2a",
16
+
"body": "#141414"
17
+
}
18
+
},
19
+
{
20
+
"uuid": "meme-selector",
21
+
"title": "Meme Selector",
22
+
"pos": [
23
+
208.49250000000006,
24
+
253.40999999999994
25
+
],
26
+
"code": "@node_entry\ndef meme_selector(selected_url: str) -> str:\n # This node simply passes the selected URL through.\n if not selected_url:\n return 'ERROR: No meme selected from the list.'\n return selected_url",
"gui_get_values_code": "import json\n\ndef get_values(widgets):\n # Get the selected item and extract its URL\n item = widgets['meme_list'].currentItem()\n if item:\n try:\n # The URL is stored in the item's data\n return {'selected_url': item.data(32)}\n except Exception:\n return {'selected_url': ''}\n return {'selected_url': ''}\n\ndef set_values(widgets, outputs):\n # This function is called when the node receives its input data\n meme_data_str = outputs.get('meme_data', '[]')\n try:\n memes = json.loads(meme_data_str)\n widgets['meme_list'].clear()\n for meme in memes:\n from PySide6.QtWidgets import QListWidgetItem\n item = QListWidgetItem(meme['name'])\n item.setData(32, meme['url']) # Store URL in the item's data role\n widgets['meme_list'].addItem(item)\n except json.JSONDecodeError:\n widgets['meme_list'].clear()\n widgets['meme_list'].addItem('Error: Invalid meme list data')",
29
+
"gui_state": {
30
+
"selected_url": ""
31
+
},
32
+
"colors": {
33
+
"title": "#2a2a2a",
34
+
"body": "#141414"
35
+
}
36
+
},
37
+
{
38
+
"uuid": "fetch-meme-template",
39
+
"title": "Fetch Meme Template",
40
+
"pos": [
41
+
525.685,
42
+
270.60249999999996
43
+
],
44
+
"code": "import requests\nfrom bs4 import BeautifulSoup\nfrom urllib.parse import urljoin\n\n@node_entry\ndef fetch_template_image(template_url: str) -> str:\n if not template_url or template_url.startswith('ERROR'):\n return template_url\n try:\n headers = {'User-Agent': 'Mozilla/5.0'}\n page_response = requests.get(template_url, headers=headers)\n page_response.raise_for_status()\n soup = BeautifulSoup(page_response.text, 'html.parser')\n img_tag = soup.find('img', {'id': 'im'})\n if not img_tag or not img_tag.get('src'):\n return 'ERROR: Could not find template image on page.'\n \n img_src = img_tag.get('src')\n img_url = urljoin(template_url, img_src)\n\n img_response = requests.get(img_url, headers=headers)\n img_response.raise_for_status()\n\n output_filename = 'downloaded_template.jpg'\n with open(output_filename, 'wb') as f:\n f.write(img_response.content)\n return output_filename\n except Exception as e:\n return f'ERROR: {e}'",
"gui_get_values_code": "def get_values(widgets):\n return {}\n\ndef set_values(widgets, outputs):\n from PySide6.QtGui import QPixmap\n from PySide6.QtCore import Qt\n image_path = outputs.get('output_1')\n if image_path and not image_path.startswith('ERROR'):\n pixmap = QPixmap(image_path)\n if not pixmap.isNull():\n scaled_pixmap = pixmap.scaled(widgets['image_label'].size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)\n widgets['image_label'].setPixmap(scaled_pixmap)\n else:\n widgets['image_label'].setText(f'Error: Could not load\\n{image_path}')\n else:\n widgets['image_label'].setText(f'Execution failed:\\n{image_path}')",
0 commit comments