diff --git a/CREATE_BRIDGE.md b/CREATE_BRIDGE.md
new file mode 100644
index 00000000..215ae282
--- /dev/null
+++ b/CREATE_BRIDGE.md
@@ -0,0 +1,23 @@
+# Howto create a bridge
+
+A bridge is an interface that allows rss-bridge to create a RSS feed from a website.
+The bridge is a PHP file, located in the `bridges/` folder.
+
+##Specifications
+
+A rss bridge must extend the `BridgeAbstract` class, and implement the following functions :
+
+* The `loadMetadatas` function, described below,
+* The `getCacheDuration` function, describing the time during which rss-bridge will output cached values instead of re-generating a RSS feed.
+* The `collectData` function, also described below.
+
+##The `collectData` function
+
+This function takes as a parameter an array called `$param`, that is automatically filled with values from the user, according to the values setted in `loadMetadatas`.
+This function is the place where all the website scrapping and the RSS feed generation process will go.
+
+The RSS elements are stored in the class variable `items[]`.
+
+Every RSS element is an instance of the `Item` class.
+
+
diff --git a/bridges/AcrimedBridge.php b/bridges/AcrimedBridge.php
index 97a2e4a7..d50a0d66 100644
--- a/bridges/AcrimedBridge.php
+++ b/bridges/AcrimedBridge.php
@@ -1,6 +1,6 @@
maintainer = "qwertygc";
+ $this->name = "Acrimed Bridge";
+ $this->uri = "http://www.acrimed.org/";
+ $this->description = "Returns the newest articles.";
+ $this->update = "2014-05-25";
+
+ }
+ public function collectData(array $param){
function StripCDATA($string) {
$string = str_replace(' Type = A (Anime), D (Drama), T (Tokusatsu), or leave empty for everything
+ * @description Returns the 10 newest releases posted on Anime-Ultime
* @maintainer ORelio
- * @update 2015-09-07
- * @use1(type="A/D/T/Empty")
+ * @update 2015-10-30
+ * @use1(list|type="everything=>;Anime=>A;Drama=>D;Tokusatsu=>T")
*/
class AnimeUltimeBridge extends BridgeAbstract {
diff --git a/bridges/Arte7Bridge.php b/bridges/Arte7Bridge.php
new file mode 100644
index 00000000..fa4dbda8
--- /dev/null
+++ b/bridges/Arte7Bridge.php
@@ -0,0 +1,113 @@
+toutes-les-videos;Actu & société=>actu-société;Séries & fiction=>séries-fiction;Cinéma=>cinéma;Arts & spectacles classiques=>arts-spectacles-classiques;Culture pop=>culture-pop;Découverte=>découverte;Histoire=>histoire;Junior=>junior")
+* @use2(list|catde="Alle Videos (deutsch)=>alle-videos;Aktuelles & Gesellschaft=>aktuelles-gesellschaft;Fernsehfilme & Serien=>fernsehfilme-serien;Kino=>kino;Kunst & Kultur=>kunst-kultur;Popkultur & Alternativ=>popkultur-alternativ;Entdeckung=>entdeckung;Geschichte=>geschichte;Junior=>junior")
+*/
+class Arte7Bridge extends BridgeAbstract{
+
+ public function loadMetadatas() {
+
+ $this->maintainer = "mitsukarenai";
+ $this->name = "Arte +7";
+ $this->uri = "http://www.arte.tv/";
+ $this->description = "Returns newest videos from ARTE +7";
+ $this->update = "2015-10-31";
+ $this->parameters["Catégorie (Français)"] =
+ '[
+ {
+ "type" : "list",
+ "identifier" : "catfr",
+ "name" : "Catégorie",
+ "values" : [
+ {
+ "name" : "Toutes les vidéos (français)",
+ "value" : "toutes-les-videos"
+ },
+ {
+ "name" : "Actu & société",
+ "value" : "actu-société"
+ },
+ {
+ "name" : "Séries & fiction",
+ "value" : "séries-fiction"
+ },
+ {
+ "name" : "Cinéma",
+ "value" : "cinéma"
+ }
+
+ ]
+
+
+ }
+
+ ]';
+ }
+
+
+ public function collectData(array $param){
+
+ function extractVideoset($category='toutes-les-videos', $lang='fr')
+ {
+ $url = 'http://www.arte.tv/guide/'.$lang.'/plus7/'.$category;
+ $input = file_get_contents($url) or die('Could not request ARTE.');
+ if(strpos($input, 'categoryVideoSet') !== FALSE)
+ {
+ $input = explode('categoryVideoSet: ', $input);
+ $input = explode('}},', $input[1]);
+ $input = $input[0].'}}';
+ }
+ else
+ {
+ $input = explode('videoSet: ', $input);
+ $input = explode('}]},', $input[1]);
+ $input = $input[0].'}]}';
+ }
+ $input = json_decode($input, TRUE);
+ return $input;
+ }
+
+ $category='toutes-les-videos'; $lang='fr';
+ if (!empty($param['catfr']))
+ $category=$param['catfr'];
+ if (!empty($param['catde']))
+ { $category=$param['catde']; $lang='de'; }
+ $input_json = extractVideoset($category, $lang);
+
+ foreach($input_json['videos'] as $element) {
+ $item = new \Item();
+ $item->uri = $element['url'];
+ $item->id = $element['id'];
+ $hack_broadcast_time = $element['rights_end'];
+ $hack_broadcast_time = strtok($hack_broadcast_time, 'T');
+ $hack_broadcast_time = strtok('T');
+ $item->timestamp = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time);
+ $item->thumbnailUri = $element['thumbnail_url'];
+ $item->title = $element['title'];
+ if (!empty($element['subtitle']))
+ $item->title = $element['title'].' | '.$element['subtitle'];
+ $item->duration = round((int)$element['duration']/60);
+ $item->content = $element['teaser'].'
'.$item->duration.'min
';
+ $this->items[] = $item;
+ }
+ }
+
+ public function getName(){
+ return 'Arte7';
+ }
+
+ public function getURI(){
+ return 'http://www.arte.tv/';
+ }
+
+ public function getCacheDuration(){
+ return 1800; // 30 minutes
+ }
+}
diff --git a/bridges/Arte7deBridge.php b/bridges/Arte7deBridge.php
deleted file mode 100644
index 55d6dcfe..00000000
--- a/bridges/Arte7deBridge.php
+++ /dev/null
@@ -1,71 +0,0 @@
-alle-videos;Aktuelles & Gesellschaft=>aktuelles-gesellschaft;Fernsehfilme & Serien=>fernsehfilme-serien;Kino=>kino;Kunst & Kultur=>kunst-kultur;Popkultur & Alternativ=>popkultur-alternativ;Entdeckung=>entdeckung;Geschichte=>geschichte;Junior=>junior")
-*/
-class Arte7deBridge extends BridgeAbstract{
-
- public function collectData(array $param){
-
- function extractVideoset($category='alle-videos')
- {
- $url = 'http://www.arte.tv/guide/de/plus7/'.$category;
- $input = file_get_contents($url) or die('Could not request ARTE.');
- if(strpos($input, 'categoryVideoSet') !== FALSE)
- {
- $input = explode('categoryVideoSet: ', $input);
- $input = explode('}},', $input[1]);
- $input = $input[0].'}}';
- }
- else
- {
- $input = explode('videoSet: ', $input);
- $input = explode('}]},', $input[1]);
- $input = $input[0].'}]}';
- }
- $input = json_decode($input, TRUE);
- return $input;
- }
-
- $category='alle-videos';
- if (!empty($param['cat']))
- $category=$param['cat'];
- $input_json = extractVideoset($category);
-
- foreach($input_json['videos'] as $element) {
- $item = new \Item();
- $item->uri = $element['url'];
- $item->id = $element['id'];
- $hack_broadcast_time = $element['rights_end'];
- $hack_broadcast_time = strtok($hack_broadcast_time, 'T');
- $hack_broadcast_time = strtok('T');
- $item->timestamp = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time);
- $item->thumbnailUri = $element['thumbnail_url'];
- $item->title = $element['title'];
- if (!empty($element['subtitle']))
- $item->title = $element['title'].' | '.$element['subtitle'];
- $item->duration = round((int)$element['duration']/60);
- $item->content = $element['teaser'].'
'.$item->duration.'min
';
- $this->items[] = $item;
- }
- }
-
- public function getName(){
- return 'Arte7de';
- }
-
- public function getURI(){
- return 'http://www.arte.tv/';
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
-}
diff --git a/bridges/Arte7frBridge.php b/bridges/Arte7frBridge.php
deleted file mode 100644
index f521e858..00000000
--- a/bridges/Arte7frBridge.php
+++ /dev/null
@@ -1,71 +0,0 @@
-toutes-les-videos;Actu & société=>actu-société;Séries & fiction=>séries-fiction;Cinéma=>cinéma;Arts & spectacles classiques=>arts-spectacles-classiques;Culture pop=>culture-pop;Découverte=>découverte;Histoire=>histoire;Junior=>junior")
-*/
-class Arte7frBridge extends BridgeAbstract{
-
- public function collectData(array $param){
-
- function extractVideoset($category='toutes-les-videos')
- {
- $url = 'http://www.arte.tv/guide/fr/plus7/'.$category;
- $input = file_get_contents($url) or die('Could not request ARTE.');
- if(strpos($input, 'categoryVideoSet') !== FALSE)
- {
- $input = explode('categoryVideoSet: ', $input);
- $input = explode('}},', $input[1]);
- $input = $input[0].'}}';
- }
- else
- {
- $input = explode('videoSet: ', $input);
- $input = explode('}]},', $input[1]);
- $input = $input[0].'}]}';
- }
- $input = json_decode($input, TRUE);
- return $input;
- }
-
- $category='toutes-les-videos';
- if (!empty($param['cat']))
- $category=$param['cat'];
- $input_json = extractVideoset($category);
-
- foreach($input_json['videos'] as $element) {
- $item = new \Item();
- $item->uri = $element['url'];
- $item->id = $element['id'];
- $hack_broadcast_time = $element['rights_end'];
- $hack_broadcast_time = strtok($hack_broadcast_time, 'T');
- $hack_broadcast_time = strtok('T');
- $item->timestamp = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time);
- $item->thumbnailUri = $element['thumbnail_url'];
- $item->title = $element['title'];
- if (!empty($element['subtitle']))
- $item->title = $element['title'].' | '.$element['subtitle'];
- $item->duration = round((int)$element['duration']/60);
- $item->content = $element['teaser'].'
'.$item->duration.'min
';
- $this->items[] = $item;
- }
- }
-
- public function getName(){
- return 'Arte7fr';
- }
-
- public function getURI(){
- return 'http://www.arte.tv/';
- }
-
- public function getCacheDuration(){
- return 1800; // 30 minutes
- }
-}
diff --git a/bridges/DemoBridge.php b/bridges/DemoBridge.php
new file mode 100644
index 00000000..df38be6b
--- /dev/null
+++ b/bridges/DemoBridge.php
@@ -0,0 +1,72 @@
+maintainer = "teromene";
+ $this->name = "DemoBridge";
+ $this->uri = "http://github.com/sebsauvage/rss-bridge";
+ $this->description = "Bridge used for demos";
+ $this->update = "2015-11-03";
+
+ $this->parameters['testCheckbox'] =
+ '[
+ {
+ "type" : "checkbox",
+ "identifier" : "testCheckbox",
+ "name" : "test des checkbox"
+ }
+
+ ]';
+
+ $this->parameters['testList'] =
+ '[
+ {
+ "type" : "list",
+ "identifier" : "testList",
+ "name" : "test des listes",
+ "values" : [
+ {
+ "name" : "Test",
+ "value" : "test"
+ },
+ {
+ "name" : "Test 2",
+ "value" : "test2"
+ }
+ ]
+ }
+ ]';
+ $this->parameters['testNumber'] =
+ '[
+ {
+ "type" : "number",
+ "identifier" : "testNumber",
+ "name" : "test des numéros",
+ "exampleValue" : "1515632"
+
+ }
+
+ ]';
+
+ }
+
+ public function collectData(array $param){
+
+ }
+
+ public function getCacheDuration(){
+ return 3600; // 1 hour
+ }
+}
diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php
index 15f648ca..dc37d5ec 100644
--- a/bridges/FacebookBridge.php
+++ b/bridges/FacebookBridge.php
@@ -9,7 +9,7 @@
*/
class FacebookBridge extends BridgeAbstract{
- private $name;
+
public function collectData(array $param){
diff --git a/bridges/LeBonCoinBridge.php b/bridges/LeBonCoinBridge.php
index e3cc2562..3a1df702 100755
--- a/bridges/LeBonCoinBridge.php
+++ b/bridges/LeBonCoinBridge.php
@@ -3,17 +3,13 @@
* RssBridgeLeBonCoin
* Search LeBonCoin for most recent ads in a specific region and topic.
* Returns the most recent classified ads in results, sorting by date (most recent first).
-* Region identifiers : alsace, aquitaine, auvergne, basse_normandie, bourgogne, bretagne, centre,
-* champagne_ardenne, corse, franche_comte, haute_normandie, ile_de_france, languedoc_roussillon,
-* limousin, lorraine, midi_pyrenees, nord_pas_de_calais, pays_de_la_loire, picardie,
-* poitou_charentes, provence_alpes_cote_d_azur, rhone_alpes, guadeloupe, martinique, guyane, reunion.
-* 2014-07-22
*
* @name LeBonCoin
* @homepage http://www.leboncoin.fr
* @description Returns most recent results from LeBonCoin for a region and a keyword.
* @maintainer 16mhz
-* @use1(r="Region identifier", k="Keyword")
+* @update 2015-10-30
+* @use1(list|r="Alsace=>alsace;Aquitaine=>aquitaine;Auvergne=>auvergne;Basse Normandie=>basse_normandie;Bourgogne=>bourgogne;Bretagne=>bretagne;Centre=>centre;Champagne Ardenne=>champagne_ardenne;Corse=>corse;Franche Comté=>franche_comte;Haute Normandie=>haute_normandie;Ile de France=>ile_de_france;Languedoc Roussillon=>languedoc_roussillon;Limousin=>limousin;Lorraine=>lorraine;Midi Pyrénées=>midi_pyrenees;Nord Pas De Calais=>nord_pas_de_calais;Pays de la Loire=>pays_de_la_loire;Picardie=>picardie;Poitou Charentes=>poitou_charentes;Provence Alpes Côte d'Azur=>provence_alpes_cote_d_azur;Rhône-Alpes=>rhone_alpes;Guadeloupe=>guadeloupe;Martinique=>martinique;Guyane=>guyane;Réunion=>reunion", text|k="Keyword")
*/
class LeBonCoinBridge extends BridgeAbstract{
diff --git a/bridges/OpenClassroomsBridge.php b/bridges/OpenClassroomsBridge.php
index 29db57ab..0c8eda71 100644
--- a/bridges/OpenClassroomsBridge.php
+++ b/bridges/OpenClassroomsBridge.php
@@ -3,32 +3,32 @@
* RssBridgeOpenClassrooms
* Retrieve lastest tutorials from OpenClassrooms.
* Returns the most recent tutorials, sorting by date (most recent first).
-* 2014-05-25
*
* @name OpenClassrooms Bridge
-* @homepage http://fr.openclassrooms.com/
+* @homepage https://openclassrooms.com/
* @description Returns latest tutorials from OpenClassrooms.
* @maintainer sebsauvage
-* @use1(u="informatique or sciences")
+* @update 2015-10-30
+* @use1(list|u="Arts & Culture=>arts;Code=>code;Design=>design;Entreprise=>business;Numérique=>digital;Sciences=>sciences;Sciences humaines=>humanities;Systèmes d'information=>it;Autres=>others")
*/
class OpenClassroomsBridge extends BridgeAbstract{
public function collectData(array $param){
- if ($param['u']!='informatique' && $param['u']!='sciences')
+ if (empty($param['u']))
{
- $this->returnError('Error: You must chose "informatique" or "science".', 404);
+ $this->returnError('Error: You must chose a category.', 404);
}
$html = '';
- $link = 'http://fr.openclassrooms.com/'.$param['u'].'/cours?title=&sort=updatedAt+desc';
+ $link = 'https://openclassrooms.com/courses?categories='.$param['u'].'&title=&sort=updatedAt+desc';
$html = file_get_html($link) or $this->returnError('Could not request OpenClassrooms.', 404);
- foreach($html->find('li.col6') as $element) {
+ foreach($html->find('.courseListItem') as $element) {
$item = new \Item();
- $item->uri = 'http://fr.openclassrooms.com'.$element->find('a', 0)->href;
- $item->title = $element->find('div.courses-content strong', 0)->innertext;
- $item->content = $element->find('span.course-tags', 0)->innertext;
+ $item->uri = 'https://openclassrooms.com'.$element->find('a', 0)->href;
+ $item->title = $element->find('h3', 0)->plaintext;
+ $item->content = $element->find('slidingItem__descriptionContent', 0)->plaintext;
$this->items[] = $item;
}
}
@@ -38,7 +38,7 @@ class OpenClassroomsBridge extends BridgeAbstract{
}
public function getURI(){
- return 'http://fr.openclassrooms.com';
+ return 'https://openclassrooms.com/';
}
public function getCacheDuration(){
diff --git a/bridges/TwitchApiBridge.php b/bridges/TwitchApiBridge.php
index 7e7f1c49..cedb7496 100644
--- a/bridges/TwitchApiBridge.php
+++ b/bridges/TwitchApiBridge.php
@@ -9,8 +9,8 @@
* @description Returns the newest broadcasts or highlights by channel name using the Twitch API (v3)
* @maintainer logmanoriginal
* @update 2015-07-14
-* @use1(channel="Channel", broadcasts="true|false")
-* @use2(channel="Channel", limit="Limit", broadcasts="true|false")
+* @use1(text|channel="Channel", list|broadcasts="Show broadcasts=>true;Don't show broadcasts=>false")
+* @use2(text|channel="Channel", text|limit="Limit", list|broadcasts="Show broadcasts=>true;Don't show broadcasts=>false")
*
* Description for the API is available on GitHub: https://github.com/justintv/twitch-api
*/
diff --git a/bridges/WorldOfTanks.php b/bridges/WorldOfTanks.php
index 80c9f3a1..ccc80bf5 100644
--- a/bridges/WorldOfTanks.php
+++ b/bridges/WorldOfTanks.php
@@ -2,9 +2,9 @@
/**
*
* @name World of Tanks
-* @description News about the tank slaughter game. Language can be fr, ?
+* @description News about the tank slaughter game.
* @update 2015-09-12
-* @use1(lang="Searched language",category="Category id")
+* @use1(list|lang="Français=>fr;English=>en;Español=>es;Deutsch=>de;Čeština=>cs;Polski=>pl;Türkçe=>tr",text|category="Category id")
*/
define('WORLD_OF_TANKS', 'http://worldoftanks.eu/');
define('NEWS', '/news/');
diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php
index 0aa787b5..bcc6d2f6 100644
--- a/bridges/YoutubeBridge.php
+++ b/bridges/YoutubeBridge.php
@@ -2,25 +2,70 @@
/**
* RssBridgeYoutube
* Returns the newest videos
-*
-* @name Youtube Bridge
-* @homepage https://www.youtube.com/
-* @description Returns the 10 newest videos by username/channel/playlist or search
-* @maintainer mitsukarenai
-* @update 2015-07-08
-* @use1(u="username")
-* @use2(c="channel id")
-* @use3(p="playlist id")
-* @use4(s="search keyword",pa="page")
-*
-* WARNING: to parse big playlists (over ~90 videos), you need to edit simple_html_dom.php:
+* WARNING: to parse big playlists (over ~90 videos), you need to edit simple_html_dom.php:
* change: define('MAX_FILE_SIZE', 600000);
* into: define('MAX_FILE_SIZE', 900000); (or more)
*/
-class YoutubeBridge extends BridgeAbstract{
-
- private $request;
-
+class YoutubeBridge extends BridgeAbstract {
+
+
+ public function loadMetadatas() {
+
+ $this->name = "Youtube Bridge";
+
+ $this->homepage = "https://youtube.com";
+ $this->description = "Returns the 10 newest videos by username/channel/playlist or search";
+ $this->maintainer = "mitsukarenai";
+
+ $this->parameters["By username"] =
+ '[
+ {
+ "type" : "text",
+ "identifier" : "u",
+ "name" : "username",
+ "exampleValue" : "test"
+ }
+ ]';
+
+ $this->parameters['By channel id'] =
+ '[
+ {
+ "type" : "number",
+ "identifier" : "c",
+ "name" : "channel id",
+ "exampleValue" : "15"
+ }
+ ]';
+
+ $this->parameters['By playlist Id'] =
+ '[
+ {
+ "type" : "number",
+ "identifier" : "c",
+ "name" : "playlist id",
+ "exampleValue" : "15"
+ }
+ ]';
+
+ $this->parameters["Search result"] =
+ '[
+ {
+ "type" : "text",
+ "identifier" : "s",
+ "name" : "search keyword",
+ "exampleValue" : "test"
+
+ },
+ {
+ "type" : "number",
+ "identifier" : "pa",
+ "name" : "page",
+ "exampleValue" : "1"
+
+ }
+ ]';
+ }
+
public function collectData(array $param){
function getPublishDate($id) {
diff --git a/index.php b/index.php
index 0ab85e06..5a4dea80 100644
--- a/index.php
+++ b/index.php
@@ -1,4 +1,5 @@
setCache($cache); // just add disable cache to your query to disable caching
}
$bridge->setDatas($_REQUEST);
-
+ $bridge->loadMetadatas();
// Data transformation
$format = Format::create($format);
$format
->setDatas($bridge->getDatas())
->setExtraInfos(array(
- 'name' => $bridge->getName(),
- 'uri' => $bridge->getURI(),
+ 'name' => $bridge->name,
+ 'uri' => $bridge->uri,
))
->display();
die;
@@ -135,86 +137,97 @@ function getHelperButtonsFormat($formats){
return $buttons;
}
-function displayBridgeCard($bridgeReference, $bridgeInformations, $formats, $isActive = true)
+function displayBridgeCard($bridgeName, $formats, $isActive = true)
{
- $name = isset($bridgeInformations['homepage']) ? ''.$bridgeInformations['name'].'' : $bridgeInformations['name'];
- $description = isset($bridgeInformations['description']) ? $bridgeInformations['description'] : 'No description provided';
+
+ $bridgeElement = Bridge::create($bridgeName);
+ $bridgeElement->loadMetadatas();
+
+ $name = ''.$bridgeElement->name.'';
+ $description = $bridgeElement->description;
+
$card = <<
+ ';
return $card;
}
-$bridges = Bridge::searchInformation();
$formats = Format::searchInformation();
+
?>
@@ -239,24 +252,27 @@ $formats = Format::searchInformation();
$activeFoundBridgeCount = 0;
$showInactive = isset($_REQUEST['show_inactive']) && $_REQUEST['show_inactive'] == 1;
$inactiveBridges = '';
- foreach($bridges as $bridgeReference => $bridgeInformations)
+ foreach(Bridge::listBridges() as $bridgeName)
{
- if(BridgeWhitelist($whitelist_selection, $bridgeReference))
+ if(BridgeWhitelist($whitelist_selection, $bridgeName))
{
- echo displayBridgeCard($bridgeReference, $bridgeInformations, $formats);
+ echo displayBridgeCard($bridgeName, $formats);
$activeFoundBridgeCount++;
}
elseif ($showInactive)
{
// inactive bridges
- $inactiveBridges .= displayBridgeCard($bridgeReference, $bridgeInformations, $formats, false) . PHP_EOL;
+ $inactiveBridges .= displayBridgeCard($bridgeName, $formats, false) . PHP_EOL;
}
}
echo '
' . $inactiveBridges;
?>
+