aboutsummaryrefslogtreecommitdiffstats
path: root/README.md
blob: 2a2bebad2b42676ceaf0080c32e7658af8cf806a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# lftpq

![Build Status](https://github.com/mpolden/lftpq/workflows/ci/badge.svg)

A queue generator for [lftp](https://lftp.yar.ru).

## Usage

```
$ lftpq -h
Usage of lftpq:
  -F string
    	Format to use in dry-run mode (default "lftp")
  -c string
    	Classify string and print its local dir
  -f string
    	Path to config (default "~/.lftpqrc")
  -i	Build queues from stdin
  -l string
    	Override local dir for this run
  -n	Print queue and exit
  -p string
    	Path to lftp program (default "lftp")
  -q	Do not print output from lftp
  -t	Test and print config
```

## Example config

```json
{
  "Default": {
    "GetCmd": "mirror"
  },
  "LocalDirs": [
    {
      "Name": "my-tv-dir",
      "Parser": "show",
      "Dir": "/tmp/{{ .Name }}/S{{ .Season }}/"
    },
  ],
  "Sites": [
    {
      "Name": "foo",
      "Dirs": [
        "/dir1",
        "/dir2"
      ],
      "LocalDir": "my-tv-dir",
      "SkipSymlinks": true,
      "SkipExisting": true,
      "SkipFiles": true,
      "Merge": true,
      "Priorities": [
        "^important",
        "^less\\.important"
      ],
      "Parser": "show",
      "MaxAge": "24h",
      "Patterns": [
        "^Dir1",
        "^Dir2"
      ],
      "Filters": [
        "(?i)incomplete"
      ],
      "Replacements": [
        {
          "Pattern": "\\.The\\.",
          "Replacement": ".the."
        }
      ],
      "PostCommand": "/usr/local/bin/post-process.sh"
    }
  ]
}
```

## Configuration options

`Default` holds the default site configuration, which will apply to all sites.
All options can be overridden per site. This is useful when you want to apply
the same options to multiple sites.

`LocalDirs` defines one or more local directory configurations.

`Name` is the name of this local directory configuration. This is used to bind a
site to a local directory.

`Parser` sets the parser to use when parsing media. Valid values are `show`,
`movie` or empty string (disable parsing).

`Dir` is the local directory where files should be downloaded. This can be a
template. When the `show` parser is used, the following template variables are
available:

Variable  | Description            | Type   | Example
--------- | -----------------------|------- | -------
`Name`    | Name of the show       | string | `The.Wire`
`Season`  | Show season            | int    | `1`
`Episode` | Show episode           | int    | `5`
`Release` | Release/directory name | string | `The.Wire.S01E05.720p.BluRay.X264`

When using the `movie` parser, the following variables are available:

Variable  | Description            | Type   | Example
--------- | -----------------------| -------| -------
`Name`    | Movie name             | string | `Apocalypse.Now`
`Year`    | Production year        | int    | `1979`
`Release` | Release/directory name | string | `Apocalypse.Now.1979.720p.BluRay.X264`

All variables can be formatted with `Sprintf`. For example `/mydir/{{ .Name
}}/S{{ .Season | Sprintf "%02" }}/` would format the season using two decimals
and would result in `/mydir/The.Wire/S01/`.

`Replacements` is a list of replacements that can be used to replace
misspellings or incorrect casing in media titles. `Pattern` is a regular
expression and `Replacement` is the replacement string. If multiple replacements
are given, they will be processed in the order they are listed.

`Sites` holds the configuration for each individual site.

`Name` is the bookmark or URL of the site. This is passed to the `open` command in lftp.

`GetCmd` sets the lftp command to use when downloading, this can also be an
alias. For example: If you have `alias m "mirror --only-missing"` in your
`.lftprc`, then `GetCmd` can be set to `m`.

`Dirs` is a list of remote directories from which the queue is generated.

`LocalDir` is the name of the local directory configuration to use from
`LocalDirs`.

`SkipSymlinks` determines whether to ignore symlinks when generating the queue.

`SkipExisting` determines whether to ignore non-empty directories that already
exist in `LocalDir`.

`SkipFiles` determines whether to ignore files when generating the queue. When
`true` only directories will be included in the queue. Files inside a directory
will still be transferred.

`Merge` determines whether files/directories that exist locally should be merged
into the queue before deduplication takes place. This information can then be
used when doing post-processing of the queue.

For example: Candidate `A` is transferred during session `1` and candidate `B`
is transferred during session `2`. If candidate `B` has a higher priority than
`A`, so that `A` is considered a duplicate of `B`, `B` will be transferred
during session `2`. This means that both candidates exist on disk after session
`2` ends. If `Merge` is `true`, the queue passed to `PostCommand` will contain
candidate `A` along with its duplication status (the fields `Merged` and
`Duplicate` will both be `true`).

`Priorities` is a list of patterns used to deduplicate directories which contain
the same media (e.g. same show, season and episode, but different release).
Directories are deduplicated based on the order of matching patterns, where the
earliest match is given the highest rank. For example, if the items
`Foo.1.important` and `Foo.1.less.important` are determined to be the same
media, then given the priorities in the example above, `Foo.1.important` would
be kept and `Foo.2.less.important` would be removed from the queue.

`MaxAge` sets the maximum age of directories to consider for the queue. If a
directory is older than `MaxAge`, it will always be excluded. `MaxAge` has
precedence over `Patterns` and `Filters`.

`Patterns` is a list of patterns (regular expressions) used when including
directories. A directory matching any of these patterns will be included in the
queue.

`Filters` is a list of patterns used when excluding directories. A directory
matching any of these patterns will be excluded from the queue. `Filters` has
precedence over `Patterns`.

`PostCommand` specifies a command for post-processing of the queue. The queue
will be passed to the command on stdin, in JSON format. Leave empty to disable.