Skip to content

Commit

Permalink
Improve scraping downloading concurrency (#224)
Browse files Browse the repository at this point in the history
* cleanup

* validate refresh interval in the model

* use correct import and feild name

* incomplete not working code commit

* less broken now works to scraper stage

* Scrapers working

* End to end baby

* Settings reload

* Add update interval field for plex on frontend

* Cleanup and add type based item fetching

* make requested by based on class

* Render state name correctly

* add scheduler to reqs

* fill out any missing info in plex library using metadata state

* check for scheduler and executor when shutting down

* fix: plex validation

* dont instantiate container with list

* pickle doing bad things

* improve container updating accuraccy and add tests

* remove commented code

* state transition improvements

* don't check for metadata so often

* add indexed state and renamed content

* Use states instead of services to route items

* add type hints

* use hasattr instead

* Improvements from GB

* fix service reference

* state improvements

* feat: add symlink watcher using watchdog.

* improved deepcopy performance

* Infer parent_id when adding season/episode like direct parent link

* Lots of fixes

---------

Co-authored-by: Spoked <Spoked@localhost>
  • Loading branch information
omnunum and Spoked authored Feb 24, 2024
1 parent 7beb06b commit 710b75e
Show file tree
Hide file tree
Showing 41 changed files with 1,117 additions and 1,070 deletions.
17 changes: 6 additions & 11 deletions backend/controllers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,11 @@ async def get_rd_user():
@router.get("/services")
async def get_services(request: Request):
data = {}
if hasattr(request.app.program, "core_manager"):
for service in request.app.program.core_manager.services:
if hasattr(request.app.program, "services"):
for service in request.app.program.services.values():
data[service.key] = service.initialized
if getattr(service, "sm", False):
for sub_service in service.sm.services:
data[sub_service.key] = sub_service.initialized
if hasattr(request.app.program, "extras_manager"):
for service in request.app.program.extras_manager.services:
data[service.key] = service.initialized
if getattr(service, "sm", False):
for sub_service in service.sm.services:
data[sub_service.key] = sub_service.initialized
if not hasattr(service, "services"):
continue
for sub_service in service.services.values():
data[sub_service.key] = sub_service.initialized
return {"success": True, "data": data}
6 changes: 3 additions & 3 deletions backend/controllers/items.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fastapi import APIRouter, HTTPException, Request
from program.media.state import MediaItemStates
from program.media.state import States

router = APIRouter(
prefix="/items",
Expand All @@ -12,15 +12,15 @@
async def get_states(request: Request):
return {
"success": True,
"states": [state for state in MediaItemStates],
"states": [state for state in States],
}


@router.get("/")
async def get_items(request: Request):
return {
"success": True,
"items": [item.to_dict() for item in request.app.program.media_items.items],
"items": [item.to_dict() for item in request.app.program.media_items],
}


Expand Down
3 changes: 0 additions & 3 deletions backend/controllers/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,4 @@ async def set_settings(settings: List[SetSettings]):

settings_manager.load(settings_dict=current_settings)

# Notify observers about the update.
settings_manager.notify_observers()

return {"success": True, "message": "Settings updated successfully."}
21 changes: 14 additions & 7 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import contextlib
import sys
import threading
import time
import argparse
import traceback

import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from program import Program
from controllers.settings import router as settings_router
from controllers.items import router as items_router
from controllers.default import router as default_router
import contextlib
import sys
import threading
import time
import uvicorn
import argparse

from utils.logger import logger

parser = argparse.ArgumentParser()
parser.add_argument("--dev", action="store_true", help="Enable development mode")
Expand All @@ -28,6 +32,9 @@ def run_in_thread(self):
while not self.started:
time.sleep(1e-3)
yield
except Exception as e:
logger.error(traceback.format_exc())
raise e
finally:
app.program.stop()
self.should_exit = True
Expand Down Expand Up @@ -57,4 +64,4 @@ def run_in_thread(self):
app.program.start()
app.program.run()
except KeyboardInterrupt:
pass
pass
Loading

0 comments on commit 710b75e

Please sign in to comment.