Skip to content

Commit

Permalink
Merge pull request #135 from luigi311/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
luigi311 authored Jan 6, 2024
2 parents faef0ae + 95f2a9a commit 6ec003f
Show file tree
Hide file tree
Showing 12 changed files with 630 additions and 260 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: CI
on:
workflow_dispatch:
push:
paths-ignore:
- .gitignore
Expand Down Expand Up @@ -44,10 +45,16 @@ jobs:
sudo chown -R $PUID:$PGID JellyPlex-Watched-CI
docker pull lscr.io/linuxserver/plex &
docker pull lscr.io/linuxserver/jellyfin &
wait
docker-compose -f JellyPlex-Watched-CI/plex/docker-compose.yml up -d
docker-compose -f JellyPlex-Watched-CI/jellyfin/docker-compose.yml up -d
# Wait for containers to start
sleep 15
sleep 5
docker-compose -f JellyPlex-Watched-CI/plex/docker-compose.yml logs
docker-compose -f JellyPlex-Watched-CI/jellyfin/docker-compose.yml logs
Expand All @@ -59,6 +66,7 @@ jobs:
python main.py
cat mark.log
python test/validate_ci_marklog.py
docker:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
"program": "main.py",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Pytest",
"type": "python",
"request": "launch",
"module": "pytest",
"args": [
"-vv"
],
"console": "integratedTerminal",
"justMyCode": true
}
]
}
4 changes: 3 additions & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ ENV BLACKLIST_USERS ''
ENV WHITELIST_USERS ''


RUN addgroup --system jellyplex_user && \
RUN apk add --no-cache tini && \
addgroup --system jellyplex_user && \
adduser --system --no-create-home jellyplex_user --ingroup jellyplex_user && \
mkdir -p /app && \
chown -R jellyplex_user:jellyplex_user /app
Expand All @@ -48,4 +49,5 @@ COPY --chown=jellyplex_user:jellyplex_user . .

USER jellyplex_user

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["python", "-u", "main.py"]
7 changes: 6 additions & 1 deletion Dockerfile.slim
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ ENV BLACKLIST_USERS ''
ENV WHITELIST_USERS ''


RUN addgroup --system jellyplex_user && \
RUN apt-get update && \
apt-get install tini --yes --no-install-recommends && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
addgroup --system jellyplex_user && \
adduser --system --no-create-home jellyplex_user --ingroup jellyplex_user && \
mkdir -p /app && \
chown -R jellyplex_user:jellyplex_user /app
Expand All @@ -48,4 +52,5 @@ COPY --chown=jellyplex_user:jellyplex_user . .

USER jellyplex_user

ENTRYPOINT ["/bin/tini", "--"]
CMD ["python", "-u", "main.py"]
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys

if __name__ == "__main__":
# Check python version 3.6 or higher
if not (3, 6) <= tuple(map(int, sys.version_info[:2])):
print("This script requires Python 3.6 or higher")
# Check python version 3.9 or higher
if not (3, 9) <= tuple(map(int, sys.version_info[:2])):
print("This script requires Python 3.9 or higher")
sys.exit(1)

from src.main import main
Expand Down
14 changes: 14 additions & 0 deletions src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ def str_to_bool(value: any) -> bool:

# Search for nested element in list
def contains_nested(element, lst):
if lst is None:
return None

for i, item in enumerate(lst):
if item is None:
continue
if element in item:
return i
elif element == item:
return i
return None


Expand All @@ -92,6 +99,13 @@ def future_thread_executor(args: list, threads: int = 32):

workers = min(int(os.getenv("MAX_THREADS", 32)), os.cpu_count() * 2, threads)

# If only one worker, run in main thread to avoid overhead
if workers == 1:
results = []
for arg in args:
results.append(arg[0](*arg[1:]))
return results

with ThreadPoolExecutor(max_workers=workers) as executor:
for arg in args:
# * arg unpacks the list into actual arguments
Expand Down
22 changes: 19 additions & 3 deletions src/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def show_title_dict(user_list: dict):

return show_output_dict
except Exception:
logger("Generating show_output_dict failed, skipping", 1)
logger("Skipping show_output_dict ", 1)
return {}


Expand All @@ -168,12 +168,28 @@ def episode_title_dict(user_list: dict):
episode_output_dict["completed"] = []
episode_output_dict["time"] = []
episode_output_dict["locations"] = []
episode_output_dict["show"] = []
episode_output_dict["season"] = []
episode_counter = 0 # Initialize a counter for the current episode position

# Iterate through the shows, seasons, and episodes in user_list
for show in user_list:
for season in user_list[show]:
for episode in user_list[show][season]:
# Add the show title to the episode_output_dict if it doesn't exist
if "show" not in episode_output_dict:
episode_output_dict["show"] = [None] * episode_counter

# Add the season number to the episode_output_dict if it doesn't exist
if "season" not in episode_output_dict:
episode_output_dict["season"] = [None] * episode_counter

# Add the show title to the episode_output_dict
episode_output_dict["show"].append(dict(show))

# Add the season number to the episode_output_dict
episode_output_dict["season"].append(season)

# Iterate through the keys and values in each episode
for episode_key, episode_value in episode.items():
# If the key is not "status", add the key to episode_output_dict if it doesn't exist
Expand Down Expand Up @@ -213,7 +229,7 @@ def episode_title_dict(user_list: dict):

return episode_output_dict
except Exception:
logger("Generating episode_output_dict failed, skipping", 1)
logger("Skipping episode_output_dict", 1)
return {}


Expand Down Expand Up @@ -246,7 +262,7 @@ def movies_title_dict(user_list: dict):

return movies_output_dict
except Exception:
logger("Generating movies_output_dict failed, skipping", 1)
logger("Skipping movies_output_dict failed", 1)
return {}


Expand Down
Loading

0 comments on commit 6ec003f

Please sign in to comment.