Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wrote a json converter, from Journey.cloud export to DailyTxt import format #13

Closed
xontik opened this issue Aug 4, 2022 · 3 comments

Comments

@xontik
Copy link

xontik commented Aug 4, 2022

Would you be interested in it ? it worked for me i wont use it again so if you want it it's yours

const { promises: fs } = require("fs");
const striptags = require("striptags");

const getFiles = async () => {
  const list = await fs.readdir("./input");

  const data = list.map((name) => {
    const entry = require(`./input/${name}`);
    const date = new Date(+name.split("-")[0]);
    return {
      date,
      text: entry.text,
    };
  });
  const out = {};

  data.forEach((entry) => {
    const month = "" + entry.date.getMonth();
    const year = entry.date.getFullYear();
    if (out[year] === undefined) {
      out[year] = { [month]: { days: [] } };
    } else {
      if (out[year][month] === undefined) {
        out[year][month] = { days: [] };
      }
    }
    const day = entry.date.getDate();

    out[year][month].days.push({
      day,
      text: striptags(entry.text),
      date_written: `${("" + day).padStart(2, "0")}/${("" + month).padStart(
        2,
        "0"
      )}/${year} ${("" + entry.date.getHours()).padStart(2, "0")}:${(
        "" + entry.date.getMinutes()
      ).padStart(2, "0")}`,
    });
  });

  for (const [year, months] of Object.entries(out)) {
    if (!fs.mkdir(`output/${year}`, { recursive: true })) {
      fs.mkdirSync(`output/${year}`);
    }
    for (const [month, days] of Object.entries(months)) {
      fs.writeFile(
        `output/${year}/${("" + month).padStart(2, "0")}.json`,
        JSON.stringify(days),
        { flag: "a+" }
      );
    }
  }
};

getFiles();
@PhiTux
Copy link
Owner

PhiTux commented Aug 4, 2022

Wow, that's cool (and I didn't even know that journey.cloud exists until now).

What about the encryption? This is obviously missing, right?
But how is your imported text then even working with DailyTxT? Normally all text is saved encrypted in the files and gets decrypted when loading into the browser.

@xontik
Copy link
Author

xontik commented Aug 4, 2022

I just converted their exported (and decrypted) JSON into your DailyTxt exported (and decrypted) JSON.

Then I used your restore from zip fonctionality.

My code is bullshit but I thought it could help someone !

@PhiTux
Copy link
Owner

PhiTux commented Aug 4, 2022

Ah, thanks for clarification!
I didn't read properly concerning the import-functionality.

I think what I would just do: link to this issue and your code from within the readme.

Thanks very much :)

@PhiTux PhiTux closed this as completed Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants