pub / kontra

Der linke Newsaggregator.
git clone src.jayvii.de/pub/kontra.git
Home | Log | Files | Exports | Refs | README | RSS

commit 592618fea83c572026b42a7edd3f6baaeb6e94e4
parent 51ed65606199dd2479291837f6e18ac59f988393
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Fri,  6 Jun 2025 12:38:28 +0200

feat: tool that counts category occurences

Diffstat:
Atools/gen_categories.php | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/tools/gen_categories.php b/tools/gen_categories.php @@ -0,0 +1,27 @@ +<!-- +SPDX-License-Identifier: AGPL-3.0-or-later +SPDX-FileCopyrightText: 2025 JayVii <jayvii+kontra[AT]posteo[DOT]de> +--> +<?php + +// Load news sources file +$sources = json_decode( + file_get_contents("./news-sources.json"), + true +); + +// extract categories from each news source and add it to a new array +$categories = array(); +foreach ($sources["sources"] as $source) { + foreach($source["categories"] as $category) { + array_push($categories, $category); + } +} + +// sort new array by ID +sort($categories); + +// Print unique values and their counts +print_r(array_count_values($categories)); + +?>