diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..157d764 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 00df356..2a91889 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ records/ docker-compose.yml __pycache__/ +aarlo/ +.venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ed6ebfb..ca7cc90 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-slim +FROM python:3.12-slim # Create the working directories RUN mkdir /arlo-downloader /records @@ -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}" \ ] diff --git a/README.md b/README.md index 23da1cf..fac1cdd 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -83,6 +83,7 @@ version: "2.1" services: arlo-downloader: image: diaznet/arlo-downloader:latest + build: . container_name: arlo-downloader:latest environment: - ARLO_USERNAME= @@ -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 @@ -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. diff --git a/arlo-downloader.py b/arlo-downloader.py index 57f7513..5d6550e 100644 --- a/arlo-downloader.py +++ b/arlo-downloader.py @@ -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'), @@ -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)) diff --git a/config.py b/config.py index c86ff8d..1c6e071 100644 --- a/config.py +++ b/config.py @@ -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, diff --git a/requirements.txt b/requirements.txt index 9a2e47e..690a289 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -pyaarlo==0.7.1.2 +pyaarlo==0.8.0.11 +python-slugify>=7.0.0 \ No newline at end of file diff --git a/test-windows.bat b/test-windows.bat new file mode 100644 index 0000000..16777ac --- /dev/null +++ b/test-windows.bat @@ -0,0 +1 @@ +python arlo-downloader.py -m ".\records\${Y}\${m}\${F}T${t}_${N}_${SN}"