From cd6b94f868124dd799f489dd42288a507235e015 Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Fri, 20 Oct 2023 18:40:13 +0200 Subject: [PATCH] prepare for release --- README.md | 129 ++++++++++++++++++++++++++++++++++++ config.yml.example | 34 +++++----- internal/dav/response.go | 2 +- internal/torrent/manager.go | 9 +++ 4 files changed, 157 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b30e393..8b36ba5 100644 --- a/README.md +++ b/README.md @@ -1 +1,130 @@ # zurg + +## Building + +```bash +docker build -t debridmediamanager/zurg:latest . +``` + +This builds zurg + +## config.yml + +You need a `config.yml` created before you use zurg + +```yaml +# Zurg configuration version +zurg: v1 + +token: YOUR_TOKEN_HERE +port: 9999 +concurrent_workers: 10 +check_for_changes_every_secs: 15 +info_cache_time_hours: 12 + +# List of directory definitions and their filtering rules +directories: + + # Configuration for TV shows + shows: + group: media # directories on different groups have duplicates of the same torrent + filters: + - regex: /season[\s\.]?\d/i # Capture torrent names with the term 'season' in any case + - regex: /Saison[\s\.]?\d/i # For non-English namings + - regex: /stage[\s\.]?\d/i + - regex: /s\d\d/i # Capture common season notations like S01, S02, etc. + - contains: complete + - contains: seasons + - id: ATUWVRF53X5DA + - contains_strict: PM19 + - contains_strict: Detective Conan Remastered + - contains_strict: Goblin Slayer + + # Configuration for movies + movies: + group: media # because movies and shows are in the same group, and shows come first before movies, all torrents that doesn't fall into shows will fall into movies + filters: + - regex: /.*/ # you cannot leave a directory without filters because it will not have any torrents in it + + # Configuration for Dolby Vision content + "hd movies": + group: another + filters: + - regex: /\b2160|\b4k|\buhd|\bdovi|\bdolby.?vision|\bdv|\bremux/i # Matches abbreviations of 'dolby vision' + + "low quality": + group: another + filters: + - regex: /.*/ + + # Configuration for children's content + kids: + group: kids + filters: + - contains: xxx # Ensures adult content is excluded + - id: XFPQ5UCMUVAEG # Specific inclusion by torrent ID + - id: VDRPYNRPQHEXC + - id: YELNX3XR5XJQM + +``` + + +## Running + +### Standalone webdav server + +```bash +docker run -v ./config.yml:/app/config.yml -v zurgdata:/app/data -p 9999:9999 debridmediamanager/zurg:latest +``` + +- Runs zurg on port 9999 on your localhost +- Make sure you have config.yml on the current directory +- It creates a `zurgdata` volume for the data files + +### with rclone + +```yaml +version: '3.8' + +services: + zurg: + image: debridmediamanager/zurg:latest + restart: unless-stopped + ports: + - 9999:9999 + volumes: + - ./config.yml:/app/config.yml + - zurgdata:/app/data + + rclone: + image: rclone/rclone:latest + restart: unless-stopped + environment: + TZ: Europe/Berlin + PUID: 1000 + PGID: 1000 + volumes: + - ./media:/data + - ./rclone.conf:/config/rclone/rclone.conf + privileged: true + cap_add: + - SYS_ADMIN + devices: + - /dev/fuse + command: "mount zurg: /data --allow-other --allow-non-empty --uid 1000 --gid 1000 --dir-cache-time 1s --poll-interval 1s --read-only --log-level INFO" + +volumes: + zurgdata: +``` + +You will need to create a `media` directory to make the rclone mount work. + +Together with this `docker-compose.yml` you will need this `rclone.conf` as well on the same directory. + +``` +[zurg] +type = webdav +url = http://zurg:9999 +vendor = other + +``` diff --git a/config.yml.example b/config.yml.example index efe3b21..55ac8cd 100644 --- a/config.yml.example +++ b/config.yml.example @@ -14,9 +14,16 @@ directories: shows: group: media # directories on different groups have duplicates of the same torrent filters: - - regex: /season/i # Capture torrent names with the term 'season' in any case - - regex: /Saison/i # For non-English namings + - regex: /season[\s\.]?\d/i # Capture torrent names with the term 'season' in any case + - regex: /Saison[\s\.]?\d/i # For non-English namings + - regex: /stage[\s\.]?\d/i - regex: /s\d\d/i # Capture common season notations like S01, S02, etc. + - contains: complete + - contains: seasons + - id: ATUWVRF53X5DA + - contains_strict: PM19 + - contains_strict: Detective Conan Remastered + - contains_strict: Goblin Slayer # Configuration for movies movies: @@ -24,27 +31,22 @@ directories: filters: - regex: /.*/ # you cannot leave a directory without filters because it will not have any torrents in it - # Configuration for remuxes - remuxes: - group: def - filters: - - contains: remux # Specifically target remuxed content - # Configuration for Dolby Vision content - "dolby vision": - group: random + "hd movies": + group: another filters: - - and: - - regex: /\bdovi\b/i # Matches abbreviations of 'dolby vision' - - contains: 4k # you can be quite greedy here, dolby vision + 4k! + - regex: /\b2160|\b4k|\buhd|\bdovi|\bdolby.?vision|\bdv|\bremux/i # Matches abbreviations of 'dolby vision' + + "low quality": + group: another + filters: + - regex: /.*/ # Configuration for children's content kids: group: kids filters: - - or: # you can also group conditions with 'or' which is useful especially inside 'and' conditions - - not_contains: xxx # Ensures adult content is excluded - - not_contains_strict: trailer # strict vs non-strict is just about case sensitivity; this ensures trailers aren't added + - contains: xxx # Ensures adult content is excluded - id: XFPQ5UCMUVAEG # Specific inclusion by torrent ID - id: VDRPYNRPQHEXC - id: YELNX3XR5XJQM diff --git a/internal/dav/response.go b/internal/dav/response.go index 0a1c660..67aad87 100644 --- a/internal/dav/response.go +++ b/internal/dav/response.go @@ -53,7 +53,7 @@ func createSingleTorrentResponse(basePath string, torrents []torrent.Torrent, t // TODO: trigger a re-add for the file // It is selected but no link is available // I think this is handled on the manager side so we just need to refresh - t.RefreshInfo(torrent.ID) + // t.RefreshInfo(torrent.ID) continue } filename := filepath.Base(file.Path) diff --git a/internal/torrent/manager.go b/internal/torrent/manager.go index 7f5d1ab..4584a6d 100644 --- a/internal/torrent/manager.go +++ b/internal/torrent/manager.go @@ -297,6 +297,15 @@ func (t *TorrentManager) writeToFile(torrentID string, torrent *Torrent) { func (t *TorrentManager) readFromFile(torrentID string) *Torrent { filePath := fmt.Sprintf("data/%s.bin", torrentID) + fileInfo, err := os.Stat(filePath) + if err != nil { + return nil + } + + if time.Since(fileInfo.ModTime()) > time.Duration(t.config.GetCacheTimeHours())*time.Hour { + return nil + } + file, err := os.Open(filePath) if err != nil { return nil