Skip to content

Commit d56a152

Browse files
committed
0.1.1
- updated extraction logic for improved performance - added github action workflow - added stalebot
1 parent c6bae83 commit d56a152

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

.github/stale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exemptLabels:
77
- enhancement
88
- bug
99
- solved
10+
- documentation
1011
# Label to use when marking an issue as stale
1112
staleLabel: stale
1213
# Comment to post when marking an issue as stale. Set to `false` to disable

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# PrusaSlicer Thumbnails
22

3+
![GitHub Downloads](https://badgen.net/github/assets-dl/jneilliii/OctoPrint-PrusaSlicerThumbnails/)
4+
35
This plugin will extract the embedded thumbnails from PrusaSlicer gcode files where the printer's profile ini file has the thumbnail option configured. This is default behavior for the Prusa Mini printer profile.
46

57
The thumbnail image extracted will always be the last resolution provided in the thumbnail setting. So for example the Prusa Mini setting is `thumbnails = 16x16,220x124` so the thumbnail that will be extracted will be 220x124 pixels as seen in the screenshots below. Check the Configuration section below for additional details.

octoprint_prusaslicerthumbnails/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,20 @@ def _extract_thumbnail(self, gcode_filename, thumbnail_filename):
5454
import re
5555
import base64
5656
regex = r"(?:^; thumbnail begin \d+x\d+ \d+)(?:\n|\r\n?)((?:.+(?:\n|\r\n?))+)(?:^; thumbnail end)"
57+
lineNum = 0
58+
collectedString = ""
5759
with open(gcode_filename,"rb") as gcode_file:
58-
test_str = gcode_file.read().decode('utf-8')
60+
for line in gcode_file:
61+
lineNum += 1
62+
gcode = octoprint.util.comm.gcode_command_for_cmd(line)
63+
extrusionMatch = octoprint.util.comm.regexes_parameters["floatE"].search(line)
64+
if gcode == "G1" and extrusionMatch:
65+
self._logger.debug("Line %d: Detected first extrusion. Read complete.", lineNum)
66+
break
67+
if line.startswith(";") or line.startswith("\n"):
68+
collectedString += line
69+
self._logger.debug(collectedString)
70+
test_str = collectedString
5971
test_str = test_str.replace(octoprint.util.to_native_str('\r\n'),octoprint.util.to_native_str('\n'))
6072
matches = re.findall(regex, test_str, re.MULTILINE)
6173
if len(matches) > 0:
@@ -148,7 +160,7 @@ def get_update_information(self):
148160
current=self._plugin_version,
149161

150162
# update method: pip
151-
pip="https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/archive/{target_version}.zip"
163+
pip="https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails/releases/latest/download/{target_version}.zip"
152164
)
153165
)
154166

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "PrusaSlicer Thumbnails"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "0.1.0"
17+
plugin_version = "0.1.1"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)