import depuis Pocket, yeah cf #3

This commit is contained in:
nicosomb 2013-04-17 10:35:50 +02:00
parent a672f9f506
commit 0753bfefd7
4 changed files with 1782 additions and 0 deletions

View file

@ -4,6 +4,7 @@ poche is based on :
* Encoding https://github.com/neitanod/forceutf8
* logo by Brightmix http://www.iconfinder.com/icondetails/43256/128/jeans_monotone_pocket_icon
* icons http://icomoon.io
* PHP Simple HTML DOM Parser (for Pocket import) http://simplehtmldom.sourceforge.net/
poche is developed by Nicolas Lœuillet under the Do What the Fuck You Want to Public License

View file

@ -27,6 +27,10 @@ You **have** to protect your db/poche.sqlite file. Modify the virtual host of yo
</Files>
```
## Import from Pocket
If you want to import your Pocket datas, [export them here](https://getpocket.com/export). Put the HTML file in your poche directory, execute import.php file locally by following instructions. Be careful, the script can take a very long time.
## License
Copyright © 2010-2013 Nicolas Lœuillet <nicolas@loeuillet.org>
This work is free. You can redistribute it and/or modify it under the

55
import.php Normal file
View file

@ -0,0 +1,55 @@
<?php
/**
* poche, a read it later open source system
*
* @category poche
* @author Nicolas Lœuillet <support@inthepoche.com>
* @copyright 2013
* @license http://www.wtfpl.net/ see COPYING file
*/
set_time_limit(0);
include dirname(__FILE__).'/inc/config.php';
include dirname(__FILE__).'/inc/simple_html_dom.php';
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>';
}
else {
$html = new simple_html_dom();
$html->load_file('ril_export.html');
$read = '0';
$errors = array();
foreach($html->find('ul') as $ul)
{
foreach($ul->find('li') as $li)
{
$a = $li->find('a');
$url = $a[0]->href;
$parametres_url = prepare_url($url);
$sql_action = 'INSERT INTO entries ( url, title, content, is_read ) VALUES (?, ?, ?, ?)';
$params_action = array($url, $parametres_url['title'], $parametres_url['content'], $read);
try
{
# action query
if (isset($sql_action))
{
$query = $db->getHandle()->prepare($sql_action);
$query->execute($params_action);
}
}
catch (Exception $e)
{
$errors[] = $e->getMessage();
}
}
# 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>';
}

1722
inc/simple_html_dom.php Normal file

File diff suppressed because it is too large Load diff