From 05cacf72b2cf47d3329d0b14e526cd566e288ea9 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:53 +0200 Subject: [PATCH] Added README. --- README.md | 40 ++++++++++++++++++++++++++++++++++++++++ fetchContent.js | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..55aa991 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# reddit-post-dump + +## Installation +`npm install` + +## Usage +`node app.js --user={username}` + +## Configuration +The default configuration aims to be sensible, and the application may be used without any further tweaking. However, this application came to life because I was not satisfied by the organizatory facilities of similar applications, thus a multitude of options are at your disposal as described in this document. + +### Patterns +Path patterns dictate where and how a file will be saved. Various variables and options are available, and you may use subdirectories divided by `/`. + +### Variables +* `$postId`: The ID of the reddit post +* `$postTitle`: The title of the reddit post +* `$postUser`: The user that submitted the post, almost always equivalent to the `--user` command line argument +* `$postDate`: The submission date of the reddit post, formatted by the `dateformat` configuration described below + +* `$albumId`: The ID of the media host album +* `$albumTitle`: The title of the media host album +* `$albumDescription`: The description of the media host album +* `$albumDate`: The submission date of the media host album, formatted by the `dateformat` configuration described below + +* `$itemId`: The ID of the individual image or video +* `$itemTitle`: The title of the individual image or video +* `$itemDescription`: The description of the individual image or video +* `$itemDate`: The submission date of the individual image or video, formatted by the `dateformat` configuration described below +* `$itemIndex`: The index of the individual image or video in an album, offset by the `indexOffset` configuration described below +* `$ext`: The extension of the file. Must practically always be included. + +### Date format +Affects the representation of `$postDate`, `$albumDate` and `$itemDate` and defaults to `YYYYMMDD`. See [this documentation](https://date-fns.org/v1.29.0/docs/format) for an overview of all available tokens. + +### Index offset +Arrays start at 0, but as to not tire myself out debating the matter, you may offset it my any numerical value you like. Affects the `$itemIndex` variable for album items. + +### Slash substitute +The patterns are Unix file paths, and a `/` therefore indicates a new directory. You may freely use directories in your paths, but titles or descriptions may contain a `/` that is not supposed to create a new directory. All instances of `/` in a variable value will be replaced with the configured slash substitute. diff --git a/fetchContent.js b/fetchContent.js index c014a34..ce3c542 100644 --- a/fetchContent.js +++ b/fetchContent.js @@ -14,7 +14,7 @@ const extensions = { }; function interpolate(path, post, item, index) { - const dateFormat = config.patterns.date || 'YYYYMMDD'; + const dateFormat = config.patterns.dateformat || 'YYYYMMDD'; const vars = { $postId: post.id,