jneilliii / OctoPrint-PrusaSlicerThumbnails

91 stars 20 forks source link

Here we go again....with a REQUEST #111

Closed bolsoncerrado closed 1 year ago

bolsoncerrado commented 1 year ago

I'm not sure of the streamline of the plugin vs the upload process but here's my request: a small icon next to the thumbnail to "FORCE EXTRACT" thumbnail on a given filename if it was already there...

I still find VERY ODD that when the NAS drive I'm filling the octoprint uploads and thumbnails (different folders) shows the thumbnail of the very first upload on ALL octoprint instances of our farm but next ones do not.

So perhaps a "force extract" button (or "force process") would fix it for the offending instances :?

Doable? If not on the main branch perhaps a fork?

bolsoncerrado commented 1 year ago

Ps. You may want to edit the Simplify3D section in the main page with v5.1 native support for thumbnails ;)

Captura de pantalla 2023-05-16 a las 21 15 44
jneilliii commented 1 year ago

Ps. You may want to edit the Simplify3D section in the main page with v5.1 native support for thumbnails ;)

Captura de pantalla 2023-05-16 a las 21 15 44

Thanks for this info, readme updated.

As for your request, I don't see a reason why I couldn't add that. There is the crawl approach in the settings already, and curious if you run that on a broken instance where the thumbnails do not show what happens.

bolsoncerrado commented 1 year ago

Ah u mean the Rescan all files when pressing refresh in file list? I didn't even notice it!! Lemme try.

bolsoncerrado commented 1 year ago

Doh! Guess what? It worked!!! Thanks again!!!

bolsoncerrado commented 1 year ago

Now that I think of it.... Given it works by rescanning (manually with the scan button at least) the files in each instance, can you think of any trick to automate this? Cron job? Extra call after upload takes place? It would ease things on a Nas farm, really :)

I mean what I actually was looking for was that SCAN FILES option right next to the thumbnails icon if possible ;) But automation would be awesome too, just AFTER upload on a particular instance. That would ease things when there are hundreds of files on the uploads folder so it does not take forever to refresh.

jneilliii commented 1 year ago

Ah, I was going to recommend the rescan on refresh option but it seems from the email notice of your unedited post said that didn't work. The only thing I can think of that would impact this is if your symlink is broken for the plugin's data folder or the uploads folder. The way the plugin works is that it updates the .metadata.json file in the folder the file is in with URLs. Those URLs (assuming you don't use the uploads folder for your thumbnails) will pull from a virtual path that points to the folder <octoprint basedir as specified in instance config>/data/prusaslicerthumbnails/<filename>.png. One way to check if the issue is with metdata or the pathing would be to load <octoprint instance url>/api/files?recursive=true after logging into the web interface. You'll get a response of all your file data and each of those should have a thumbnail and thumbnail_src property like below.

{
      "date": 1676744159,
      "display": "CCR10_Credit Card Holder Divider+4.gcode",
      "gcodeAnalysis": {
        "analysisFirstFilamentPrintTime": 12.915100179077854,
        "analysisLastFilamentPrintTime": 2504.236985114749,
        "analysisPending": false,
        "analysisPrintTime": 2510.486712779706,
        "compensatedPrintTime": 2932.1935762637722,
        "dimensions": {
          "depth": 180.0,
          "height": 2.1600000858306885,
          "width": 187.97699546813965
        },
        "estimatedPrintTime": 2932.1935762637722,
        "filament": {
          "tool0": {
            "length": 3619.703125089407,
            "volume": 8.70640632112325
          }
        },
        "firstFilament": 0.08647794382676685,
        "lastFilament": 0.9912177336623507,
        "printingArea": {
          "maxX": 198.07699584960938,
          "maxY": 200.0,
          "maxZ": 2.1600000858306885,
          "minX": 10.100000381469727,
          "minY": 20.0,
          "minZ": 0
        },
        "progress": [
          [
            0,
            2932.1935762637722
          ],
          [
            0.08647794382676685,
            2505.7427729973065
          ],
          [
            0.16106135802811433,
            2444.894728634018
          ],
          [
            0.19104721767821,
            2384.7598220749755
          ],
          [
            0.21035849945933957,
            2324.745776222274
          ],
          [
            0.21938336983946544,
            2262.1978261899976
          ],
          [
            0.2338564338592065,
            2201.131064411629
          ],
          [
            0.24147420079296864,
            2140.7021567601596
          ],
          [
            0.25271023373166607,
            2080.6935533125848
          ],
          [
            0.28605789225607897,
            2019.8493900346928
          ],
          [
            0.3203759669503979,
            1959.6484706825336
          ],
          [
            0.33302603487952975,
            1899.126821361056
          ],
          [
            0.3493220949898799,
            1839.1013144549493
          ],
          [
            0.35725871295089695,
            1777.3318789254567
          ],
          [
            0.3690215432389719,
            1716.0047864274136
          ],
          [
            0.4047189952033715,
            1655.2939874576705
          ],
          [
            0.4415878781157291,
            1594.2903968219307
          ],
          [
            0.4543904400144176,
            1533.52782379571
          ],
          [
            0.47088751490281977,
            1472.4451363536505
          ],
          [
            0.48095904843763,
            1411.8623502252124
          ],
          [
            0.5019962846923781,
            1351.681736735858
          ],
          [
            0.5453392297668228,
            1289.7521702980403
          ],
          [
            0.5693362353397843,
            1228.5630725515325
          ],
          [
            0.5875038123492389,
            1166.6380641320152
          ],
          [
            0.5961890370698977,
            1106.4823782278356
          ],
          [
            0.6094976016857515,
            1045.2590704672464
          ],
          [
            0.6491252391382705,
            985.1515297247231
          ],
          [
            0.6827501594255136,
            923.7086091802687
          ],
          [
            0.6951160340477445,
            860.960882993825
          ],
          [
            0.7116408351124296,
            798.9188041223338
          ],
          [
            0.7226411955527213,
            737.0498736168279
          ],
          [
            0.7534519089472371,
            676.758557384763
          ],
          [
            0.7935578229406383,
            616.7362122615091
          ],
          [
            0.8104985166495688,
            554.9717959052439
          ],
          [
            0.8282294063825658,
            492.07286304274794
          ],
          [
            0.8373859761000361,
            431.8285144094543
          ],
          [
            0.8524482213657915,
            370.8658160590858
          ],
          [
            0.8929007125627305,
            309.63423572685224
          ],
          [
            0.9247858152882136,
            248.52294708032787
          ],
          [
            0.935765381096293,
            188.03383249791432
          ],
          [
            0.9522901821609782,
            125.78822005751908
          ],
          [
            0.9637064352455152,
            65.18893841153431
          ],
          [
            0.9912177336623507,
            14.420888061635196
          ],
          [
            1,
            0
          ]
        ]
      },
      "hash": "ae6925164e5e2213489b3884aeb086461ef619b9",
      "name": "CCR10_Credit Card Holder Divider+4.gcode",
      "origin": "local",
      "path": "CCR10_Credit Card Holder Divider+4.gcode",
      "prints": {
        "failure": 0,
        "last": {
          "date": 1676836901.9438758,
          "printTime": 2942.7508654482663,
          "success": true
        },
        "success": 7
      },
      "refs": {
        "download": "https://vlx.kicks-ass.net/downloads/files/local/CCR10_Credit%20Card%20Holder%20Divider%2B4.gcode",
        "resource": "https://vlx.kicks-ass.net/api/files/local/CCR10_Credit%20Card%20Holder%20Divider+4.gcode"
      },
      "size": 144268,
      "statistics": {
        "averagePrintTime": {
          "sp_printer": 2855.182739800973
        },
        "lastPowerCost": {
          "_default": 0.0091
        },
        "lastPrintTime": {
          "sp_printer": 2942.7508654482663
        }
      },
      "thumbnail": "plugin/prusaslicerthumbnails/thumbnail/CCR10_Credit%20Card%20Holder%20Divider%2B4.png?20230218181600",
      "thumbnail_src": "prusaslicerthumbnails",
      "type": "machinecode",
      "typePath": [
        "machinecode",
        "gcode"
      ]
    }

If you see that property in the response for your files, then that should be loading the images from that path. Check and verify the file exists in that path, or is seen from that symlink path via SSH I suppose. As an example in the listed item above the path would be <octoprint instance basedir>/data/prusaslicerthumbnails/CCR10_Credit Card Holder Divider+4.png (filename is url encoded).

bolsoncerrado commented 1 year ago

Yeah I forgot to click save the setting, that's why I deleted it, it works fine. I'm only worried if the uploads folder starts to grow and each rescan takes ages I won't be able to start a print locally Hmmm well we will see based on field experience, thanks again :)

jneilliii commented 1 year ago

For completeness, if you wanted to go the route of forcing this through cron or event manager (OctoPrint settings). The command would require an API key. In theory the following would spawn the same crawl process. Replace YOUR_API_KEY and OCTOPRINT_INSTANCE_URL with the appropriate values. Don't use the global API key, create a new Application key instead or use a user API key from user settings.

curl -s -H "Content-Type: application/json" -H "X-Api-Key: YOUR_API_KEY" -X POST -d '{"command": "crawl_files"}' http://OCTOPRINT_INSTANCE_URL/api/plugin/prusaslicerthumbnails
bolsoncerrado commented 1 year ago

Thabks!