From f2b301218ff296fd46efc20e4378c4e17074f87c Mon Sep 17 00:00:00 2001
From: SebLaus <97241865+SebLaus@users.noreply.github.com>
Date: Wed, 1 Nov 2023 12:37:20 +0100
Subject: [PATCH 1/3] [IdealoBridge] Created
Checks the price of a given item on idealo.de. Can create an Alarm Message if a the price is lower than set or an Priceupdate if the price has changed.
---
bridges/IdealoBridge.php | 179 +++++++++++++++++++++++++++++++++++++++
1 file changed, 179 insertions(+)
create mode 100755 bridges/IdealoBridge.php
diff --git a/bridges/IdealoBridge.php b/bridges/IdealoBridge.php
new file mode 100755
index 00000000000..bbf478c7d9c
--- /dev/null
+++ b/bridges/IdealoBridge.php
@@ -0,0 +1,179 @@
+ [
+ 'name' => 'Idealo.de Link to productpage',
+ 'required' => true,
+ 'exampleValue' => 'https://www.idealo.de/preisvergleich/OffersOfProduct/202007367_-s7-pro-ultra-roborock.html'
+ ],
+ 'ExcludeNew' => [
+ 'name' => 'Priceupdate: Do not track new items',
+ 'type' => 'checkbox',
+ 'value' => 'c'
+ ],
+ 'ExcludeUsed' => [
+ 'name' => 'Priceupdate: Do not track used items',
+ 'type' => 'checkbox',
+ 'value' => 'uc'
+ ],
+ 'MaxPriceNew' => [
+ 'name' => 'Pricealarm: Maximum price for new Product',
+ 'type' => 'number'
+ ],
+ 'MaxPriceUsed' => [
+ 'name' => 'Pricealarm: Maximum price for used Product',
+ 'type' => 'number'
+ ],
+ ]
+ ];
+
+ public function getIcon()
+ {
+ return 'https://cdn.idealo.com/storage/ids-assets/ico/favicon.ico';
+ }
+
+ public function collectData()
+ {
+ $link = $this->getInput('Link');
+ $html = getSimpleHTMLDOM($link);
+
+ // Get Productname
+ $titleobj = $html->find('.oopStage-title',0);
+ $Productname = $titleobj->find('span', 0)->plaintext;
+
+ // Create product specific Cache Keys with the link
+ $KeyNEW = $link;
+ $KeyNEW .= 'NEW';
+
+ $KeyUSED = $link;
+ $KeyUSED .= 'USED';
+
+ // Load previous Price
+ $OldPriceNew = $this->loadCacheValue($KeyNEW);
+ $OldPriceUsed = $this->loadCacheValue($KeyUSED);
+
+ // First button is new. Found at oopStage-conditionButton-wrapper-text class (.)
+ $FirstButton = $html->find('.oopStage-conditionButton-wrapper-text',0);
+ if($FirstButton){
+ $PriceNew = $FirstButton->find('strong', 0)->plaintext;
+ }
+
+ // Second Button is used
+ $SecondButton = $html->find('.oopStage-conditionButton-wrapper-text',1);
+ if($SecondButton){
+ $PriceUsed = $SecondButton->find('strong', 0)->plaintext;
+ }
+
+ // Only continue if a price has changed
+ if($PriceNew != $OldPriceNew || $PriceUsed != $OldPriceUsed){
+
+ // Get Product Image
+ $image = $html->find('.datasheet-cover-image',0)->src;
+
+ // Generate Content
+ if($PriceNew > 1){
+ $content = "
Price New:
$PriceNew
";
+ $content .= "Price Newbefore:
$OldPriceNew
";
+ }
+
+ if($this->getInput('MaxPriceNew') != ''){
+ $content .= sprintf("Max Price Used:
%s,00 €
",$this->getInput('MaxPriceNew'));
+ }
+
+ if($PriceUsed > 1){
+ $content .= "Price Used:
$PriceUsed
";
+ $content .= "Price Used before:
$OldPriceUsed
";
+ }
+
+ if($this->getInput('MaxPriceUsed') != ''){
+ $content .= sprintf("Max Price Used:
%s,00 €
",$this->getInput('MaxPriceUsed'));
+ }
+
+ $content .= "";
+
+
+ $now = date('d.m.j H:m');
+
+ $Pricealarm = 'Pricealarm %s: %s %s %s';
+
+ // Currently under Max new price
+ if($this->getInput('MaxPriceNew') != '') {
+ if($PriceNew < $this->getInput('MaxPriceNew')){
+ $title = sprintf($Pricealarm, 'Used', $PriceNew, $Productname, $now);
+ $item = [
+ 'title' => $title,
+ 'uri' => $link,
+ 'content' => $content,
+ 'uid' => md5($title)
+ ];
+ $this->items[] = $item;
+ }
+ }
+
+ // Currently under Max used price
+ if($this->getInput('MaxPriceUsed') != '') {
+ if($PriceUsed < $this->getInput('MaxPriceUsed')){
+ $title = sprintf($Pricealarm, 'Used',$PriceUsed, $Productname, $now);
+ $item = [
+ 'title' => $title,
+ 'uri' => $link,
+ 'content' => $content,
+ 'uid' => md5($title)
+ ];
+ $this->items[] = $item;
+ }
+ }
+
+ // General Priceupdate
+ if($this->getInput('MaxPriceUsed') == '' && $this->getInput('MaxPriceNew') == '') {
+ // check if a relevant pricechange happened
+ if(( !$this->getInput('ExcludeNew') && $PriceNew != $OldPriceNew )||
+ (!$this->getInput('ExcludeUsed') && $PriceUsed != $OldPriceUsed )){
+ $title .= 'Priceupdate! ';
+
+ if(!$this->getInput('ExcludeNew')){
+ if($PriceNew<$OldPriceNew){
+ $title .= 'NEW:⬇ '; // Arrow Down Emoji
+ }
+ if($PriceNew>$OldPriceNew){
+ $title .= 'NEW:⬆ '; // Arrow Up Emoji
+ }
+ }
+
+
+ if(!$this->getInput('ExcludeUsed')){
+ if($PriceUsed<$OldPriceUsed){
+ $title .= 'USED:⬇ '; // Arrow Down Emoji
+ }
+ if($PriceUsed>$OldPriceUsed){
+ $title .= 'USED:⬆ '; // Arrow Up Emoji
+ }
+ }
+ $title .= $Productname;
+ $title .= ' ';
+ $title .= $now;
+
+ $item = [
+ 'title' => $title,
+ 'uri' => $link,
+ 'content' => $content,
+ 'uid' => md5($title)
+ ];
+ $this->items[] = $item;
+ }
+ }
+ }
+
+ // Save current price
+ $this->saveCacheValue($KeyNEW, $PriceNew);
+ $this->saveCacheValue($KeyUSED, $PriceUsed);
+ }
+}
From 53f10ceb398a393d665885c63ee0c94a43c246a1 Mon Sep 17 00:00:00 2001
From: SebLaus <97241865+SebLaus@users.noreply.github.com>
Date: Wed, 1 Nov 2023 20:00:05 +0100
Subject: [PATCH 2/3] Changed Exec and syntax
---
bridges/IdealoBridge.php | 76 ++++++++++++++++++++--------------------
1 file changed, 38 insertions(+), 38 deletions(-)
mode change 100755 => 100644 bridges/IdealoBridge.php
diff --git a/bridges/IdealoBridge.php b/bridges/IdealoBridge.php
old mode 100755
new mode 100644
index bbf478c7d9c..85c7fb1a110
--- a/bridges/IdealoBridge.php
+++ b/bridges/IdealoBridge.php
@@ -46,7 +46,7 @@ public function collectData()
$html = getSimpleHTMLDOM($link);
// Get Productname
- $titleobj = $html->find('.oopStage-title',0);
+ $titleobj = $html->find('.oopStage-title', 0);
$Productname = $titleobj->find('span', 0)->plaintext;
// Create product specific Cache Keys with the link
@@ -55,46 +55,46 @@ public function collectData()
$KeyUSED = $link;
$KeyUSED .= 'USED';
-
+
// Load previous Price
$OldPriceNew = $this->loadCacheValue($KeyNEW);
$OldPriceUsed = $this->loadCacheValue($KeyUSED);
// First button is new. Found at oopStage-conditionButton-wrapper-text class (.)
- $FirstButton = $html->find('.oopStage-conditionButton-wrapper-text',0);
- if($FirstButton){
+ $FirstButton = $html->find('.oopStage-conditionButton-wrapper-text', 0);
+ if ($FirstButton) {
$PriceNew = $FirstButton->find('strong', 0)->plaintext;
}
// Second Button is used
- $SecondButton = $html->find('.oopStage-conditionButton-wrapper-text',1);
- if($SecondButton){
+ $SecondButton = $html->find('.oopStage-conditionButton-wrapper-text', 1);
+ if ($SecondButton) {
$PriceUsed = $SecondButton->find('strong', 0)->plaintext;
}
// Only continue if a price has changed
- if($PriceNew != $OldPriceNew || $PriceUsed != $OldPriceUsed){
-
+ if ($PriceNew != $OldPriceNew || $PriceUsed != $OldPriceUsed) {
+
// Get Product Image
$image = $html->find('.datasheet-cover-image',0)->src;
// Generate Content
- if($PriceNew > 1){
- $content = "Price New:
$PriceNew
";
- $content .= "Price Newbefore:
$OldPriceNew
";
+ if ($PriceNew > 1) {
+ $content = "Price New:
$PriceNew
";
+ $content .= "Price Newbefore:
$OldPriceNew
";
}
- if($this->getInput('MaxPriceNew') != ''){
- $content .= sprintf("Max Price Used:
%s,00 €
",$this->getInput('MaxPriceNew'));
+ if ($this->getInput('MaxPriceNew') != '') {
+ $content .= sprintf('Max Price Used:
%s,00 €
', $this->getInput('MaxPriceNew'));
}
- if($PriceUsed > 1){
- $content .= "Price Used:
$PriceUsed
";
- $content .= "Price Used before:
$OldPriceUsed
";
+ if ($PriceUsed > 1) {
+ $content .= "Price Used:
$PriceUsed
";
+ $content .= "Price Used before:
$OldPriceUsed
";
}
- if($this->getInput('MaxPriceUsed') != ''){
- $content .= sprintf("Max Price Used:
%s,00 €
",$this->getInput('MaxPriceUsed'));
+ if ($this->getInput('MaxPriceUsed') != '') {
+ $content .= sprintf('Max Price Used:
%s,00 €
', $this->getInput('MaxPriceUsed'));
}
$content .= "";
@@ -105,9 +105,9 @@ public function collectData()
$Pricealarm = 'Pricealarm %s: %s %s %s';
// Currently under Max new price
- if($this->getInput('MaxPriceNew') != '') {
- if($PriceNew < $this->getInput('MaxPriceNew')){
- $title = sprintf($Pricealarm, 'Used', $PriceNew, $Productname, $now);
+ if ($this->getInput('MaxPriceNew') != '') {
+ if ($PriceNew < $this->getInput('MaxPriceNew')) {
+ $title = sprintf($Pricealarm, 'Used', $PriceNew, $Productname, $now);
$item = [
'title' => $title,
'uri' => $link,
@@ -119,55 +119,55 @@ public function collectData()
}
// Currently under Max used price
- if($this->getInput('MaxPriceUsed') != '') {
- if($PriceUsed < $this->getInput('MaxPriceUsed')){
- $title = sprintf($Pricealarm, 'Used',$PriceUsed, $Productname, $now);
+ if ($this->getInput('MaxPriceUsed') != '') {
+ if ($PriceUsed < $this->getInput('MaxPriceUsed')) {
+ $title = sprintf($Pricealarm, 'Used', $PriceUsed, $Productname, $now);
$item = [
'title' => $title,
'uri' => $link,
'content' => $content,
'uid' => md5($title)
];
- $this->items[] = $item;
+ $this->items[] = $item;
}
}
// General Priceupdate
- if($this->getInput('MaxPriceUsed') == '' && $this->getInput('MaxPriceNew') == '') {
+ if ($this->getInput('MaxPriceUsed') == '' && $this->getInput('MaxPriceNew') == '') {
// check if a relevant pricechange happened
- if(( !$this->getInput('ExcludeNew') && $PriceNew != $OldPriceNew )||
- (!$this->getInput('ExcludeUsed') && $PriceUsed != $OldPriceUsed )){
+ if ((!$this->getInput('ExcludeNew') && $PriceNew != $OldPriceNew ) ||
+ (!$this->getInput('ExcludeUsed') && $PriceUsed != $OldPriceUsed )) {
$title .= 'Priceupdate! ';
- if(!$this->getInput('ExcludeNew')){
- if($PriceNew<$OldPriceNew){
+ if (!$this->getInput('ExcludeNew')) {
+ if ($PriceNew < $OldPriceNew) {
$title .= 'NEW:⬇ '; // Arrow Down Emoji
}
- if($PriceNew>$OldPriceNew){
+ if ($PriceNew > $OldPriceNew) {
$title .= 'NEW:⬆ '; // Arrow Up Emoji
}
}
-
-
- if(!$this->getInput('ExcludeUsed')){
- if($PriceUsed<$OldPriceUsed){
+
+
+ if (!$this->getInput('ExcludeUsed')) {
+ if ($PriceUsed < $OldPriceUsed) {
$title .= 'USED:⬇ '; // Arrow Down Emoji
}
- if($PriceUsed>$OldPriceUsed){
+ if ($PriceUsed > $OldPriceUsed) {
$title .= 'USED:⬆ '; // Arrow Up Emoji
}
}
$title .= $Productname;
$title .= ' ';
$title .= $now;
-
+
$item = [
'title' => $title,
'uri' => $link,
'content' => $content,
'uid' => md5($title)
];
- $this->items[] = $item;
+ $this->items[] = $item;
}
}
}
From caafc0e340eb611596335c43207c0781e56f32f9 Mon Sep 17 00:00:00 2001
From: SebLaus <97241865+SebLaus@users.noreply.github.com>
Date: Wed, 1 Nov 2023 20:16:20 +0100
Subject: [PATCH 3/3] last fixes for remaining warning
---
bridges/IdealoBridge.php | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bridges/IdealoBridge.php b/bridges/IdealoBridge.php
index 85c7fb1a110..89c5f87df90 100644
--- a/bridges/IdealoBridge.php
+++ b/bridges/IdealoBridge.php
@@ -74,9 +74,8 @@ public function collectData()
// Only continue if a price has changed
if ($PriceNew != $OldPriceNew || $PriceUsed != $OldPriceUsed) {
-
// Get Product Image
- $image = $html->find('.datasheet-cover-image',0)->src;
+ $image = $html->find('.datasheet-cover-image', 0)->src;
// Generate Content
if ($PriceNew > 1) {
@@ -135,8 +134,10 @@ public function collectData()
// General Priceupdate
if ($this->getInput('MaxPriceUsed') == '' && $this->getInput('MaxPriceNew') == '') {
// check if a relevant pricechange happened
- if ((!$this->getInput('ExcludeNew') && $PriceNew != $OldPriceNew ) ||
- (!$this->getInput('ExcludeUsed') && $PriceUsed != $OldPriceUsed )) {
+ if (
+ (!$this->getInput('ExcludeNew') && $PriceNew != $OldPriceNew ) ||
+ (!$this->getInput('ExcludeUsed') && $PriceUsed != $OldPriceUsed )
+ ) {
$title .= 'Priceupdate! ';
if (!$this->getInput('ExcludeNew')) {