Skip to content

Commit

Permalink
Upgraded packages
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaserlang committed May 19, 2024
1 parent bd76dbd commit 9ebe776
Show file tree
Hide file tree
Showing 12 changed files with 969 additions and 561 deletions.
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[project]
name = "seplis_play_server"
version = "2.0"
description = ""
dependencies = [
"PyYAML==6.0.1",
"pydantic==2.7.1",
"pydantic-settings==2.2.1",
"sqlalchemy[asyncio]==2.0.30",
"alembic==1.13.1",
"sentry-sdk==2.2.0",
"aiomysql==0.2.0",
"aiosqlite==0.19.0",
"fastapi==0.111.0",
"pyjwt==2.8.0",
"uvicorn==0.29.0",
"click==8.1.7",
"pytest==8.2.0",
"pytest_asyncio==0.23.7",
"httpx==0.27.0",
"respx==0.21.1",
"orjson==3.10.3",
"guessit==3.8.0",
"watchfiles==0.21.0",
"aiofile==3.8.8",
"iso639-lang==2.2.3",
]

[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core>=3.2,<4"]

[tool.ruff]
ignore = ["E712"]

[tool.ruff.format]
quote-style = "single"

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "I"]
28 changes: 14 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PyYAML==6.0.1
pydantic==2.5.2
pydantic-settings==2.0.3
sqlalchemy[asyncio]==2.0.23
alembic==1.12.1
sentry-sdk==1.34.0
pydantic==2.7.1
pydantic-settings==2.2.1
sqlalchemy[asyncio]==2.0.30
alembic==1.13.1
sentry-sdk==2.2.0
aiomysql==0.2.0
aiosqlite==0.19.0
fastapi==0.109.2
fastapi==0.111.0
pyjwt==2.8.0
uvicorn==0.23.2
uvicorn==0.29.0
click==8.1.7
pytest==7.4.3
pytest_asyncio==0.21.1
httpx==0.25.1
respx==0.20.2
orjson==3.9.10
guessit==3.7.1
pytest==8.2.0
pytest_asyncio==0.23.7
httpx==0.27.0
respx==0.21.1
orjson==3.10.3
guessit==3.8.0
watchfiles==0.21.0
aiofile==3.8.8
iso639-lang==2.1.0
iso639-lang==2.2.3
36 changes: 22 additions & 14 deletions seplis_play_server/database.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.ext.asyncio import (
AsyncSession,
create_async_engine,
async_sessionmaker,
AsyncEngine,
)
from seplis_play_server import config, utils
import os.path
import alembic.config
from alembic import command


def get_config():
cfg = alembic.config.Config(
os.path.dirname(
os.path.abspath(__file__)
)+'/alembic.ini'
os.path.dirname(os.path.abspath(__file__)) + "/alembic.ini"
)
cfg.set_main_option('script_location', 'seplis_play_server:migration')
cfg.set_main_option('url', config.database)
cfg.set_main_option("script_location", "seplis_play_server:migration")
cfg.set_main_option("url", config.database)
return cfg


def upgrade():
cfg = get_config()
command.upgrade(cfg, 'head')
command.upgrade(cfg, "head")


class Database:

def __init__(self):
self.engine = None
self.session = None
self.engine: AsyncEngine
self.session: async_sessionmaker

def setup(self):
self.engine = create_async_engine(
config.database.replace('mysqldb', 'aiomysql').replace('pymysql', 'aiomysql').replace('sqlite:', 'sqlite+aiosqlite:'),
config.database.replace("mysqldb", "aiomysql")
.replace("pymysql", "aiomysql")
.replace("sqlite:", "sqlite+aiosqlite:"),
echo=False,
pool_recycle=3599,
pool_pre_ping=True,
json_serializer=lambda obj: utils.json_dumps(obj),
json_deserializer=lambda s: utils.json_loads(s),
)
self.session = sessionmaker(self.engine, expire_on_commit=False, class_=AsyncSession)
self.session = async_sessionmaker(
self.engine, expire_on_commit=False, class_=AsyncSession
)

async def close(self):
await self.engine.dispose()

database = Database()

database = Database()
26 changes: 12 additions & 14 deletions seplis_play_server/routes/subtitle_file.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
from typing import Annotated
from fastapi import APIRouter, HTTPException, Response, Depends
from pydantic import constr
from pydantic import StringConstraints
from ..transcoders.subtitle import get_subtitle_file, get_subtitle_file_from_external
from ..dependencies import get_metadata

router = APIRouter()

@router.get('/subtitle-file')

@router.get("/subtitle-file")
async def download_subtitle(
lang: constr(min_length=1),
lang: Annotated[str, StringConstraints(min_length=1)],
offset: int | float = 0,
metadata=Depends(get_metadata)
):
if int(lang.split(':')[1]) < 1000:
sub = await get_subtitle_file(
metadata=metadata,
lang=lang,
offset=offset
)
metadata=Depends(get_metadata),
):
if int(lang.split(":")[1]) < 1000:
sub = await get_subtitle_file(metadata=metadata, lang=lang, offset=offset)
else:
sub = await get_subtitle_file_from_external(
id_=int(lang.split(':')[1])-1000,
id_=int(lang.split(":")[1]) - 1000,
offset=offset,
)
if not sub:
raise HTTPException(500, 'Unable retrive subtitle file')
return Response(content=sub, media_type='text/vtt')
raise HTTPException(500, "Unable retrive subtitle file")
return Response(content=sub, media_type="text/vtt")
4 changes: 3 additions & 1 deletion seplis_play_server/scanners/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import asyncio
import os, os.path, subprocess
import os
import os.path
import subprocess
from datetime import datetime, timezone
from seplis_play_server import config, utils, logger

Expand Down
Loading

0 comments on commit 9ebe776

Please sign in to comment.