mirror of
https://github.com/moparisthebest/wallabag
synced 2024-11-23 17:42:15 -05:00
first test for readability import
This commit is contained in:
parent
99dd7d3877
commit
02ea9f0769
77
import.php
77
import.php
@ -14,37 +14,64 @@ include dirname(__FILE__).'/inc/config.php';
|
|||||||
include dirname(__FILE__).'/inc/simple_html_dom.php';
|
include dirname(__FILE__).'/inc/simple_html_dom.php';
|
||||||
|
|
||||||
if (!isset($_GET['start'])) {
|
if (!isset($_GET['start'])) {
|
||||||
echo 'Please execute the import script locally, it can take a very long time. <br /><a href="import.php?start">Bye bye Pocket, let\'s go !</a>';
|
echo '
|
||||||
|
Please execute the import script locally, it can take a very long time. <br /><br />
|
||||||
|
Please choose between Pocket & Readabilty :
|
||||||
|
<br /><a href="import.php?start=pocket">Bye bye Pocket, let\'s go !</a>
|
||||||
|
<br /><a href="import.php?start=readability">Bye bye Readability, let\'s go !</a>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$html = new simple_html_dom();
|
if ($_GET['start'] == 'pocket') {
|
||||||
$html->load_file('ril_export.html');
|
$html = new simple_html_dom();
|
||||||
|
$html->load_file('ril_export.html');
|
||||||
|
|
||||||
$read = 0;
|
$read = 0;
|
||||||
$errors = array();
|
$errors = array();
|
||||||
foreach($html->find('ul') as $ul)
|
foreach($html->find('ul') as $ul)
|
||||||
{
|
|
||||||
foreach($ul->find('li') as $li)
|
|
||||||
{
|
{
|
||||||
$a = $li->find('a');
|
foreach($ul->find('li') as $li)
|
||||||
$url = $a[0]->href;
|
{
|
||||||
|
$a = $li->find('a');
|
||||||
|
$url = $a[0]->href;
|
||||||
|
|
||||||
|
action_to_do('add', $url);
|
||||||
action_to_do('add', $url);
|
if ($read == '1') {
|
||||||
if ($read == '1') {
|
$last_id = $db->getHandle()->lastInsertId();
|
||||||
$last_id = $db->getHandle()->lastInsertId();
|
$sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
||||||
$sql_update = "UPDATE entries SET is_read=~is_read WHERE id=?";
|
$params_update = array($last_id);
|
||||||
$params_update = array($last_id);
|
$query_update = $db->getHandle()->prepare($sql_update);
|
||||||
$query_update = $db->getHandle()->prepare($sql_update);
|
$query_update->execute($params_update);
|
||||||
$query_update->execute($params_update);
|
}
|
||||||
}
|
}
|
||||||
|
# Pocket génère un fichier HTML avec deux <ul>
|
||||||
|
# Le premier concerne les éléments non lus
|
||||||
|
# Le second concerne les éléments archivés
|
||||||
|
$read = 1;
|
||||||
}
|
}
|
||||||
# Pocket génère un fichier HTML avec deux <ul>
|
|
||||||
# Le premier concerne les éléments non lus
|
|
||||||
# Le second concerne les éléments archivés
|
|
||||||
$read = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>';
|
echo 'Import from Pocket completed. <a href="index.php">Welcome to #poche !</a>';
|
||||||
logm('import from pocket completed');
|
logm('import from pocket completed');
|
||||||
|
}
|
||||||
|
else if ($_GET['start'] == 'readability') {
|
||||||
|
$str_data = file_get_contents("readability");
|
||||||
|
$data = json_decode($str_data,true);
|
||||||
|
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
|
$url = '';
|
||||||
|
foreach ($value as $key2 => $value2) {
|
||||||
|
if ($key2 == 'article__url') {
|
||||||
|
$url = $value2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($url != '')
|
||||||
|
action_to_do('add', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo 'Import from Readability completed. <a href="index.php">Welcome to #poche !</a>';
|
||||||
|
logm('import from Readability completed');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo 'Error with the import. <a href="index.php">Welcome to #poche !</a>';
|
||||||
|
logm('error with the import');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user