Skip to content

Commit

Permalink
Merge pull request #185 from anarion80/add_pinchflat
Browse files Browse the repository at this point in the history
✨ Add Pinchflat
  • Loading branch information
anarion80 authored Aug 28, 2024
2 parents e33246d + 9b58b42 commit 009d790
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Photoprism](https://www.photoprism.app/) - An AI-Powered Photos App for the Decentralized Web
* [PhotoStructure](https://photostructure.com/) - Your new home for all your photos & videos
* [PhpMyAdmin](https://www.phpmyadmin.net/) - a tool intended to handle the administration of MySQL over the Web
* [Pinchflat](https://github.com/kieraneglin/pinchflat/) - Your next YouTube media manager
* [Piwigo](https://piwigo.org/) - Photo Gallery Software
* [Plex](https://www.plex.tv/) - Plex Media Server
* [Plex Autoscan](https://github.com/Cloudbox/autoscan) - automatic Plex library updates
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,10 @@
tags:
- phpmyadmin

- role: pinchflat
tags:
- pinchflat

- role: piwigo
tags:
- piwigo
Expand Down
33 changes: 33 additions & 0 deletions roles/pinchflat/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
pinchflat_enabled: false
pinchflat_available_externally: false

# directories
pinchflat_data_directory: "{{ docker_home }}/pinchflat"

# network
pinchflat_port: "8175"
pinchflat_hostname: "pinchflat"

# specs
pinchflat_memory: 1g

# docker
pinchflat_container_name: pinchflat
pinchflat_image_name: "ghcr.io/kieraneglin/pinchflat"
pinchflat_image_version: latest
pinchflat_user_id: "1000"
pinchflat_group_id: "1000"

# pinchflat
pinchflat_downloads_directory: "{{ downloads_root }}/pinchflat"
pinchflat_timezone: "{{ ansible_nas_timezone }}"
pinchflat_log_level: "debug"
pinchflat_basic_auth_username: "pinchflat"
pinchflat_basic_auth_password: "pinchflat"
pinchflat_expose_feed_endpoints: "false"
pinchflat_enable_ipv6: "false"
pinchflat_journal_mode: "wal"
pinchflat_tz_data_dir: "/etc/elixir_tzdata_data"
pinchflat_base_route_path: "/"
pinchflat_yt_dlp_worker_concurrency: "2"
18 changes: 18 additions & 0 deletions roles/pinchflat/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
provisioner:
inventory:
group_vars:
all:
pinchflat_enabled: true
pinchflat_downloads_directory: "/tmp/downloads"
pinchflat_data_directory: "/tmp"
platforms:
- name: instance
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp
cgroupns_mode: host
privileged: true
pre_build_image: true
10 changes: 10 additions & 0 deletions roles/pinchflat/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
pinchflat_enabled: false
19 changes: 19 additions & 0 deletions roles/pinchflat/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get pinchflat container state
community.docker.docker_container:
name: "{{ pinchflat_container_name }}"
register: result

- name: Check if pinchflat containers are running
ansible.builtin.assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
19 changes: 19 additions & 0 deletions roles/pinchflat/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove pinchflat
community.docker.docker_container:
name: "{{ pinchflat_container_name }}"
state: absent
register: result

- name: Check if pinchflat is stopped
ansible.builtin.assert:
that:
- not result.changed
1 change: 1 addition & 0 deletions roles/pinchflat/requirements.yml
63 changes: 63 additions & 0 deletions roles/pinchflat/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
- name: Start Pocket-ID
block:
- name: Create Pocket-ID Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ pinchflat_user_id }}"
group: "{{ pinchflat_group_id }}"
with_items:
- "{{ pinchflat_data_directory }}"
- "{{ pinchflat_data_directory }}/config"

- name: Change ownership of downloads directory
ansible.builtin.file:
path: "{{ pinchflat_downloads_directory }}"
state: directory
owner: "{{ pinchflat_user_id }}"
group: "{{ pinchflat_group_id }}"
recurse: yes

- name: Create Pocket-ID Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ pinchflat_container_name }}"
image: "{{ pinchflat_image_name }}:{{ pinchflat_image_version }}"
user: "{{ pinchflat_user_id }}:{{ pinchflat_group_id }}"
pull: true
volumes:
- "{{ pinchflat_data_directory }}/config:/config"
- "{{ pinchflat_downloads_directory }}:/downloads:rw"
ports:
- "{{ pinchflat_port }}:8945"
env:
TZ: "{{ pinchflat_timezone }}"
LOG_LEVEL: "{{ pinchflat_log_level }}"
BASIC_AUTH_USERNAME: "{{ pinchflat_basic_auth_username }}"
BASIC_AUTH_PASSWORD: "{{ pinchflat_basic_auth_password }}"
EXPOSE_FEED_ENDPOINTS: "{{ pinchflat_expose_feed_endpoints }}"
ENABLE_IPV6: "{{ pinchflat_enable_ipv6 }}"
JOURNAL_MODE: "{{ pinchflat_journal_mode }}"
TZ_DATA_DIR: "{{ pinchflat_tz_data_dir }}"
BASE_ROUTE_PATH: "{{ pinchflat_base_route_path }}"
YT_DLP_WORKER_CONCURRENCY: "{{ pinchflat_yt_dlp_worker_concurrency }}"
restart_policy: unless-stopped
memory: "{{ pinchflat_memory }}"
tty: true
labels:
traefik.enable: "{{ pinchflat_available_externally | string }}"
traefik.http.routers.pinchflat.rule: "Host(`{{ pinchflat_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.pinchflat.tls.certresolver: "letsencrypt"
traefik.http.routers.pinchflat.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.pinchflat.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.pinchflat.loadbalancer.server.port: "8945"
when: pinchflat_enabled is true

- name: Stop Pocket-ID
block:
- name: Stop Pocket-ID
community.docker.docker_container:
name: "{{ pinchflat_container_name }}"
state: absent
when: pinchflat_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/download-tools/pinchflat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Pinchflat"
description: "Your next YouTube media manager"
---

Homepage: [https://github.com/kieraneglin/pinchflat](https://github.com/kieraneglin/pinchflat)

Pinchflat is a self-hosted app for downloading YouTube content built using yt-dlp. It's designed to be lightweight, self-contained, and easy to use. You set up rules for how to download content from YouTube channels or playlists and it'll do the rest, periodically checking for new content. It's perfect for people who want to download content for use in with a media center app (Plex, Jellyfin, Kodi) or for those who want to archive media!

## Usage

Set `pinchflat_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Pinchflat web interface can be found at [http://ansible_nas_host_or_ip:8175](http://ansible_nas_host_or_ip:8175).

0 comments on commit 009d790

Please sign in to comment.