Merge branch 'master' into MangareaderBridge

This commit is contained in:
logmanoriginal 2016-01-21 21:20:17 +01:00
commit b5c7566b7a
12 changed files with 112 additions and 16 deletions

1
.gitignore vendored
View file

@ -170,6 +170,7 @@ App_Data/*.ldf
## Other ide stuff
#################
.idea/*
[#]*[#]
#############
## Windows detritus

View file

@ -90,6 +90,7 @@ Parameter Name | Parameter values | Description
type|text, number, list, checkbox| Type of the input, default is text
required| true | Set this if you want your attribute to be required
values| [ {"name" : option1Name, "value" : "option1Value"}, ...] | Values list, required with the 'list' type
title| text | Will be shown as tooltip when mouse-hovering over the input
#### Guidelines

View file

@ -53,6 +53,16 @@ class DemoBridge extends BridgeAbstract{
public function collectData(array $param){
$item = new \Item();
$item->name = "TestElement";
$item->title = "Test";
$item->content = "Awesome content !";
$item->id = "Lalala";
$item->uri = "http://test.test/test";
$item->enclosures[] = "http://www.ardmediathek.de/ard/servlet/image/00/32/68/18/38/1135274624/16x9/960";
$this->items[] = $item;
}
public function getName() {
@ -68,6 +78,6 @@ class DemoBridge extends BridgeAbstract{
}
public function getCacheDuration(){
return 3600; // 1 hour
return 00; // 1 hour
}
}

View file

@ -0,0 +1,42 @@
<?php
class JapanExpoBridge extends BridgeAbstract{
public function loadMetadatas() {
$this->maintainer = "Ginko";
$this->name = "JapanExpo";
$this->uri = "http://www.japan-expo-paris.com/fr/actualites";
$this->description = "Returns most recent results from Japan Expo actualités.";
$this->update = "2016-01-19";
}
public function collectData(array $param){
$link = 'http://www.japan-expo-paris.com/fr/actualites';
$html = file_get_html($link) or $this->returnError('Could not request JapanExpo. for : ' . $link , 404);
foreach($html->find('a._tile2') as $element) {
$item = new Item();
$item->uri = $element->href;
$item->title = $element->find('span._title', 0)->plaintext;
$style = $element->find('img.rspvimgset', 0)->style;
preg_match('/url\(([^)]+)\)/', $style, $match);
$item->content = "<img src=".$match[1]."></img><br>".$element->find('span.date', 0)->plaintext;
$this->items[] = $item;
}
}
public function getName(){
return 'Japan Expo Actualités';
}
public function getURI(){
return 'http://www.japan-expo-paris.com/fr/actualites';
}
public function getCacheDuration(){
return 86400; // 1 day
}
}

View file

@ -134,7 +134,7 @@ class LeBonCoinBridge extends BridgeAbstract{
public function collectData(array $param){
$html = '';
$link = 'http://www.leboncoin.fr/annonces/offres/' . $param[r] . '/?f=a&th=1&q=' . $param[k];
$link = 'http://www.leboncoin.fr/annonces/offres/' . $param['r'] . '/?f=a&th=1&q=' . $param['k'];
$html = file_get_html($link) or $this->returnError('Could not request LeBonCoin.', 404);
$list = $html->find('.list-lbc', 0);

View file

@ -5,9 +5,9 @@ class ThePirateBayBridge extends BridgeAbstract{
$this->maintainer = "mitsukarenai";
$this->name = "The Pirate Bay";
$this->uri = "https://thepiratebay.vg/";
$this->uri = "https://thepiratebay.se/";
$this->description = "Returns results for the keywords. You can put several list of keywords by separating them with a semicolon (e.g. \"one show;another show\")";
$this->update = "2014-05-26";
$this->update = "2015-01-09";
$this->parameters[] =
'[
@ -60,7 +60,7 @@ class ThePirateBayBridge extends BridgeAbstract{
$keywordsList = explode(";",$param['q']);
foreach($keywordsList as $keywords){
$html = file_get_html('https://thepiratebay.vg/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404);
$html = file_get_html('https://thepiratebay.se/search/'.rawurlencode($keywords).'/0/3/0') or $this->returnError('Could not request TPB.', 404);
if ($html->find('table#searchResult', 0) == FALSE)
$this->returnError('No result for query '.$keywords, 404);
@ -68,7 +68,7 @@ class ThePirateBayBridge extends BridgeAbstract{
foreach($html->find('tr') as $element) {
$item = new \Item();
$item->uri = 'https://thepiratebay.vg/'.$element->find('a.detLink',0)->href;
$item->uri = 'https://thepiratebay.se/'.$element->find('a.detLink',0)->href;
$item->id = $item->uri;
$item->timestamp = parseDateTimestamp($element);
$item->title = $element->find('a.detLink',0)->plaintext;
@ -86,7 +86,7 @@ class ThePirateBayBridge extends BridgeAbstract{
}
public function getURI(){
return 'https://thepiratebay.vg/';
return 'https://thepiratebay.se/';
}
public function getCacheDuration(){

View file

@ -13,7 +13,7 @@ class TwitchApiBridge extends BridgeAbstract{
$this->name = "Twitch API Bridge";
$this->uri = "http://www.twitch.tv";
$this->description = "Returns the newest broadcasts or highlights by channel name using the Twitch API (v3)";
$this->update = "2015-07-14";
$this->update = "2016-01-09";
$this->parameters["Get channel without limit"] =
'[
@ -31,7 +31,7 @@ class TwitchApiBridge extends BridgeAbstract{
"value" : "true"
},
{
"name" : "Don\'t show broadcasts",
"name" : "Show highlights",
"value" : "false"
}
]
@ -58,7 +58,7 @@ class TwitchApiBridge extends BridgeAbstract{
"value" : "true"
},
{
"name" : "Don\'t show broadcasts",
"name" : "Show highlights",
"value" : "false"
}
]

View file

@ -8,7 +8,7 @@ class FileCache extends CacheAbstract{
public function loadData(){
$this->isPrepareCache();
$datas = json_decode(file_get_contents($this->getCacheFile()),true);
$datas = unserialize(file_get_contents($this->getCacheFile()));
$items = array();
foreach($datas as $aData){
$item = new \Item();
@ -24,7 +24,10 @@ class FileCache extends CacheAbstract{
public function saveData($datas){
$this->isPrepareCache();
$writeStream = file_put_contents($this->getCacheFile(), json_encode($datas));
//Re-encode datas to UTF-8
//$datas = Cache::utf8_encode_deep($datas);
$writeStream = file_put_contents($this->getCacheFile(), serialize($datas));
if(!$writeStream) {

View file

@ -36,6 +36,15 @@ class AtomFormat extends FormatAbstract{
// We prevent content from closing the CDATA too early.
$entryContent = is_null($data->content) ? '' : '<![CDATA[' . $this->sanitizeHtml(str_replace(']]>','',$data->content)) . ']]>';
// We generate a list of the enclosure links
$entryEnclosures = "";
foreach($data->enclosures as $enclosure) {
$entryEnclosures .= "<link rel=\"enclosure\" href=\"".$enclosure."\"></link>";
}
$entries .= <<<EOD
<entry>
@ -48,6 +57,7 @@ class AtomFormat extends FormatAbstract{
<id>{$entryUri}</id>
<updated>{$entryTimestamp}</updated>
<content type="html">{$entryContent}</content>
{$entryEnclosures}
</entry>
EOD;

View file

@ -70,6 +70,26 @@ class Cache{
return preg_match('@^[A-Z][a-zA-Z0-9-]*$@', $nameCache);
}
static public function utf8_encode_deep(&$input) {
if (is_string($input)) {
$input = utf8_encode($input);
} else if (is_array($input)) {
foreach ($input as &$value) {
Cache::utf8_encode_deep($value);
}
unset($value);
} else if (is_object($input)) {
$vars = array_keys(get_object_vars($input));
foreach ($vars as $var) {
Cache::utf8_encode_deep($input->$var);
}
}
}
static public function purge() {
$cacheTimeLimit = time() - 60*60*24 ;
$cachePath = 'cache';

View file

@ -80,6 +80,11 @@ CARD;
$additionalInfoString .= " pattern=\"".$inputEntry['pattern']."\"";
}
if(isset($inputEntry['title'])) {
$additionalInfoString .= " title=\"" .$inputEntry['title']."\"";
}
if(!isset($inputEntry['exampleValue'])) $inputEntry['exampleValue'] = "";
$idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($inputEntry['identifier']);

View file

@ -2,15 +2,19 @@
interface ItemInterface{}
/**
* Object to store datas collect informations
* FIXME : not sur this logic is the good, I think recast all is necessary
*/
* Object to store datas collect informations
* FIXME : not sur this logic is the good, I think recast all is necessary
*/
class Item implements ItemInterface{
// FIXME : use the arrayInterface instead
public $enclosures = array();
public function __set($name, $value){
$this->$name = $value;
}
public function __get($name){
return isset($this->$name) ? $this->$name : null;
return (isset($this->$name) ? $this->$name : null);
}
}