-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd76dbd
commit 9ebe776
Showing
12 changed files
with
969 additions
and
561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.