aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Import')
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php6
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php19
-rw-r--r--src/Wallabag/ImportBundle/Import/ReadabilityImport.php16
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagImport.php16
4 files changed, 18 insertions, 39 deletions
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 2af0e69b..a1a14576 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -79,20 +79,20 @@ abstract class AbstractImport implements ImportInterface
79 79
80 /** 80 /**
81 * Fetch content from the ContentProxy (using graby). 81 * Fetch content from the ContentProxy (using graby).
82 * If it fails return false instead of the updated entry. 82 * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
83 * 83 *
84 * @param Entry $entry Entry to update 84 * @param Entry $entry Entry to update
85 * @param string $url Url to grab content for 85 * @param string $url Url to grab content for
86 * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url 86 * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url
87 * 87 *
88 * @return Entry|false 88 * @return Entry
89 */ 89 */
90 protected function fetchContent(Entry $entry, $url, array $content = []) 90 protected function fetchContent(Entry $entry, $url, array $content = [])
91 { 91 {
92 try { 92 try {
93 return $this->contentProxy->updateEntry($entry, $url, $content); 93 return $this->contentProxy->updateEntry($entry, $url, $content);
94 } catch (\Exception $e) { 94 } catch (\Exception $e) {
95 return false; 95 return $entry;
96 } 96 }
97 } 97 }
98 98
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 1bf22d68..e00eb44b 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -199,24 +199,16 @@ class PocketImport extends AbstractImport
199 } 199 }
200 200
201 $entry = new Entry($this->user); 201 $entry = new Entry($this->user);
202 $entry = $this->fetchContent($entry, $url); 202 $entry->setUrl($url);
203
204 // jump to next entry in case of problem while getting content
205 if (false === $entry) {
206 ++$this->skippedEntries;
207 203
208 return; 204 // update entry with content (in case fetching failed, the given entry will be return)
209 } 205 $entry = $this->fetchContent($entry, $url);
210 206
211 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 207 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
212 if ($importedEntry['status'] == 1 || $this->markAsRead) { 208 $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead);
213 $entry->setArchived(true);
214 }
215 209
216 // 0 or 1 - 1 If the item is starred 210 // 0 or 1 - 1 If the item is starred
217 if ($importedEntry['favorite'] == 1) { 211 $entry->setStarred($importedEntry['favorite'] == 1);
218 $entry->setStarred(true);
219 }
220 212
221 $title = 'Untitled'; 213 $title = 'Untitled';
222 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') { 214 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') {
@@ -226,7 +218,6 @@ class PocketImport extends AbstractImport
226 } 218 }
227 219
228 $entry->setTitle($title); 220 $entry->setTitle($title);
229 $entry->setUrl($url);
230 221
231 // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image 222 // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image
232 if (isset($importedEntry['has_image']) && $importedEntry['has_image'] > 0 && isset($importedEntry['images'][1])) { 223 if (isset($importedEntry['has_image']) && $importedEntry['has_image'] > 0 && isset($importedEntry['images'][1])) {
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
index b852f8f0..fa2b7053 100644
--- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
+++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php
@@ -103,18 +103,12 @@ class ReadabilityImport extends AbstractImport
103 'created_at' => $importedEntry['date_added'], 103 'created_at' => $importedEntry['date_added'],
104 ]; 104 ];
105 105
106 $entry = $this->fetchContent( 106 $entry = new Entry($this->user);
107 new Entry($this->user), 107 $entry->setUrl($data['url']);
108 $data['url'], 108 $entry->setTitle($data['title']);
109 $data
110 );
111
112 // jump to next entry in case of problem while getting content
113 if (false === $entry) {
114 ++$this->skippedEntries;
115 109
116 return; 110 // update entry with content (in case fetching failed, the given entry will be return)
117 } 111 $entry = $this->fetchContent($entry, $data['url'], $data);
118 112
119 $entry->setArchived($data['is_archived']); 113 $entry->setArchived($data['is_archived']);
120 $entry->setStarred($data['is_starred']); 114 $entry->setStarred($data['is_starred']);
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php
index 969a6a04..043bb0a2 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagImport.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php
@@ -101,18 +101,12 @@ abstract class WallabagImport extends AbstractImport
101 101
102 $data = $this->prepareEntry($importedEntry); 102 $data = $this->prepareEntry($importedEntry);
103 103
104 $entry = $this->fetchContent( 104 $entry = new Entry($this->user);
105 new Entry($this->user), 105 $entry->setUrl($data['url']);
106 $importedEntry['url'], 106 $entry->setTitle($data['title']);
107 $data
108 );
109
110 // jump to next entry in case of problem while getting content
111 if (false === $entry) {
112 ++$this->skippedEntries;
113 107
114 return; 108 // update entry with content (in case fetching failed, the given entry will be return)
115 } 109 $entry = $this->fetchContent($entry, $data['url'], $data);
116 110
117 if (array_key_exists('tags', $data)) { 111 if (array_key_exists('tags', $data)) {
118 $this->contentProxy->assignTagsToEntry( 112 $this->contentProxy->assignTagsToEntry(