aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 2574d49e13a1be3bd257d8185d29c91a5fc2aae6 (plain)
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
# Reddit Nextcloud importer

A process to import images and videos from saved post on reddit to a instance of
Nextcloud.

## apk

This project is available as an apk at [apkbuilds](https://git.sr.ht/~gabrielgio/apkbuilds).

# Environment variables

* `CLIENT_ID` and `CLIENT_SECRET`: crendentials needed to access Reddit's API.
  To get those info you'd need:
  * Go to [authorized application page](https://www.reddit.com/prefs/apps)
  * Click on `Create another app...` button at the bottom of the page.
  * Input the information and pick `script`.
  * You can use `http://localhost:8080` on `redirect uri` field as you won't
  need it.
  
* `REDDIT_USERNAME` and `REDDIT_PASSWORD`: user credential to access Reddit's
  API. Because you chose `script` that user need to be listed as a developer in
  the application page. To add a new user as a developer go to [authorized
  application page](https://www.reddit.com/prefs/apps) and click on the `edit`
  button on the application you just created. It will open a field `add
  developer`.

* `NEXTCLOUD_HOST`: the host domain a port for the nextcloud instance.

* `NEXTCLOUD_USERNAME` and `NEXTCLOUD_PASSWORD`: user credential for the
  nextcloud instance.
  
* `NEXTCLOUD_PATH`: root folder for where all the images will be saved.

* `FROM_BEGINNING`: it will download all the files since the first available
  saved post.
  
* `LOG_LEVEL`: it will set the log level:
  * info
  * error

# Running as docker container

Since I'm not distributing this project as docker anymore feel free to build it
yourself. I have it packed for alpine already, you can start with the following
dockerfile

```dockerfile
FROM alpine:3.16

RUN apk add curl

RUN echo "https://artifacts.gabrielgio.me/repo/v3.16/" >> /etc/apk/repositories
RUN curl https://artifacts.gabrielgio.me/repo/mail%40gabrielgio.me-62ddc4dc.rsa.pub \
    -o  /etc/apk/keys/mail@gabrielgio.me-62ddc4dc.rsa.pub

RUN apk add reddit-nextcloud-importer

ENTRYPOINT reddit-nextcloud-importer
```

then run:

```shell
docker build -t reddit-nextcloud-importer .
```

To run as docker you need to pass all the environment variables listed above:

```BASH
docker run -d --rm \
  -e CLIENT_ID=$CLIENT_ID \
  -e CLIENT_SECRET=$CLIENT_SECRET \
  -e REDDIT_USERNAME=$REDDIT_USERNAME \
  -e REDDIT_PASSWORD=$REDDIT_PASSWORD \
  -e NEXTCLOUD_HOST=$REDDIT_HOST \
  -e NEXTCLOUD_USERNAME=$NEXTCLOUD_USERNAME \
  -e NEXTCLOUD_PASSWORD=$NEXTCLOUD_PASSWORD \
  -e NEXTCLOUD_PATH=$NEXTCLOUD_PATH \
  reddit-nextcloud-importer:latest
```