diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 6e05aa9..c072478 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -70,14 +70,14 @@ class Kernel extends ConsoleKernel $schedule->command('scrape:hama')->everyFiveMinutes() ->pingOnSuccess(env('APP_URL') . "/api/ping/hama"); - $schedule->command('scrape:raajjemv')->everyFiveMinutes() - ->pingOnSuccess(env('APP_URL') . "/api/ping/raajjemv"); + // $schedule->command('scrape:raajjemv')->everyFiveMinutes() + // ->pingOnSuccess(env('APP_URL') . "/api/ping/raajjemv"); - $schedule->command('scrape:funadhoo-times')->everyFiveMinutes() - ->pingOnSuccess(env('APP_URL') . "/api/ping/funadhoo-times"); + // $schedule->command('scrape:funadhoo-times')->everyFiveMinutes() + // ->pingOnSuccess(env('APP_URL') . "/api/ping/funadhoo-times"); - $schedule->command('scrape:zaviyani')->everyFiveMinutes() - ->pingOnSuccess(env('APP_URL') . "/api/ping/zaviyani"); + // $schedule->command('scrape:zaviyani')->everyFiveMinutes() + // ->pingOnSuccess(env('APP_URL') . "/api/ping/zaviyani"); $schedule->command('scrape:jazeera')->everyFiveMinutes() ->pingOnSuccess(env('APP_URL') . "/api/ping/jazeera"); diff --git a/app/Http/Controllers/API/SourcesAPIController.php b/app/Http/Controllers/API/SourcesAPIController.php index 7625cd7..0de7d13 100644 --- a/app/Http/Controllers/API/SourcesAPIController.php +++ b/app/Http/Controllers/API/SourcesAPIController.php @@ -19,7 +19,15 @@ class SourcesAPIController extends Controller public function index() { return Cache::remember('sources.index', 300, function () { - return SourceResource::collection(Source::all()); + return SourceResource::collection(Source::whereNotIn('slug',[ + 'mihaaru', + 'hama', + 'zaviyani', + 'funadhoo-times', + 'psm', + 'raajjemv', + 'voice' + ])->get()); }); } diff --git a/app/Services/Feeds/RaajjeMvFeed.php b/app/Services/Feeds/RaajjeMvFeed.php index 5eb0cd7..fdff5e0 100644 --- a/app/Services/Feeds/RaajjeMvFeed.php +++ b/app/Services/Feeds/RaajjeMvFeed.php @@ -1,5 +1,4 @@ client = new Client(); } + /** - * Get all the latest news + * Get all the latest news from the 'އެންމެ ފަސް' section * * @return array */ public function get(): array { - $crawler = $this->client->request('GET', "https://raajje.mv/"); $feeds = []; - $articles = $crawler->filter('div[v-if*="homepage.emme_fas"] article-grid')->first()->attr(':collection'); + // Find the 'އެންމެ ފަސް' section + $articlesContainer = $crawler->filter('.waheed')->each(function ($node) { + // Ensure we are in the right section + if (strpos($node->text(), 'އެންމެ ފަސް') !== false) { + return $node->filter('a')->each(function ($articleNode) { + $link = $articleNode->attr('href'); + $title = trim($articleNode->filter('div.leading-relaxed')->text()); + $date = trim($articleNode->filter('div.mt-3.text-sm')->text()); - $raw_response = json_decode(html_entity_decode($articles), true); - foreach($raw_response as $response) - { - $feeds[] = [ - "title" => $response["heading"], - "link" => "https://raajje.mv/".$response["id"], - "date" => $response["approved_date"] - ]; - } + return [ + "title" => $title, + "link" => "https://raajje.mv" . $link, + "date" => $date + ]; + }); + } + }); - return $feeds; + // Remove null values and flatten the array + $articlesContainer = array_filter($articlesContainer); + + return !empty($articlesContainer) ? array_merge(...$articlesContainer) : []; } }