diff --git a/CREDITS b/CREDITS index 916eae5d8..6df488ee4 100644 --- a/CREDITS +++ b/CREDITS @@ -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 diff --git a/README.md b/README.md index d1e1f0ff4..c678d11cf 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ You **have** to protect your db/poche.sqlite file. Modify the virtual host of yo ``` +## 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 This work is free. You can redistribute it and/or modify it under the diff --git a/import.php b/import.php new file mode 100644 index 000000000..7a657c21b --- /dev/null +++ b/import.php @@ -0,0 +1,55 @@ + + * @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.
Bye bye Pocket, let\'s go !'; +} +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