Skip to content

Commit

Permalink
Merge pull request #66 from matiasjrossi/master
Browse files Browse the repository at this point in the history
Fix timelapse in 1.9.0+
  • Loading branch information
mikedmor authored Sep 2, 2023
2 parents 7aa9377 + 3116451 commit fd6db8b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions octoprint_multicam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import requests
import flask
import threading

import octoprint.plugin
import octoprint.settings
Expand All @@ -24,6 +25,7 @@ def __init__(self):
self.cacheBuster = True
self.snapshotSslValidation = True
self.webRtcServers = []
self._capture_mutex = threading.Lock()

def get_assets(self):
return {
Expand Down Expand Up @@ -154,16 +156,18 @@ def profile_to_webcam(profile):

return [profile_to_webcam(profile) for profile in profiles]

def take_webcam_snapshot(self, name):
webcam = next((webcam for webcam in self.get_webcam_configurations() if webcam.name == name), None)
def take_webcam_snapshot(self, provided_webcam):
webcam = provided_webcam.config

if webcam is None:
raise WebcamNotAbleToTakeSnapshotException(name)
raise WebcamNotAbleToTakeSnapshotException("provided_webcam is None")

snapshot_url = webcam.snapshot_url
# using compat.snapshot because snapshotDisplay is supposedly only for user
snapshot_url = webcam.compat.snapshot
can_snapshot = snapshot_url is not None and snapshot_url != "http://" and snapshot_url != ""

if not can_snapshot:
raise WebcamNotAbleToTakeSnapshotException(name)
raise WebcamNotAbleToTakeSnapshotException(webcam.name)

with self._capture_mutex:
self._logger.debug(f"Capturing image from {snapshot_url}")
Expand Down

0 comments on commit fd6db8b

Please sign in to comment.