Skip to content

Commit

Permalink
Refresh pyaarlo library and make necessary changes to handle new version
Browse files Browse the repository at this point in the history
Refresh pyaarlo library and make necessary changes to handle new version
  • Loading branch information
diaznet authored Nov 10, 2024
2 parents 6b9b5af + 47f1a56 commit 41fe765
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 22 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Build and Push docker image on Dockerhub

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build_push:
runs-on: ubuntu-latest

steps:

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
diaznet/arlo-downloader
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Checkout
- uses: actions/checkout@v4

# Build and push Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

# Log-out of Docker Hub
- name: Log out of Docker Hub
run: docker logout
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
records/
docker-compose.yml
__pycache__/
aarlo/
.venv
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.12-slim

# Create the working directories
RUN mkdir /arlo-downloader /records
Expand All @@ -18,14 +18,14 @@ RUN pip install --upgrade pip && pip install -r requirements.txt
ENTRYPOINT ["/arlo-downloader/entrypoint.sh"]

# Start the arlo-downloader.py script
CMD [ \
"python", "/arlo-downloader/arlo-downloader.py", \
"--save-media-to", "'/records/${Y}/${m}/${F}T${t}_${N}_${SN}'", \
"--tfa-type", "${TFA_TYPE:=PUSH}", \
"--tfa-source", "${TFA_SOURCE:=push}", \
"--tfa-retries", "${TFA_RETRIES:=10}", \
"--tfa-delay", "${TFA_DELAY:=5}", \
"--tfa-host", "${TFA_HOST:=:=_invalid}", \
"--tfa-username", "{$TFA_USERNAME:=_invalid}", \
"--tfa-password", "{$TFA_PASSWORD:=_invalid}" \
CMD [ \
"python", "/arlo-downloader/arlo-downloader.py", \
"--save-media-to", "'/records/${Y}/${m}/${F}T${t}_${N}_${SN}'",\
"--tfa-type", "${TFA_TYPE:=PUSH}", \
"--tfa-source", "${TFA_SOURCE:=push}", \
"--tfa-retries", "${TFA_RETRIES:=10}", \
"--tfa-delay", "${TFA_DELAY:=5}", \
"--tfa-host", "${TFA_HOST:=_invalid}", \
"--tfa-username", "${TFA_USERNAME:=_invalid}", \
"--tfa-password", "${TFA_PASSWORD:=_invalid}" \
]
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This way your main account is not used by Arlo Downloader and access can be revo

| Parameter | Function | Default |
| :----: | --- | --- |
| -e `TFA_TYPE` | Arlo TFA type. Currently only supports PUSH,EMAIL | PUSH |
| -e `TFA_TYPE` | Arlo TFA type. Currently only supports push,email | push |
| -e `TFA_SOURCE` | Arlo TFA type. Currently only supports push,imap | push |
| -e `TFA_RETRIES` | Arlo TFA retries. | 10 |
| -e `TFA_DELAY` | Arlo TFA Delay between each check | 5 |
Expand Down Expand Up @@ -83,6 +83,7 @@ version: "2.1"
services:
arlo-downloader:
image: diaznet/arlo-downloader:latest
build: .
container_name: arlo-downloader:latest
environment:
- ARLO_USERNAME=<api_username>
Expand All @@ -92,10 +93,12 @@ services:
restart: unless-stopped
```
Start the docker containers with docker-compose up. To run the containers in the background add the -d flag:
Note: you are also going to need the various TFA_* environmetn variables if yu have 2FA activated on your account.
Build and start the docker containers with docker-compose up. To run the containers in the background add the -d flag:
```bash
docker-compose up -d
docker-compose up --build -d
```

### docker cli
Expand Down Expand Up @@ -158,8 +161,7 @@ Any damage cannot be related back to the author.

# Todo's
- Ability to customize video filenames / filepath
- ~~Ability to enable DEBUG with docker compose / run~~

# Credits
Author: Jeremy Diaz
This container uses [pyaarlo](https://github.com/twrecked/pyaarlo) 0.7.1.2 library.
This container uses [pyaarlo](https://github.com/twrecked/pyaarlo) 0.8 library.
7 changes: 3 additions & 4 deletions arlo-downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def attribute_changed(device, attr, value):
# Print configuration in DEBUG
for confItem in Config.dump_config().items(): logging.debug(confItem)
# log in
# add `verbose_debug=True` to enable even more debugging
# add `dump=True` to enable event stream packet dumps
arlo = pyaarlo.PyArlo(username=USERNAME, password=PASSWORD,
tfa_type=Config.config('tfa_type'),
Expand All @@ -88,11 +87,11 @@ def attribute_changed(device, attr, value):
tfa_host=Config.config('tfa_host'),
tfa_username=Config.config('tfa_username'),
tfa_password=Config.config('tfa_password'),
synchronous_mode=True,
save_state=False,
synchronous_mode=False,
mode_api='v2',
save_state=True,
dump=False,
storage_dir='aarlo',
verbose_debug=True,
save_media_to=Config.config('save_media_to'))
if not arlo.is_connected:
logging.info("failed to login({})".format(arlo._last_error))
Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Config:
__conf = {
"save_media_to": os.path.dirname(os.path.realpath(__file__)) + os.path.sep + "${Y}/${m}/${F}T${t}_${N}_${SN}",
"save_media_to": os.path.dirname(os.path.realpath(__file__)) + os.path.sep + "${Y}" + os.path.sep + "${m}" + os.path.sep + "${F}T${t}_${N}_${SN}",
"tfa_type": "PUSH",
"tfa_source": "push",
"tfa_retries": 10,
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyaarlo==0.7.1.2
pyaarlo==0.8.0.11
python-slugify>=7.0.0
1 change: 1 addition & 0 deletions test-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python arlo-downloader.py -m ".\records\${Y}\${m}\${F}T${t}_${N}_${SN}"

0 comments on commit 41fe765

Please sign in to comment.