diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-09 09:36:07 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-11 21:58:55 +0200 |
commit | 6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926 (patch) | |
tree | 38ea829aeea879f4bfdd9873cea556a244247b7e /src/Wallabag/ImportBundle | |
parent | 3aca0a9f00417b64203a660dee0a2b4c0fe22ac8 (diff) | |
download | wallabag-6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926.tar.gz wallabag-6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926.tar.zst wallabag-6d65c0a8b089d3caa6f8e20d7935a9fe2f87d926.zip |
Add ability to define created_at for all import
At the moment only Readability & wallabag v2 import allow created_at import.
Pocket removed `time_added` field from their API v2 to v3...
And wallabag v1 doesn't export that value.
Diffstat (limited to 'src/Wallabag/ImportBundle')
4 files changed, 15 insertions, 0 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php index 845380b7..92dcdd40 100644 --- a/src/Wallabag/ImportBundle/Import/PocketImport.php +++ b/src/Wallabag/ImportBundle/Import/PocketImport.php | |||
@@ -193,6 +193,11 @@ class PocketImport extends AbstractImport | |||
193 | $this->client = $client; | 193 | $this->client = $client; |
194 | } | 194 | } |
195 | 195 | ||
196 | /** | ||
197 | * {@inheritdoc} | ||
198 | * | ||
199 | * @see https://getpocket.com/developer/docs/v3/retrieve | ||
200 | */ | ||
196 | public function parseEntry(array $importedEntry) | 201 | public function parseEntry(array $importedEntry) |
197 | { | 202 | { |
198 | $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; | 203 | $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; |
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index 915d4cd3..8f080d38 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php | |||
@@ -89,6 +89,9 @@ class ReadabilityImport extends AbstractImport | |||
89 | return true; | 89 | return true; |
90 | } | 90 | } |
91 | 91 | ||
92 | /** | ||
93 | * {@inheritdoc} | ||
94 | */ | ||
92 | public function parseEntry(array $importedEntry) | 95 | public function parseEntry(array $importedEntry) |
93 | { | 96 | { |
94 | $existingEntry = $this->em | 97 | $existingEntry = $this->em |
@@ -108,6 +111,7 @@ class ReadabilityImport extends AbstractImport | |||
108 | 'language' => '', | 111 | 'language' => '', |
109 | 'is_archived' => $importedEntry['archive'] || $this->markAsRead, | 112 | 'is_archived' => $importedEntry['archive'] || $this->markAsRead, |
110 | 'is_starred' => $importedEntry['favorite'], | 113 | 'is_starred' => $importedEntry['favorite'], |
114 | 'created_at' => $importedEntry['date_added'], | ||
111 | ]; | 115 | ]; |
112 | 116 | ||
113 | $entry = $this->fetchContent( | 117 | $entry = $this->fetchContent( |
@@ -125,6 +129,7 @@ class ReadabilityImport extends AbstractImport | |||
125 | 129 | ||
126 | $entry->setArchived($data['is_archived']); | 130 | $entry->setArchived($data['is_archived']); |
127 | $entry->setStarred($data['is_starred']); | 131 | $entry->setStarred($data['is_starred']); |
132 | $entry->setCreatedAt(new \DateTime($data['created_at'])); | ||
128 | 133 | ||
129 | $this->em->persist($entry); | 134 | $this->em->persist($entry); |
130 | ++$this->importedEntries; | 135 | ++$this->importedEntries; |
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index 026567b0..8e50b135 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php | |||
@@ -139,6 +139,10 @@ abstract class WallabagImport extends AbstractImport | |||
139 | $entry->setArchived($data['is_archived']); | 139 | $entry->setArchived($data['is_archived']); |
140 | $entry->setStarred($data['is_starred']); | 140 | $entry->setStarred($data['is_starred']); |
141 | 141 | ||
142 | if (!empty($data['created_at'])) { | ||
143 | $entry->setCreatedAt(new \DateTime($data['created_at'])); | ||
144 | } | ||
145 | |||
142 | $this->em->persist($entry); | 146 | $this->em->persist($entry); |
143 | ++$this->importedEntries; | 147 | ++$this->importedEntries; |
144 | 148 | ||
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php index 292b72a7..4f001062 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php +++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php | |||
@@ -42,6 +42,7 @@ class WallabagV1Import extends WallabagImport | |||
42 | 'is_archived' => $entry['is_read'] || $this->markAsRead, | 42 | 'is_archived' => $entry['is_read'] || $this->markAsRead, |
43 | 'is_starred' => $entry['is_fav'], | 43 | 'is_starred' => $entry['is_fav'], |
44 | 'tags' => '', | 44 | 'tags' => '', |
45 | 'created_at' => '', | ||
45 | ]; | 46 | ]; |
46 | 47 | ||
47 | // force content to be refreshed in case on bad fetch in the v1 installation | 48 | // force content to be refreshed in case on bad fetch in the v1 installation |