parent
c56f7abc2a
commit
1cfe939927
1 changed files with 19 additions and 19 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
class AskfmBridge extends BridgeAbstract {
|
class AskfmBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const MAINTAINER = 'az5he6ch';
|
const MAINTAINER = 'az5he6ch, logmanoriginal';
|
||||||
const NAME = 'Ask.fm Answers';
|
const NAME = 'Ask.fm Answers';
|
||||||
const URI = 'https://ask.fm/';
|
const URI = 'https://ask.fm/';
|
||||||
const CACHE_TIMEOUT = 300; //5 min
|
const CACHE_TIMEOUT = 300; //5 min
|
||||||
|
@ -19,39 +19,39 @@ class AskfmBridge extends BridgeAbstract {
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
or returnServerError('Requested username can\'t be found.');
|
or returnServerError('Requested username can\'t be found.');
|
||||||
|
|
||||||
foreach($html->find('div.streamItem-answer') as $element) {
|
$html = defaultLinkTo($html, self::URI);
|
||||||
|
|
||||||
|
foreach($html->find('article.streamItem-answer') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = self::URI . $element->find('a.streamItemsAge', 0)->href;
|
$item['uri'] = $element->find('a.streamItem_meta', 0)->href;
|
||||||
$question = trim($element->find('h1.streamItemContent-question', 0)->innertext);
|
$question = trim($element->find('header.streamItem_header', 0)->innertext);
|
||||||
|
|
||||||
$item['title'] = trim(
|
$item['title'] = trim(
|
||||||
htmlspecialchars_decode($element->find('h1.streamItemContent-question', 0)->plaintext,
|
htmlspecialchars_decode($element->find('header.streamItem_header', 0)->plaintext,
|
||||||
ENT_QUOTES
|
ENT_QUOTES
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$answer = trim($element->find('p.streamItemContent-answer', 0)->innertext);
|
$item['timestamp'] = strtotime($element->find('time', 0)->datetime);
|
||||||
|
|
||||||
// Doesn't work, DOM parser doesn't seem to like data-hint, dunno why
|
$answer = trim($element->find('div.streamItem_content', 0)->innertext);
|
||||||
#$item['update'] = $element->find('a.streamitemsage',0)->data-hint;
|
|
||||||
|
|
||||||
// This probably should be cleaned up, especially for YouTube embeds
|
// This probably should be cleaned up, especially for YouTube embeds
|
||||||
$visual = $element->find('div.streamItemContent-visual', 0)->innertext;
|
if($visual = $element->find('div.streamItem_visual', 0)) {
|
||||||
//Fix tracking links, also doesn't work
|
$visual = $visual->innertext;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix tracking links, also doesn't work
|
||||||
foreach($element->find('a') as $link) {
|
foreach($element->find('a') as $link) {
|
||||||
if(strpos($link->href, 'l.ask.fm') !== false) {
|
if(strpos($link->href, 'l.ask.fm') !== false) {
|
||||||
|
|
||||||
// Too slow
|
|
||||||
#$link->href = str_replace('#_=_', '', get_headers($link->href, 1)['Location']);
|
|
||||||
|
|
||||||
$link->href = $link->plaintext;
|
$link->href = $link->plaintext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '<p>' . $question . '</p><p>' . $answer . '</p><p>' . $visual . '</p>';
|
$item['content'] = '<p>' . $question
|
||||||
// Fix relative links without breaking // scheme used by YouTube stuff
|
. '</p><p>' . $answer
|
||||||
$content = preg_replace('#href="\/(?!\/)#', 'href="' . self::URI, $content);
|
. '</p><p>' . $visual . '</p>';
|
||||||
$item['content'] = $content;
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class AskfmBridge extends BridgeAbstract {
|
||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
if(!is_null($this->getInput('u'))) {
|
if(!is_null($this->getInput('u'))) {
|
||||||
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
|
return self::URI . urlencode($this->getInput('u'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
|
|
Loading…
Reference in a new issue