Skip to content

Commit

Permalink
[PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge…
Browse files Browse the repository at this point in the history
…] Fixing bridge and add subcategories (#4436)

- Follow site change to get deal data (fix for #4432)
- Add Categories (sub categories in reality) support
  • Loading branch information
sysadminstory authored Feb 3, 2025
1 parent 9350750 commit 920b21b
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
11 changes: 11 additions & 0 deletions bridges/DealabsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class DealabsBridge extends PepperBridgeAbstract
Il faut alors saisir :
abonnements-internet',
],
'subgroup' => [
'name' => 'Catégorie',
'type' => 'text',
'exampleValue' => '1071',
'title' => 'Numéro du ou des catégories dans l\'URL : Il faut entrer le ou les numéros de catégories qui sont présent après "groups=" et avant tout éventuel "&"
Exemple : Si l\'URL du groupe affichées dans le navigateur est :
https://www.dealabs.com/groupe/telecommunications?groups=1071%2C1070&sortBy=new
Il faut alors saisir :
1071%2C1070',
],
'order' => [
'name' => 'Trier par',
'type' => 'list',
Expand Down Expand Up @@ -88,6 +98,7 @@ class DealabsBridge extends PepperBridgeAbstract
'uri-group' => 'groupe/',
'uri-deal' => 'bons-plans/',
'uri-merchant' => 'search/bons-plans?merchant-id=',
'image-host' => 'https://static-pepper.dealabs.com/',
'request-error' => 'Impossible de joindre Dealabs',
'thread-error' => 'Impossible de déterminer l\'ID de la discussion. Vérifiez l\'URL que vous avez entré',
'currency' => '',
Expand Down
11 changes: 11 additions & 0 deletions bridges/HotUKDealsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class HotUKDealsBridge extends PepperBridgeAbstract
https://www.hotukdeals.com/tag/broadband?sortBy=temp
Then enter :
broadband',
],
'subgrousp' => [
'name' => 'category',
'type' => 'text',
'exampleValue' => '343563',
'title' => 'Category number in the URL : The category number that must be entered is present after "groups=" and before any "&".
Example: If the URL of the group displayed in the browser is :
https://www.hotukdeals.com/tag/broadband?groups=343563&sortBy=new
Then enter :
343563',
],
'order' => [
'name' => 'Order by',
Expand Down Expand Up @@ -86,6 +96,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract
'uri-group' => 'tag/',
'uri-deal' => 'deals/',
'uri-merchant' => 'search/deals?merchant-id=',
'image-host' => 'https://images.hotukdeals.com/',
'request-error' => 'Could not request HotUKDeals',
'thread-error' => 'Unable to determine the thread ID. Check the URL you entered',
'currency' => '£',
Expand Down
11 changes: 11 additions & 0 deletions bridges/MydealsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ class MydealsBridge extends PepperBridgeAbstract
Dann geben Sie ein:
dsl',
],
'subgroups' => [
'name' => 'Kategorie',
'type' => 'text',
'exampleValue' => '293',
'title' => 'Nummer des Kategorie in der URL: Der einzugebende Kategorienummer steht nach "groups=" und vor einem "&".
Beispiel: Wenn die URL der Gruppe, die im Browser angezeigt wird, :
https://www.mydealz.de/gruppe/telefon-internet?groups=153%2C154&sortBy=new&time_frame=0
Dann geben Sie ein:
153%2C154',
],
'order' => [
'name' => 'sortieren nach',
'type' => 'list',
Expand Down Expand Up @@ -84,6 +94,7 @@ class MydealsBridge extends PepperBridgeAbstract
'uri-group' => 'gruppe/',
'uri-deal' => 'deals/',
'uri-merchant' => 'search/gutscheine?merchant-id=',
'image-host' => 'https://static.mydealz.de/',
'request-error' => 'Could not request mydeals',
'thread-error' => 'Die ID der Diskussion kann nicht ermittelt werden. Überprüfen Sie die eingegebene URL',
'currency' => '',
Expand Down
25 changes: 12 additions & 13 deletions bridges/PepperBridgeAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function collectDeals($url)
foreach ($list as $deal) {
// Get the JSON Data stored as vue
$jsonDealData = $this->getDealJsonData($deal);
$dealMeta = Json::decode($deal->find('div[class=threadGrid-headerMeta]', 0)->find('div[class=js-vue2]', 1)->getAttribute('data-vue2'));
$dealMeta = Json::decode($deal->find('div[class=js-vue2]', 1)->getAttribute('data-vue2'));

$item = [];
$item['uri'] = $this->getDealURI($jsonDealData);
Expand All @@ -80,7 +80,7 @@ protected function collectDeals($url)
. $this->getShipsFrom($dealMeta)
. $this->getShippingCost($jsonDealData)
. $this->getSource($jsonDealData)
. $this->getDealLocation($dealMeta)
. $this->getDealLocation($jsonDealData)
. $deal->find('div[class*=' . $selectorDescription . ']', 0)->innertext
. '</td><td>'
. $this->getTemperature($jsonDealData)
Expand Down Expand Up @@ -402,14 +402,9 @@ private function getDiscount($jsonDealData)
* Get the Deal location if it exists
* @return string String of the deal location
*/
private function getDealLocation($dealMeta)
private function getDealLocation($jsonDealData)
{
$ribbons = $dealMeta['props']['metaRibbons'];
$isLocal = false;
foreach ($ribbons as $ribbon) {
$isLocal |= ($ribbon['type'] == 'local');
}
if ($isLocal) {
if ($jsonDealData['props']['thread']['isLocal']) {
$content = '<div>' . $this->i8n('deal-type') . ' : ' . $this->i8n('localdeal') . '</div>';
} else {
$content = '';
Expand All @@ -424,8 +419,11 @@ private function getDealLocation($dealMeta)
private function getImage($deal)
{
// Get thread Image JSON content
$content = Json::decode($deal->find('div[class*=threadGrid-image]', 0)->find('div[class=js-vue2]', 0)->getAttribute('data-vue2'));
return '<img src="' . $content['props']['threadImageUrl'] . '"/>';
$content = Json::decode($deal->find('div[class=js-vue2]', 0)->getAttribute('data-vue2'));
//return '<img src="' . $content['props']['threadImageUrl'] . '"/>';
return '<img src="' . $this->i8n('image-host') . $content['props']['thread']['mainImage']['path'] . '/'
. $content['props']['thread']['mainImage']['name'] . '/re/202x202/qt/70/'
. $content['props']['thread']['mainImage']['uid'] . '"/>';
}

/**
Expand All @@ -434,7 +432,7 @@ private function getImage($deal)
*/
private function getShipsFrom($dealMeta)
{
$metas = $dealMeta['props']['metaRibbons'];
$metas = $dealMeta['props']['metaRibbons'] ?? [];
$shipsFrom = null;
foreach ($metas as $meta) {
if ($meta['type'] == 'dispatched-from') {
Expand Down Expand Up @@ -524,6 +522,7 @@ private function getGroupURI()
{
$group = $this->getInput('group');
$order = $this->getInput('order');
$subgroups = $this->getInput('subgroups');

// This permit to keep the existing Feed to work
if ($order == $this->i8n('context-hot')) {
Expand All @@ -533,7 +532,7 @@ private function getGroupURI()
}

$url = $this->i8n('bridge-uri')
. $this->i8n('uri-group') . $group . '?sortBy=' . $sortBy;
. $this->i8n('uri-group') . $group . '?sortBy=' . $sortBy . '&groups=' . $subgroups;
return $url;
}

Expand Down

0 comments on commit 920b21b

Please sign in to comment.