wallabag: Pocket imports are not working at all

Environment

  • Version: 2.6.9
  • Installation: Docker
  • PHP version: 8.1
  • OS: Debian 12
  • Database: SQLite / MySQL
  • Parameters: Not relevant

What is the bug?

Wallabag fails to import Pocket links.

When trying to import using the Pocket API, the import fails randomly. Sometimes it imports nothing, sometimes it imports 100-200 links. After that it fails with a cryptic error message such as:

An exception occurred while executing a query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: ‘\xF0\x9F\x91\x87</…’ for column wallabag.wallabag_entry.content at row 1

Even though the imported links do not contain any UTF-8 codepoints or smilies.

Converting the exported file to JSON and then importing that using the Wallabagv2 JSON importer also fails for similar reasons.

What steps will reproduce the bug?

  • Install Wallabag in a Docker container
  • Try to import Pocket links using the API
  • It fails

If you need anymore information please let me know.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

Import from Pocket into wallabag.it thanks to the HTML file will be available in coming weeks.

Seeing the same on a wallbag.it account

500: Internal Server Error
Wallabag\ImportBundle\Import\AbstractImport::parseEntriesForProducer(): Argument #1 ($entries) must be of type array, null given, called in /var/www/wallabag.it/app2019/src/Wallabag/ImportBundle/Import/PocketImport.php on line 134

Web and retrieve are enabled.

I tried @utrenkner 's solution, but I was getting timeouts while trying to import the CSV, so I ended up using the API to import all data.

  1. Go to https://getpocket.com/export and request to export your data (thanks @utrenkner !)
  2. For me it took about 2 minutes to get the email with the zip with my 500 entries
  3. Unzip the zip, and you should have a part_000000.csv
  4. Go to https://wallabag.yourdomain.com/developer/client/create and create a new Client (we’ll need both the Client ID and the Client Secret for the next step
  5. Save the following python script to a file (e.g. convert.py) and modify the variables on the top with your data
#!/usr/bin/env python3
import csv
import requests
import sys

WALLABAG_URL = "https://wallabag.yourdomain.com"
CLIENT_ID = "yourclientid"
CLIENT_SECRET = "yourclientsecret"
USERNAME = "yourusername (default: wallabag)"
PASSWORD = "yourpassword (default: wallabag)"

r = requests.post(
    f"{WALLABAG_URL}/oauth/v2/token",
    data={
        "grant_type": "password",
        "client_id": CLIENT_ID,
        "client_secret": CLIENT_SECRET,
        "username": USERNAME,
        "password": PASSWORD,
    },
)
access_token = r.json()["access_token"]

headers = {"Authorization": f"Bearer {access_token}"}
with open(sys.argv[1], "r", encoding="utf8") as infile:
    reader = csv.reader(infile, delimiter=",", quotechar='"')

    for line in reader:
        r = requests.post(
            f"{WALLABAG_URL}/api/entries", headers=headers, data={"url": line[1]}
        )
        print(line)
        print(r.status_code)

  1. Make the script executable
chmod u+x convert.py
  1. Execute the script passing the unziped Pocket csv
./convert.py part_000000.csv

Profit!

That is excellent news! I just subscribed as a supporter for your service. Even though I might end up hosting Wallabag myself, I am happy that you offer this service and support this eco-system! Many thanks.

I have investigated this and found it to be an error from requesting too many entries from pocket. Their API documentation specifies a maximum of 30 entries per query (see the Pagination section of this page).

Changing NB_ELEMENTS in PocketImport.php to 30 seems to fix the issue, at least for me.

Excellent news! Does this include support of the date field included in the CSV file during import?

We are working on the Pocket import via their export file

As this imho still doesn’t work and many people will need it with Pocket closing, I put together script from @cgkantidis (thanks!) and added support for tags and archive status. Maybe it will help someone: https://codeberg.org/kepi/wallaback_pocket_csv_import

I don’t know if the patch does not work or if it has not yet found its way into wallabag.it. I still get the error-message when I try to import my 2500+ URLs from Pocket.

For those who, like me, do not want to wait any longer: You can export your Pocket data via https://getpocket.com/export. They will e-mail you a zip file with a CSV of your saved pages, which is structured like this:

title, url, time_added, tags, status

This is very similar to the Instapaper export file, which looks like this:

URL, Title, Selection, Folder, Timestamp

I rearranged the columns in my favorite spreadsheet application, saved it as CSV, and was able to use the Instapaper import of Wallabag.

Note, that the column “Folder” in the Instapaper CSV is translated to tags in Wallabag. However, it seems that the content of the Folder field is taken as one tag. So if the Pocket export file contains several tags for one page, it is saved as “tag1|tag2|tag3”. And exactly this string is interpreted by the Wallabag-Instaper importer as one tag. I went through all entries that had more than one tag in Pocket (i.e. at least one pipe in the tags column) and deleted all but one of them. Worked fine for me.

Thank you @ruffinge and @j0k3r!!!

@nicosomb Could you please let us know, once wallabag.it has updated to a version which includes this commit?

Same problem here. Trying to import my Pocket collection into wallabag.it.

Is there an import for TXT or CSV with just URLs? I used Pocket’s export to have all my saved articles’ URLs in a CSV file, but I don’t see an option to import a list into Wallabag.

@j0k3r true. Then just the second line is relevant.