From 6f2498760168d954ae6c9b02b412c788b6190c32 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Thu, 27 Jun 2019 20:28:23 +0200 Subject: [PATCH] [InstructablesBridge] Fix listCategories() to work with new layout --- bridges/InstructablesBridge.php | 34 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/bridges/InstructablesBridge.php b/bridges/InstructablesBridge.php index 2bec4f68..5530b99c 100644 --- a/bridges/InstructablesBridge.php +++ b/bridges/InstructablesBridge.php @@ -320,24 +320,32 @@ class InstructablesBridge extends BridgeAbstract { * parameters list) */ private function listCategories(){ - // Use arbitrary category to receive full list - $html = getSimpleHTMLDOM(self::URI . '/technology/'); - foreach($html->find('.channel a') as $channel) { - $name = html_entity_decode(trim($channel->innertext)); + // Use home page to acquire main categories + $html = getSimpleHTMLDOM(self::URI); + $html = defaultLinkTo($html, self::URI); - // Remove unwanted entities - $name = str_replace("'", '', $name); - $name = str_replace(''', '', $name); + foreach($html->find('.home-content-explore-link') as $category) { - $uri = $channel->href; + // Use arbitrary category to receive full list + $html = getSimpleHTMLDOM($category->href); - $category = explode('/', $uri)[1]; + foreach($html->find('.channel-thumbnail a') as $channel) { + $name = html_entity_decode(trim($channel->title)); - if(!isset($categories) - || !array_key_exists($category, $categories) - || !in_array($uri, $categories[$category])) - $categories[$category][$name] = $uri; + // Remove unwanted entities + $name = str_replace("'", '', $name); + $name = str_replace(''', '', $name); + + $uri = $channel->href; + + $category_name = explode('/', $uri)[1]; + + if(!isset($categories) + || !array_key_exists($category_name, $categories) + || !in_array($uri, $categories[$category_name])) + $categories[$category_name][$name] = $uri; + } } // Build PHP array manually