X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FImportBundle%2FImport%2FInstapaperImport.php;h=3aa12f6fb6960e39fb19e914109fa1f3af5d7c68;hb=9fe87bc2e20fa95573287a61ef9798cc15648187;hp=356acf230207e75b571fb1d3b0e62ff926e6b5f3;hpb=ff1a5362f7254d686864ea53994da6c517b3d3e8;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php index 356acf23..3aa12f6f 100644 --- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php +++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php @@ -68,18 +68,32 @@ class InstapaperImport extends AbstractImport continue; } + // last element in the csv is the folder where the content belong + // BUT it can also be the status (since status = folder in Instapaper) + // and we don't want archive, unread & starred to become a tag + $tags = null; + if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) { + $tags = [$data[3]]; + } + $entries[] = [ 'url' => $data[0], 'title' => $data[1], 'status' => $data[3], 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred', 'is_starred' => $data[3] === 'Starred', - 'content_type' => '', - 'language' => '', + 'html' => false, + 'tags' => $tags, ]; } fclose($handle); + if (empty($entries)) { + $this->logger->error('InstapaperImport: no entries in imported file'); + + return false; + } + if ($this->producer) { $this->parseEntriesForProducer($entries); @@ -111,7 +125,15 @@ class InstapaperImport extends AbstractImport $entry->setTitle($importedEntry['title']); // update entry with content (in case fetching failed, the given entry will be return) - $entry = $this->fetchContent($entry, $importedEntry['url'], $importedEntry); + $this->fetchContent($entry, $importedEntry['url'], $importedEntry); + + if (!empty($importedEntry['tags'])) { + $this->tagsAssigner->assignTagsToEntry( + $entry, + $importedEntry['tags'], + $this->em->getUnitOfWork()->getScheduledEntityInsertions() + ); + } $entry->setArchived($importedEntry['is_archived']); $entry->setStarred($importedEntry['is_starred']);