diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 9340893..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM mcr.microsoft.com/devcontainers/python:1-3.11-bullseye - -ENV PYTHONUNBUFFERED 1 - -# [Optional] If your requirements rarely change, uncomment this section to add them to the image. -# COPY requirements.txt /tmp/pip-tmp/ -# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ -# && rm -rf /tmp/pip-tmp - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - - - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 516f8b4..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the -// README at: https://github.com/devcontainers/templates/tree/main/src/postgres -{ - "name": "Python 3 & PostgreSQL", - "dockerComposeFile": "./docker-compose.yml", - "service": "app", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - - // Features to add to the dev container. More info: https://containers.dev/features. - // "features": {}, - - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // This can be used to network with other containers or the host. - // "forwardPorts": [5000, 5432], - - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "pip install --user -r ./MediaManager/src/requirements.txt", - - // Configure tool-specific properties. - "customizations" : { - "jetbrains" : { - "settings": { - "com.intellij:app:HttpConfigurable.use_proxy_pac": true - }, - "backend" : "PyCharm" - } - }, - - // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. - // "remoteUser": "root" -} diff --git a/.gitignore b/.gitignore index bfd1cf9..71a0421 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .idea venv MediaManager.iml -MediaManager/res -MediaManager/res/.env +backend/res +backend/res/.env docker-compose.yml \ No newline at end of file diff --git a/MediaManager/src/auth/__init__.py b/backend/src/auth/__init__.py similarity index 90% rename from MediaManager/src/auth/__init__.py rename to backend/src/auth/__init__.py index dd2ec28..ee42b32 100644 --- a/MediaManager/src/auth/__init__.py +++ b/backend/src/auth/__init__.py @@ -2,7 +2,7 @@ import logging from datetime import datetime, timedelta, timezone import jwt -from fastapi import Depends, HTTPException, status, APIRouter +from fastapi import APIRouter, Depends, HTTPException, status from fastapi.security import OAuth2PasswordBearer from jwt.exceptions import InvalidTokenError from pydantic import BaseModel @@ -12,7 +12,6 @@ from database import SessionDependency from database.users import User - class Token(BaseModel): access_token: str token_type: str @@ -42,7 +41,7 @@ async def get_current_user(db: SessionDependency, token: str = Depends(oauth2_sc payload = jwt.decode(token, config.jwt_signing_key, algorithms=[config.jwt_signing_algorithm]) log.debug("jwt payload: " + payload.__str__()) user_uid: str = payload.get("sub") - log.debug("jwt payload sub (user uid): " + user_uid) + log.debug("jwt payload sub (USER uid): " + user_uid) if user_uid is None: raise credentials_exception token_data = TokenData(uid=user_uid) @@ -53,10 +52,10 @@ async def get_current_user(db: SessionDependency, token: str = Depends(oauth2_sc user: User | None = db.get(User, token_data.uid) if user is None: - log.debug("user not found") + log.debug("USER not found") raise credentials_exception - log.debug("received user: " + user.__str__()) + log.debug("received USER: " + user.__str__()) return user diff --git a/MediaManager/src/auth/oidc.py b/backend/src/auth/oidc.py similarity index 100% rename from MediaManager/src/auth/oidc.py rename to backend/src/auth/oidc.py diff --git a/MediaManager/src/auth/password.py b/backend/src/auth/password.py similarity index 77% rename from MediaManager/src/auth/password.py rename to backend/src/auth/password.py index 3aea110..673751f 100644 --- a/MediaManager/src/auth/password.py +++ b/backend/src/auth/password.py @@ -1,15 +1,12 @@ from typing import Annotated -import hashlib - import bcrypt from fastapi import Depends, HTTPException, status from fastapi.security import OAuth2PasswordRequestForm -from sqlmodel import Session, select +from sqlmodel import select -import database -from auth import create_access_token, Token, router -from database import users, SessionDependency +from auth import Token, create_access_token, router +from database import SessionDependency from database.users import User @@ -27,9 +24,9 @@ def get_password_hash(password: str) -> str: def authenticate_user(db: SessionDependency, email: str, password: str) -> bool | User: """ - :param email: email of the user - :param password: password of the user - :return: if authentication succeeds, returns the user object with added name and lastname, otherwise or if the user doesn't exist returns False + :param email: email of the USER + :param password: PASSWORD of the USER + :return: if authentication succeeds, returns the USER object with added name and lastname, otherwise or if the USER doesn't exist returns False """ user: User | None = db.exec(select(User).where(User.email == email)).first() if not user: @@ -48,7 +45,7 @@ async def login_for_access_token( if not user: raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, - detail="Incorrect email or password", + detail="Incorrect email or PASSWORD", headers={"WWW-Authenticate": "Bearer"}, ) # id needs to be converted because a UUID object isn't json serializable diff --git a/MediaManager/src/database/torrents.py b/backend/src/database/torrents.py similarity index 100% rename from MediaManager/src/database/torrents.py rename to backend/src/database/torrents.py diff --git a/MediaManager/src/database/tv.py b/backend/src/database/tv.py similarity index 100% rename from MediaManager/src/database/tv.py rename to backend/src/database/tv.py diff --git a/MediaManager/src/database/users.py b/backend/src/database/users.py similarity index 100% rename from MediaManager/src/database/users.py rename to backend/src/database/users.py diff --git a/MediaManager/src/dowloadClients/__init__.py b/backend/src/dowloadClients/__init__.py similarity index 100% rename from MediaManager/src/dowloadClients/__init__.py rename to backend/src/dowloadClients/__init__.py diff --git a/MediaManager/src/dowloadClients/genericDownloadClient.py b/backend/src/dowloadClients/genericDownloadClient.py similarity index 100% rename from MediaManager/src/dowloadClients/genericDownloadClient.py rename to backend/src/dowloadClients/genericDownloadClient.py diff --git a/MediaManager/src/dowloadClients/qbittorrent.py b/backend/src/dowloadClients/qbittorrent.py similarity index 100% rename from MediaManager/src/dowloadClients/qbittorrent.py rename to backend/src/dowloadClients/qbittorrent.py diff --git a/MediaManager/src/indexer/__init__.py b/backend/src/indexer/__init__.py similarity index 100% rename from MediaManager/src/indexer/__init__.py rename to backend/src/indexer/__init__.py diff --git a/MediaManager/src/indexer/generic.py b/backend/src/indexer/generic.py similarity index 100% rename from MediaManager/src/indexer/generic.py rename to backend/src/indexer/generic.py diff --git a/MediaManager/src/indexer/prowlarr.py b/backend/src/indexer/prowlarr.py similarity index 100% rename from MediaManager/src/indexer/prowlarr.py rename to backend/src/indexer/prowlarr.py diff --git a/MediaManager/src/main.py b/backend/src/main.py similarity index 100% rename from MediaManager/src/main.py rename to backend/src/main.py diff --git a/MediaManager/src/metadataProvider/__init__.py b/backend/src/metadataProvider/__init__.py similarity index 100% rename from MediaManager/src/metadataProvider/__init__.py rename to backend/src/metadataProvider/__init__.py diff --git a/MediaManager/src/metadataProvider/abstractMetaDataProvider.py b/backend/src/metadataProvider/abstractMetaDataProvider.py similarity index 100% rename from MediaManager/src/metadataProvider/abstractMetaDataProvider.py rename to backend/src/metadataProvider/abstractMetaDataProvider.py diff --git a/MediaManager/src/metadataProvider/tmdb.py b/backend/src/metadataProvider/tmdb.py similarity index 100% rename from MediaManager/src/metadataProvider/tmdb.py rename to backend/src/metadataProvider/tmdb.py diff --git a/MediaManager/src/ml/__init__.py b/backend/src/ml/__init__.py similarity index 97% rename from MediaManager/src/ml/__init__.py rename to backend/src/ml/__init__.py index 3d6aa68..8e9a6dc 100644 --- a/MediaManager/src/ml/__init__.py +++ b/backend/src/ml/__init__.py @@ -26,7 +26,7 @@ def get_season(nfo: str) -> int | None: format=NFO.model_json_schema(), messages=[ { - 'role': 'user', + 'role': 'USER', 'content': "Tell me which season the torrent with this description contains?" + " output a season number in json format, the season number is an integer" + @@ -58,7 +58,7 @@ def contains_season(season_number: int, string_to_analyze: str) -> bool: format=Contains.model_json_schema(), messages=[ { - 'role': 'user', + 'role': 'USER', 'content': "Does this torrent contain the season " + season_number.__str__() + " ?" + " output a boolean json format" + diff --git a/MediaManager/src/ml/_testing.py b/backend/src/ml/_testing.py similarity index 94% rename from MediaManager/src/ml/_testing.py rename to backend/src/ml/_testing.py index d120c35..b1e012d 100644 --- a/MediaManager/src/ml/_testing.py +++ b/backend/src/ml/_testing.py @@ -1,8 +1,7 @@ import json from datetime import datetime, timedelta -from ollama import ChatResponse -from ollama import chat +from ollama import ChatResponse, chat from pydantic import BaseModel @@ -19,7 +18,7 @@ while start_time > datetime.now(): format=NFO.model_json_schema() , messages=[ { - 'role': 'user', + 'role': 'USER', 'content': "which season does a torrent with the following NFO contain? output the season number, which is an integer in json please\n" + "The.Big.Bang.Theory.(2007).Season.9.S09.(1080p.BluRay.x265.HEVC.10bit.AAC.5.1.Vyndros)" diff --git a/MediaManager/src/ml/test__init__.py b/backend/src/ml/test__init__.py similarity index 100% rename from MediaManager/src/ml/test__init__.py rename to backend/src/ml/test__init__.py diff --git a/MediaManager/src/requirements.txt b/backend/src/requirements.txt similarity index 100% rename from MediaManager/src/requirements.txt rename to backend/src/requirements.txt diff --git a/MediaManager/src/routers/__init__.py b/backend/src/routers/__init__.py similarity index 100% rename from MediaManager/src/routers/__init__.py rename to backend/src/routers/__init__.py diff --git a/MediaManager/src/routers/users.py b/backend/src/routers/users.py similarity index 83% rename from MediaManager/src/routers/users.py rename to backend/src/routers/users.py index c276fe0..b9e1adc 100644 --- a/MediaManager/src/routers/users.py +++ b/backend/src/routers/users.py @@ -1,12 +1,11 @@ -from fastapi import APIRouter -from fastapi import Depends -from sqlalchemy.exc import IntegrityError +from fastapi import APIRouter, Depends from pydantic import BaseModel +from sqlalchemy.exc import IntegrityError from starlette.responses import JSONResponse from auth import get_current_user from auth.password import get_password_hash -from database import SessionDependency, get_session +from database import SessionDependency from database.users import User, UserCreate, UserPublic from routers import log @@ -35,9 +34,9 @@ async def create_user( db.commit() except IntegrityError as e: log.debug(e) - log.warning("Failed to create new user, User with this email already exists "+internal_user.model_dump().__str__()) + log.warning("Failed to create new USER, User with this email already exists " + internal_user.model_dump().__str__()) return JSONResponse(status_code=409, content={"message": "User with this email already exists"}) - log.info("Created new user "+internal_user.email) + log.info("Created new USER " + internal_user.email) return UserPublic(**internal_user.model_dump()) diff --git a/MediaManager/src/tv/__init__.py b/backend/src/tv/__init__.py similarity index 100% rename from MediaManager/src/tv/__init__.py rename to backend/src/tv/__init__.py diff --git a/MediaManager/src/tv/router.py b/backend/src/tv/router.py similarity index 100% rename from MediaManager/src/tv/router.py rename to backend/src/tv/router.py