Skip to content

Commit 09aa292

Browse files
committed
Merge branch 'develop'
2 parents 87da4f0 + 564253a commit 09aa292

17 files changed

+321
-179
lines changed

.github/workflows/django.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
max-parallel: 4
1414
matrix:
15-
python-version: [3.9]
15+
python-version: [3.11]
1616

1717
steps:
1818
- uses: actions/checkout@v2
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish Develop Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Set up QEMU
13+
uses: docker/setup-qemu-action@v3
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
- name: Login to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
- name: Build and push
22+
uses: docker/build-push-action@v6
23+
with:
24+
push: true
25+
tags: archmonger/conreq:develop
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish Latest Docker Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Set up QEMU
12+
uses: docker/setup-qemu-action@v3
13+
- name: Set up Docker Buildx
14+
uses: docker/setup-buildx-action@v3
15+
- name: Login to Docker Hub
16+
uses: docker/login-action@v3
17+
with:
18+
username: ${{ secrets.DOCKERHUB_USERNAME }}
19+
password: ${{ secrets.DOCKERHUB_TOKEN }}
20+
- name: Build and push
21+
uses: docker/build-push-action@v6
22+
with:
23+
push: true
24+
tags: archmonger/conreq:latest

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ data/
1111
# Temp files
1212
*.tmp
1313

14+
# Docker config folder
15+
config/
16+
1417
# Backup files #
1518
*.bak
1619
*_bak/
@@ -118,4 +121,4 @@ GitHub.sublime-settings
118121
%SystemDrive%
119122

120123
# Mac file system
121-
.DS_Store/
124+
.DS_Store/

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
"irongeek.vscode-env",
44
"eamodio.gitlens",
55
"github.vscode-pull-request-github",
6-
"knisterpeter.vscode-github",
76
"wholroyd.jinja",
87
"esbenp.prettier-vscode",
98
"ms-python.vscode-pylance",
109
"ms-python.python",
1110
"mrmlnc.vscode-autoprefixer",
1211
"gruntfuggly.todo-tree"
1312
]
14-
}
13+
}

.vscode/settings.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
{
22
"editor.detectIndentation": false,
33
"editor.formatOnSave": true,
4-
"python.linting.pylintEnabled": true,
5-
"python.linting.pylintUseMinimalCheckers": false,
6-
"python.linting.pylintArgs": [],
74
"python.languageServer": "Pylance",
8-
"python.analysis.typeCheckingMode": "off",
9-
"python.formatting.provider": "black",
10-
"python.sortImports.args": [
11-
"--src=${workspaceFolder}"
12-
],
13-
"terminal.integrated.scrollback": 20000,
5+
"terminal.integrated.scrollback": 2000,
146
"git.autofetch": true,
157
"prettier.tabWidth": 4,
168
"prettier.useTabs": true,
@@ -32,6 +24,6 @@
3224
"editor.defaultFormatter": "esbenp.prettier-vscode"
3325
},
3426
"[python]": {
35-
"editor.defaultFormatter": "ms-python.python"
27+
"editor.defaultFormatter": "charliermarsh.ruff"
3628
},
37-
}
29+
}

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# FROM ghcr.io/linuxserver/baseimage-alpine:3.20
2+
FROM python:3.11.9-alpine3.20
3+
4+
ENV DATA_DIR=/config DEBUG=False
5+
6+
COPY ./manage.py /app/manage.py
7+
COPY ./VERSION /app/VERSION
8+
COPY ./LICENSE /app/LICENSE
9+
COPY ./conreq/ /app/conreq/
10+
COPY ./requirements/ /app/conreq/requirements/
11+
12+
RUN \
13+
echo "**** Install build dependencies ****" \
14+
&& \
15+
apk add --no-cache --virtual=build-dependencies \
16+
bsd-compat-headers \
17+
build-base \
18+
cargo \
19+
curl \
20+
g++ \
21+
gcc \
22+
git \
23+
jq \
24+
libev-dev \
25+
libffi-dev \
26+
openssl-dev \
27+
&& \
28+
echo "**** Install Linux packages ****" \
29+
&& \
30+
apk add --no-cache \
31+
freetype-dev \
32+
fribidi-dev \
33+
harfbuzz-dev \
34+
jpeg-dev \
35+
lcms2-dev \
36+
openjpeg-dev \
37+
tcl-dev \
38+
tiff-dev \
39+
tk-dev \
40+
zlib-dev \
41+
&& \
42+
echo "**** Install Python dependencies ****" \
43+
&& \
44+
pip3 install --no-cache-dir -U -r /app/conreq/requirements/main.txt \
45+
&& \
46+
echo "**** Cleanup ****" \
47+
&& \
48+
apk del --purge \
49+
build-dependencies \
50+
&& \
51+
rm -rf \
52+
/root/.cache \
53+
/root/.cargo \
54+
/tmp/*
55+
56+
EXPOSE 8000
57+
58+
WORKDIR /app/
59+
CMD ["sh", "-c", "python3 manage.py run_conreq --uid ${PUID:=1000} --gid ${PGID:=1000}"]

README.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Conreq Beta
22

3-
[![Docker Pulls](https://img.shields.io/docker/pulls/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
4-
[![Docker Stars](https://img.shields.io/docker/stars/roxedus/conreq?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
5-
[![Docker Hub](https://img.shields.io/badge/Open%20On-DockerHub-blue?style=flat-square)](https://hub.docker.com/r/roxedus/conreq)
6-
[![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!")
3+
[![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!")
74

85
## Notice - July 11th, 2022
96

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

6359
| ![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) |
64-
| :------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------: |
65-
| Discover (Desktop) | More Info (Desktop) |
60+
| :-: | :-: |
61+
| Discover (Desktop) | More Info (Desktop) |
6662

6763
| ![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) |
68-
| :----------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |
69-
| Episode Selection Modal (Desktop) | Filter Modal (Desktop) |
64+
| :-: | :-: |
65+
| Episode Selection Modal (Desktop) | Filter Modal (Desktop) |
7066

7167
| ![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) |
72-
| :------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: |
73-
| Preview Modal (Desktop) | Sign In (Desktop) |
68+
| :-: | :-: |
69+
| Preview Modal (Desktop) | Sign In (Desktop) |
7470

7571
| ![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) |
76-
| :------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: |
77-
| Discover (Mobile) | More Info (Mobile) |
72+
| :-: | :-: |
73+
| Discover (Mobile) | More Info (Mobile) |
7874

7975
| ![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) |
80-
| :---------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------: |
81-
| Episode Selection Modal (Mobile) | Filter Modal (Mobile) |
76+
| :-: | :-: |
77+
| Episode Selection Modal (Mobile) | Filter Modal (Mobile) |
8278

8379
| ![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) |
84-
| :----------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------: |
85-
| Registration (Mobile) | Sign In (Mobile) |
80+
| :-: | :-: |
81+
| Registration (Mobile) | Sign In (Mobile) |

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.20.54
1+
0.21.0

conreq/core/arrs/base.py

Lines changed: 33 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -23,83 +23,43 @@ def _set_content_attributes(content_type, content_source, results):
2323
results["content_source"] = content_source
2424

2525
@staticmethod
26-
def _check_availability(content):
26+
def _check_availability(content: dict):
2727
"""Checks the availability of one item. For use within check_availability()"""
28-
# TODO: Rewrite this
29-
#####################
30-
### "Unavailable" ###
31-
#####################
32-
# Check if an individual movie or episode does not exist (Sonarr and Radarr)
33-
try:
34-
if not content["hasFile"]:
35-
content["availability"] = "Unavailable"
36-
return content
37-
except Exception:
38-
pass
28+
statistics: dict = content.get("statistics", {})
29+
percent_available: int | None = statistics.get("percentOfEpisodes")
30+
grabbed: bool | None = statistics.get("grabbed")
3931

40-
# Check if a season or series is completely unavailable (Sonarr)
41-
try:
42-
if content["episodeFileCount"] == 0:
43-
content["availability"] = "Unavailable"
44-
return content
45-
except Exception:
46-
pass
32+
##### "Unavailable" #####
33+
# Sonarr/Radarr: Check if an individual movie or episode does not exist
34+
if "hasFile" in content and not content["hasFile"]:
35+
content["availability"] = "Unavailable"
36+
return content
37+
# Sonarr: Check if a season or series is completely unavailable
38+
if statistics and percent_available == 0:
39+
content["availability"] = "Unavailable"
40+
return content
4741

48-
#################
49-
### "Partial" ###
50-
#################
51-
# Check if season or series is partially downloaded (Sonarr)
52-
try:
53-
# Series
54-
if content.__contains__("lastInfoSync"):
55-
if (
56-
content["episodeFileCount"] != 0
57-
and content["episodeFileCount"] < content["episodeCount"]
58-
):
59-
content["availability"] = "Partial"
60-
return content
42+
##### "Partial" #####
43+
# Sonarr: Check if season or series is partially downloaded
44+
if statistics and percent_available and percent_available < 100:
45+
content["availability"] = "Partial"
46+
return content
47+
# Radarr: Check if a movie is being downloaded.
48+
if grabbed is True and statistics and statistics.get("movieFileCount") == 0:
49+
content["availability"] = "Partial"
50+
return content
6151

62-
# Season
63-
elif (
64-
content["episodeFileCount"] != 0
65-
and content["totalEpisodeCount"] > content["episodeCount"]
66-
):
67-
content["availability"] = "Partial"
68-
return content
69-
except Exception:
70-
pass
71-
72-
###################
73-
### "Available" ###
74-
###################
75-
# Check if a season is fully downloaded (Sonarr)
76-
try:
77-
# Series
78-
if content.__contains__("lastInfoSync"):
79-
if (
80-
content["episodeFileCount"] != 0
81-
and content["episodeFileCount"] >= content["episodeCount"]
82-
):
83-
content["availability"] = "Available"
84-
return content
85-
86-
# Season
87-
elif (
88-
content["episodeFileCount"] != 0
89-
and content["totalEpisodeCount"] <= content["episodeCount"]
90-
):
91-
content["availability"] = "Available"
92-
return content
93-
except Exception:
94-
pass
95-
96-
# Check if an individual movie or individual episode exists (Sonarr & Radarr)
97-
try:
98-
if content["hasFile"]:
99-
content["availability"] = "Available"
100-
return content
101-
except Exception:
102-
pass
52+
##### "Available" #####
53+
# Sonarr: Check if a season or series is fully downloaded
54+
if statistics and percent_available == 100:
55+
content["availability"] = "Available"
56+
return content
57+
# Sonarr/Radarr: Check if an individual movie or individual episode exists
58+
if "hasFile" in content and content["hasFile"]:
59+
content["availability"] = "Available"
60+
return content
10361

62+
##### "Unknown" #####
63+
# This should never be reached except with Sonarr/Raddarr API changes
10464
content["availability"] = "Unknown"
10565
return content

conreq/core/arrs/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
from time import sleep
2+
13
from conreq.core.arrs.sonarr import SonarrManager
24

35

4-
def wait_for_series_info(tvdb_id, max_retries=10):
6+
def wait_for_series_info(tvdb_id, max_retries=15):
57
"""Keeps attempting to fetch a series from Sonarr until it becomes available"""
68
sonarr_manager = SonarrManager()
79
series = sonarr_manager.get(
@@ -16,4 +18,5 @@ def wait_for_series_info(tvdb_id, max_retries=10):
1618
series = sonarr_manager.get(
1719
tvdb_id=tvdb_id, obtain_season_info=True, force_update_cache=True
1820
)
21+
sleep(0.25)
1922
return series

0 commit comments

Comments
 (0)