Skip to content

Commit

Permalink
Merge pull request #447 from danieldotnl/form-payload
Browse files Browse the repository at this point in the history
Use payload in form-submit when no input_values are given
  • Loading branch information
danieldotnl authored Nov 11, 2024
2 parents f86769e + d17891c commit a550eec
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions custom_components/multiscrape/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(
self._parser = parser
self._should_submit = True
self._cookies = None
self._payload = None

def notify_scrape_exception(self):
"""Make sure form is re-submitted after an exception."""
Expand Down Expand Up @@ -134,13 +135,16 @@ async def async_submit(self, main_resource):
self._config_name,
)

input_fields.update(self._input_values)
if self._input_values is not None:

_LOGGER.debug(
"%s # Merged input fields with input data in config. Result: %s",
self._config_name,
input_fields,
)
input_fields.update(self._input_values)

_LOGGER.debug(
"%s # Merged input fields with input data in config. Result: %s",
self._config_name,
input_fields,
)
self._payload = input_fields

if not method:
method = "POST"
Expand All @@ -152,7 +156,7 @@ async def async_submit(self, main_resource):
"form_submit",
submit_resource,
method=method,
request_data=input_fields,
request_data=self._payload,
cookies=self._cookies
)
_LOGGER.debug(
Expand Down

0 comments on commit a550eec

Please sign in to comment.