[GH-ISSUE #390] Improved import from Pocket not importing tags #249

Open
opened 2026-02-25 23:33:47 +03:00 by kerem · 1 comment
Owner

Originally created by @robflate on GitHub (Feb 28, 2022).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/390

I ran the Improved import from Pocket on a fresh install and it correctly imported my bookmarks with images and the title but it did not import my tags.

I also ran the built in shiori pocket method which correctly imported my tags but not the title or images.

How can I get titles, images and tags from Pocket? Thanks.

Note: I'm running the latest version in docker using a MYSQL database.

Originally created by @robflate on GitHub (Feb 28, 2022). Original GitHub issue: https://github.com/go-shiori/shiori/issues/390 I ran the [Improved import from Pocket ](https://github.com/go-shiori/shiori/wiki/Usage#improved-import-from-pocket) on a fresh install and it correctly imported my bookmarks with images and the title but it **did not** import my tags. I also ran the built in shiori pocket method which correctly imported my tags but not the title or images. How can I get titles, images **and tags** from Pocket? Thanks. Note: I'm running the latest version in docker using a MYSQL database.
Author
Owner

@Eralde commented on GitHub (Mar 27, 2022):

@robflate I've also stumbled into this, but managed to extract tags via nodejs:

// index.mjs
//
// > node index.mjs
import { readFileSync, writeFileSync } from 'fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

const POCKET_EXPORT_FILENAME = join(__dirname, 'Pocket_export.html');
const OUTPUT_FILENAME = join(__dirname, 'shiori_commands.txt');

const contents = readFileSync(POCKET_EXPORT_FILENAME, {encoding: 'utf-8'});
const items = contents.split('<li>');

const processItem = (itemStr) => {
    const hrefMatch = itemStr.match(/href="([^\"]+)"/);
    const tagsMatch = itemStr.match(/tags="([^\"]*)"/);
    const nameMatch = itemStr.match(/>([^<]+)<\/a/);

    if (!hrefMatch || !tagsMatch || !nameMatch) {
        console.warn(`Failed to parse "${itemStr}"`);

        return null;
    }

    const href = hrefMatch[1];
    const name = nameMatch[1];

    const tagsList = tagsMatch[1]
        .split(',')
        .filter(Boolean);

    return {
        href,
        tagsList,
        name,
    }
}

const toShioriCmdArgs = ({href, tagsList, name}) => {
    const tags = tagsList.length > 0
        ? ` --tags "${tagsList.join(',')}"`
        : '';

    // Shiori does a better job of extracting names itself    
    /*const nameStr = name.includes(' ')
        ? `'${name}'`
        : name;
    */

    return `${href} ${tags}`;
};


const list = items
    .slice(1,)
    .map(item => processItem(item))
    .filter(Boolean)
    .map(itemData => toShioriCmdArgs(itemData))
    .join('\n');


writeFileSync(OUTPUT_FILENAME, list, {encoding: 'utf-8'});

Then I've put the output file to the folder synced with the Docker container & ran a slightly modified script inside the container:

head -n 50 /srv/shiori/shiori_commands.txt | xargs -e$'\n' -I {} echo "shiori add {}" | xargs -I {} sh -c {}

^^ Adds first 50 links from the exported list.

Maybe this will be useful to you 😅

<!-- gh-comment-id:1079936180 --> @Eralde commented on GitHub (Mar 27, 2022): @robflate I've also stumbled into this, but managed to extract tags via nodejs: ```javascript // index.mjs // // > node index.mjs import { readFileSync, writeFileSync } from 'fs'; import { dirname, join } from 'path'; import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); const POCKET_EXPORT_FILENAME = join(__dirname, 'Pocket_export.html'); const OUTPUT_FILENAME = join(__dirname, 'shiori_commands.txt'); const contents = readFileSync(POCKET_EXPORT_FILENAME, {encoding: 'utf-8'}); const items = contents.split('<li>'); const processItem = (itemStr) => { const hrefMatch = itemStr.match(/href="([^\"]+)"/); const tagsMatch = itemStr.match(/tags="([^\"]*)"/); const nameMatch = itemStr.match(/>([^<]+)<\/a/); if (!hrefMatch || !tagsMatch || !nameMatch) { console.warn(`Failed to parse "${itemStr}"`); return null; } const href = hrefMatch[1]; const name = nameMatch[1]; const tagsList = tagsMatch[1] .split(',') .filter(Boolean); return { href, tagsList, name, } } const toShioriCmdArgs = ({href, tagsList, name}) => { const tags = tagsList.length > 0 ? ` --tags "${tagsList.join(',')}"` : ''; // Shiori does a better job of extracting names itself /*const nameStr = name.includes(' ') ? `'${name}'` : name; */ return `${href} ${tags}`; }; const list = items .slice(1,) .map(item => processItem(item)) .filter(Boolean) .map(itemData => toShioriCmdArgs(itemData)) .join('\n'); writeFileSync(OUTPUT_FILENAME, list, {encoding: 'utf-8'}); ``` Then I've put the output file to the folder synced with the Docker container & ran a slightly modified script inside the container: ```shell head -n 50 /srv/shiori/shiori_commands.txt | xargs -e$'\n' -I {} echo "shiori add {}" | xargs -I {} sh -c {} ``` ^^ Adds first 50 links from the exported list. Maybe this will be useful to you 😅
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shiori#249
No description provided.