flatgreen / rfrance
Scrape R A D I O F R A N C E
v2.4.5
2025-03-24 22:39 UTC
Requires
- php: >=8.1
- colinodell/json5: ^3.0
- symfony/cache: ^6.4|^7.0
- symfony/css-selector: ^6.4|^7.0
- symfony/dom-crawler: ^6.4|^7.0
Requires (Dev)
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^10.5
- symfony/var-dumper: ^6.4
README
PHP library for french radio. RFrance a class to scrape and parse r a d i o f r a n c e
Prerequisites
- php >= 8.1
Installation
- Use the package manager composer to install RFrance.
composer require flatgreen/rfrance
- Optional: Create a 'cache' directory (with read|write permissions), by default the cache directory is inside the system temporary directory.
Usage
require_once 'vendor/autoload.php'; use Flatgreen\RFrance\RFrance;
Instantiate the class, with an URL page
$rf = new RFrance(); // optional in constructor, add cache directory and cache duration for page, 1 day by default. try { $rf->extract(URL); // optional: set a (approx.) limit $max_items (default: -1, all items) } catch (\Throwable $th) { //throw $th; }
Read the informations
if (empty($rf->error)){ $title = $rf->page->title; $all_items = $rf->all_items; // array of Item ... }
An Item always return an (audio media) url. This is the best
the class can find (see Item.php for information).
Three output helpers :
// to array echo $FC->toArray(); // RSS 2.0, always return informations (even with no item) header("Content-Type: text/xml; charset=UTF-8"); echo $FC->toRss(); // or // youtube-dl|yt-dlp info.json like, maybe empty if no item header('Content-Type: application/json; charset=utf-8'); echo $FC->toInfoJson();
Remarks
Does not take into account some pages that are not broadcasts.
Changelog
License
RFrance is licensed under the MIT License (MIT). Please see the license file for more information.