mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:13:24 +02:00
renaming directory
This commit is contained in:
@@ -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 <your-package-list-here>
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,6 +1,6 @@
|
||||
.idea
|
||||
venv
|
||||
MediaManager.iml
|
||||
MediaManager/res
|
||||
MediaManager/res/.env
|
||||
backend/res
|
||||
backend/res/.env
|
||||
docker-compose.yml
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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" +
|
||||
@@ -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)"
|
||||
@@ -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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user