-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: formatted using black & prettier (in frontend) and moved to crlf
- Loading branch information
1 parent
ffec1c4
commit 453d391
Showing
35 changed files
with
2,425 additions
and
2,349 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 |
---|---|---|
@@ -1,22 +1,22 @@ | ||
from fastapi import APIRouter, Request | ||
from utils.settings import settings_manager | ||
import requests | ||
from program.debrid.realdebrid import get_user | ||
|
||
|
||
router = APIRouter( | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/") | ||
async def root(request: Request): | ||
return { | ||
"success": True, | ||
"message": "Iceburg is running!", | ||
} | ||
|
||
|
||
@router.get("/user") | ||
async def get_rd_user(): | ||
return get_user() | ||
from fastapi import APIRouter, Request | ||
from utils.settings import settings_manager | ||
import requests | ||
from program.debrid.realdebrid import get_user | ||
|
||
|
||
router = APIRouter( | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/") | ||
async def root(request: Request): | ||
return { | ||
"success": True, | ||
"message": "Iceburg is running!", | ||
} | ||
|
||
|
||
@router.get("/user") | ||
async def get_rd_user(): | ||
return get_user() |
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,45 +1,46 @@ | ||
from fastapi import APIRouter, HTTPException, Request | ||
from program.media import MediaItemState | ||
from utils.logger import logger | ||
|
||
|
||
router = APIRouter( | ||
prefix="/items", | ||
tags=["items"], | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
@router.get("/states") | ||
async def get_states(request: Request): | ||
return { | ||
"success": True, | ||
"states": [state.name for state in MediaItemState], | ||
} | ||
|
||
|
||
@router.get("/") | ||
async def get_items(request: Request): | ||
return { | ||
"success": True, | ||
"items": [item.to_dict() for item in request.app.program.media_items.items], | ||
} | ||
|
||
|
||
@router.get("/{state}") | ||
async def get_item(request: Request, state: str): | ||
state = MediaItemState[state] | ||
items = request.app.program.media_items.get_items_with_state(state).items | ||
|
||
return { | ||
"success": True, | ||
"items": [item.to_dict() for item in items], | ||
} | ||
|
||
|
||
@router.delete("/remove/{item}") | ||
async def remove_item(request: Request, item: str): | ||
request.app.program.media_items.remove(item) | ||
return { | ||
"success": True, | ||
"message": f"Removed {item}", | ||
} | ||
from fastapi import APIRouter, HTTPException, Request | ||
from program.media import MediaItemState | ||
from utils.logger import logger | ||
|
||
|
||
router = APIRouter( | ||
prefix="/items", | ||
tags=["items"], | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/states") | ||
async def get_states(request: Request): | ||
return { | ||
"success": True, | ||
"states": [state.name for state in MediaItemState], | ||
} | ||
|
||
|
||
@router.get("/") | ||
async def get_items(request: Request): | ||
return { | ||
"success": True, | ||
"items": [item.to_dict() for item in request.app.program.media_items.items], | ||
} | ||
|
||
|
||
@router.get("/{state}") | ||
async def get_item(request: Request, state: str): | ||
state = MediaItemState[state] | ||
items = request.app.program.media_items.get_items_with_state(state).items | ||
|
||
return { | ||
"success": True, | ||
"items": [item.to_dict() for item in items], | ||
} | ||
|
||
|
||
@router.delete("/remove/{item}") | ||
async def remove_item(request: Request, item: str): | ||
request.app.program.media_items.remove(item) | ||
return { | ||
"success": True, | ||
"message": f"Removed {item}", | ||
} |
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,54 +1,54 @@ | ||
from copy import copy | ||
from fastapi import APIRouter | ||
from utils.settings import settings_manager | ||
from pydantic import BaseModel | ||
|
||
|
||
class SetSettings(BaseModel): | ||
key: str | ||
value: str | ||
|
||
|
||
router = APIRouter( | ||
prefix="/settings", | ||
tags=["settings"], | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/load") | ||
async def load_settings(): | ||
settings_manager.load() | ||
return { | ||
"success": True, | ||
"message": "Settings loaded!", | ||
} | ||
|
||
|
||
@router.post("/save") | ||
async def save_settings(): | ||
settings_manager.save() | ||
return { | ||
"success": True, | ||
"message": "Settings saved!", | ||
} | ||
|
||
|
||
@router.get("/get/{key}") | ||
async def get_settings(key: str): | ||
return { | ||
"success": True, | ||
"data": settings_manager.get(key), | ||
} | ||
|
||
|
||
@router.post("/set") | ||
async def set_settings(settings: SetSettings): | ||
settings_manager.set( | ||
settings.key, | ||
settings.value, | ||
) | ||
return { | ||
"success": True, | ||
"message": "Settings saved!", | ||
} | ||
from copy import copy | ||
from fastapi import APIRouter | ||
from utils.settings import settings_manager | ||
from pydantic import BaseModel | ||
|
||
|
||
class SetSettings(BaseModel): | ||
key: str | ||
value: str | ||
|
||
|
||
router = APIRouter( | ||
prefix="/settings", | ||
tags=["settings"], | ||
responses={404: {"description": "Not found"}}, | ||
) | ||
|
||
|
||
@router.get("/load") | ||
async def load_settings(): | ||
settings_manager.load() | ||
return { | ||
"success": True, | ||
"message": "Settings loaded!", | ||
} | ||
|
||
|
||
@router.post("/save") | ||
async def save_settings(): | ||
settings_manager.save() | ||
return { | ||
"success": True, | ||
"message": "Settings saved!", | ||
} | ||
|
||
|
||
@router.get("/get/{key}") | ||
async def get_settings(key: str): | ||
return { | ||
"success": True, | ||
"data": settings_manager.get(key), | ||
} | ||
|
||
|
||
@router.post("/set") | ||
async def set_settings(settings: SetSettings): | ||
settings_manager.set( | ||
settings.key, | ||
settings.value, | ||
) | ||
return { | ||
"success": True, | ||
"message": "Settings saved!", | ||
} |
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,42 +1,44 @@ | ||
import sys | ||
import os | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from program.program import Program | ||
from utils.thread import ThreadRunner | ||
from controllers.settings import router as settings_router | ||
from controllers.items import router as items_router | ||
from controllers.default import router as default_router | ||
|
||
|
||
sys.path.append(os.getcwd()) | ||
program = Program() | ||
runner = ThreadRunner(program.run, 5) | ||
|
||
def lifespan(app: FastAPI): | ||
runner.start() | ||
yield | ||
runner.stop() | ||
|
||
app = FastAPI(lifespan=lifespan) | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
app.program = program | ||
|
||
app.include_router(default_router) | ||
app.include_router(settings_router) | ||
app.include_router(items_router) | ||
|
||
if __name__ == "__main__": | ||
try: | ||
uvicorn.run("main:app", host="0.0.0.0", port=8080, reload=False) | ||
except KeyboardInterrupt: | ||
print("Exiting...") | ||
sys.exit(0) | ||
import sys | ||
import os | ||
import uvicorn | ||
from fastapi import FastAPI | ||
from fastapi.middleware.cors import CORSMiddleware | ||
from program.program import Program | ||
from utils.thread import ThreadRunner | ||
from controllers.settings import router as settings_router | ||
from controllers.items import router as items_router | ||
from controllers.default import router as default_router | ||
|
||
|
||
sys.path.append(os.getcwd()) | ||
program = Program() | ||
runner = ThreadRunner(program.run, 5) | ||
|
||
|
||
def lifespan(app: FastAPI): | ||
runner.start() | ||
yield | ||
runner.stop() | ||
|
||
|
||
app = FastAPI(lifespan=lifespan) | ||
app.add_middleware( | ||
CORSMiddleware, | ||
allow_origins=["*"], | ||
allow_credentials=True, | ||
allow_methods=["*"], | ||
allow_headers=["*"], | ||
) | ||
|
||
app.program = program | ||
|
||
app.include_router(default_router) | ||
app.include_router(settings_router) | ||
app.include_router(items_router) | ||
|
||
if __name__ == "__main__": | ||
try: | ||
uvicorn.run("main:app", host="0.0.0.0", port=8080, reload=False) | ||
except KeyboardInterrupt: | ||
print("Exiting...") | ||
sys.exit(0) |
Oops, something went wrong.