Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Archmonger committed Jun 29, 2024
2 parents 87da4f0 + 564253a commit 09aa292
Show file tree
Hide file tree
Showing 17 changed files with 321 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
python-version: [3.11]

steps:
- uses: actions/checkout@v2
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/publish-develop-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Develop Docker Image

on:
push:
branches:
- develop

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: archmonger/conreq:develop
24 changes: 24 additions & 0 deletions .github/workflows/publish-latest-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish Latest Docker Image

on:
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: archmonger/conreq:latest
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ data/
# Temp files
*.tmp

# Docker config folder
config/

# Backup files #
*.bak
*_bak/
Expand Down Expand Up @@ -118,4 +121,4 @@ GitHub.sublime-settings
%SystemDrive%

# Mac file system
.DS_Store/
.DS_Store/
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
"irongeek.vscode-env",
"eamodio.gitlens",
"github.vscode-pull-request-github",
"knisterpeter.vscode-github",
"wholroyd.jinja",
"esbenp.prettier-vscode",
"ms-python.vscode-pylance",
"ms-python.python",
"mrmlnc.vscode-autoprefixer",
"gruntfuggly.todo-tree"
]
}
}
14 changes: 3 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
{
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintUseMinimalCheckers": false,
"python.linting.pylintArgs": [],
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "off",
"python.formatting.provider": "black",
"python.sortImports.args": [
"--src=${workspaceFolder}"
],
"terminal.integrated.scrollback": 20000,
"terminal.integrated.scrollback": 2000,
"git.autofetch": true,
"prettier.tabWidth": 4,
"prettier.useTabs": true,
Expand All @@ -32,6 +24,6 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.defaultFormatter": "ms-python.python"
"editor.defaultFormatter": "charliermarsh.ruff"
},
}
}
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# FROM ghcr.io/linuxserver/baseimage-alpine:3.20
FROM python:3.11.9-alpine3.20

ENV DATA_DIR=/config DEBUG=False

COPY ./manage.py /app/manage.py
COPY ./VERSION /app/VERSION
COPY ./LICENSE /app/LICENSE
COPY ./conreq/ /app/conreq/
COPY ./requirements/ /app/conreq/requirements/

RUN \
echo "**** Install build dependencies ****" \
&& \
apk add --no-cache --virtual=build-dependencies \
bsd-compat-headers \
build-base \
cargo \
curl \
g++ \
gcc \
git \
jq \
libev-dev \
libffi-dev \
openssl-dev \
&& \
echo "**** Install Linux packages ****" \
&& \
apk add --no-cache \
freetype-dev \
fribidi-dev \
harfbuzz-dev \
jpeg-dev \
lcms2-dev \
openjpeg-dev \
tcl-dev \
tiff-dev \
tk-dev \
zlib-dev \
&& \
echo "**** Install Python dependencies ****" \
&& \
pip3 install --no-cache-dir -U -r /app/conreq/requirements/main.txt \
&& \
echo "**** Cleanup ****" \
&& \
apk del --purge \
build-dependencies \
&& \
rm -rf \
/root/.cache \
/root/.cargo \
/tmp/*

EXPOSE 8000

WORKDIR /app/
CMD ["sh", "-c", "python3 manage.py run_conreq --uid ${PUID:=1000} --gid ${PGID:=1000}"]
30 changes: 13 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Conreq Beta

[![Docker Pulls](https://img.shields.io/docker/pulls/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
[![Docker Stars](https://img.shields.io/docker/stars/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
[![Docker Hub](https://img.shields.io/badge/Open%20On-DockerHub-blue?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
[![Discord](https://img.shields.io/discord/440067432552595457?style=flat-square&label=Discord&logo=discord)](https://discord.gg/gQhGZzEjmX "Chat with the community and get realtime support!")
[![Docker Pulls](https://img.shields.io/docker/pulls/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq) [![Docker Stars](https://img.shields.io/docker/stars/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq) [![Docker Hub](https://img.shields.io/badge/Open%20On-DockerHub-blue?style=flat-square)](https://hub.docker.com/r/roxedus/conreq) [![Discord](https://img.shields.io/discord/440067432552595457?style=flat-square&label=Discord&logo=discord)](https://discord.gg/gQhGZzEjmX "Chat with the community and get realtime support!")

## Notice - July 11th, 2022

Expand Down Expand Up @@ -45,7 +42,6 @@ MYSQL_CONFIG_FILE = /config/mysql.cnf # default: None
# Security
SSL_SECURITY = True # default: False (True enables advanced SSL security features)
PWNED_VALIDATOR = False # default: True (False disables checking for compromised passwords)
X_FRAME_OPTIONS = SAMEORIGIN # default: DENY (False disables X-Frame-Options)
ALLOWED_HOST = 192.168.0.199 # default: * (Comma separated list. Asterisk allows all hosts.)
TRUSTED_ORIGINS = https://*.example.com # default: None (Comma separated list. Required to be set if using https.)
DEBUG = True # default: False (Only enable this during development or testing.)
Expand All @@ -61,25 +57,25 @@ EMAIL_HOST_PASSWORD = dogmemes123 # default: None
# Screenshots

| ![Login screen](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_discover.png?raw=true) | ![Discover tab](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_more_info.png?raw=true) |
| :------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------: |
| Discover (Desktop) | More Info (Desktop) |
| :-: | :-: |
| Discover (Desktop) | More Info (Desktop) |

| ![More Info Tab](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_modal_episode_selection.png?raw=true) | ![Content Preview Modal](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_modal_filter.png?raw=true) |
| :----------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |
| Episode Selection Modal (Desktop) | Filter Modal (Desktop) |
| :-: | :-: |
| Episode Selection Modal (Desktop) | Filter Modal (Desktop) |

| ![Discover Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_modal_preview.png?raw=true) | ![More Info Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/desktop_sign_in.png?raw=true) |
| :------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: |
| Preview Modal (Desktop) | Sign In (Desktop) |
| :-: | :-: |
| Preview Modal (Desktop) | Sign In (Desktop) |

| ![Discover Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_discover.png?raw=true) | ![More Info Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_more_info.png?raw=true) |
| :------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: |
| Discover (Mobile) | More Info (Mobile) |
| :-: | :-: |
| Discover (Mobile) | More Info (Mobile) |

| ![Discover Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_modal_episode_selection.png?raw=true) | ![More Info Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_modal_filter.png?raw=true) |
| :---------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------: |
| Episode Selection Modal (Mobile) | Filter Modal (Mobile) |
| :-: | :-: |
| Episode Selection Modal (Mobile) | Filter Modal (Mobile) |

| ![Discover Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_registration.png?raw=true) | ![More Info Tab Mobile](https://github.com/Archmonger/Conreq/blob/main/misc/screenshots/mobile_sign_in.png?raw=true) |
| :----------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------: |
| Registration (Mobile) | Sign In (Mobile) |
| :-: | :-: |
| Registration (Mobile) | Sign In (Mobile) |
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.20.54
0.21.0
106 changes: 33 additions & 73 deletions conreq/core/arrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,83 +23,43 @@ def _set_content_attributes(content_type, content_source, results):
results["content_source"] = content_source

@staticmethod
def _check_availability(content):
def _check_availability(content: dict):
"""Checks the availability of one item. For use within check_availability()"""
# TODO: Rewrite this
#####################
### "Unavailable" ###
#####################
# Check if an individual movie or episode does not exist (Sonarr and Radarr)
try:
if not content["hasFile"]:
content["availability"] = "Unavailable"
return content
except Exception:
pass
statistics: dict = content.get("statistics", {})
percent_available: int | None = statistics.get("percentOfEpisodes")
grabbed: bool | None = statistics.get("grabbed")

# Check if a season or series is completely unavailable (Sonarr)
try:
if content["episodeFileCount"] == 0:
content["availability"] = "Unavailable"
return content
except Exception:
pass
##### "Unavailable" #####
# Sonarr/Radarr: Check if an individual movie or episode does not exist
if "hasFile" in content and not content["hasFile"]:
content["availability"] = "Unavailable"
return content
# Sonarr: Check if a season or series is completely unavailable
if statistics and percent_available == 0:
content["availability"] = "Unavailable"
return content

#################
### "Partial" ###
#################
# Check if season or series is partially downloaded (Sonarr)
try:
# Series
if content.__contains__("lastInfoSync"):
if (
content["episodeFileCount"] != 0
and content["episodeFileCount"] < content["episodeCount"]
):
content["availability"] = "Partial"
return content
##### "Partial" #####
# Sonarr: Check if season or series is partially downloaded
if statistics and percent_available and percent_available < 100:
content["availability"] = "Partial"
return content
# Radarr: Check if a movie is being downloaded.
if grabbed is True and statistics and statistics.get("movieFileCount") == 0:
content["availability"] = "Partial"
return content

# Season
elif (
content["episodeFileCount"] != 0
and content["totalEpisodeCount"] > content["episodeCount"]
):
content["availability"] = "Partial"
return content
except Exception:
pass

###################
### "Available" ###
###################
# Check if a season is fully downloaded (Sonarr)
try:
# Series
if content.__contains__("lastInfoSync"):
if (
content["episodeFileCount"] != 0
and content["episodeFileCount"] >= content["episodeCount"]
):
content["availability"] = "Available"
return content

# Season
elif (
content["episodeFileCount"] != 0
and content["totalEpisodeCount"] <= content["episodeCount"]
):
content["availability"] = "Available"
return content
except Exception:
pass

# Check if an individual movie or individual episode exists (Sonarr & Radarr)
try:
if content["hasFile"]:
content["availability"] = "Available"
return content
except Exception:
pass
##### "Available" #####
# Sonarr: Check if a season or series is fully downloaded
if statistics and percent_available == 100:
content["availability"] = "Available"
return content
# Sonarr/Radarr: Check if an individual movie or individual episode exists
if "hasFile" in content and content["hasFile"]:
content["availability"] = "Available"
return content

##### "Unknown" #####
# This should never be reached except with Sonarr/Raddarr API changes
content["availability"] = "Unknown"
return content
5 changes: 4 additions & 1 deletion conreq/core/arrs/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from time import sleep

from conreq.core.arrs.sonarr import SonarrManager


def wait_for_series_info(tvdb_id, max_retries=10):
def wait_for_series_info(tvdb_id, max_retries=15):
"""Keeps attempting to fetch a series from Sonarr until it becomes available"""
sonarr_manager = SonarrManager()
series = sonarr_manager.get(
Expand All @@ -16,4 +18,5 @@ def wait_for_series_info(tvdb_id, max_retries=10):
series = sonarr_manager.get(
tvdb_id=tvdb_id, obtain_season_info=True, force_update_cache=True
)
sleep(0.25)
return series
Loading

0 comments on commit 09aa292

Please sign in to comment.