Skip to content

Commit

Permalink
Rename Scraping to Scraper to be consistent across platform
Browse files Browse the repository at this point in the history
  • Loading branch information
omnunum committed Feb 5, 2024
1 parent 3b001a3 commit db29f42
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 46 deletions.
4 changes: 2 additions & 2 deletions backend/program/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import threading
import time
import concurrent.futures
from program.scrapers import Scraping
from program.scrapers import Scraper
from program.realdebrid import Debrid
from program.symlink import Symlinker
from program.media.container import MediaItemContainer
Expand Down Expand Up @@ -37,7 +37,7 @@ def start(self):
if not self.startup_args.dev:
self.pickly = Pickly(self.media_items, self.data_path)
self.pickly.start()
self.core_manager = ServiceManager(self.media_items, True, Content, Plex, Scraping, Debrid, Symlinker)
self.core_manager = ServiceManager(self.media_items, True, Content, Plex, Scraper, Debrid, Symlinker)
if self.validate():
logger.info("Iceberg started!")
else:
Expand Down
2 changes: 1 addition & 1 deletion backend/program/media/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def perform_action(self, _):

class Content(MediaItemState):
def perform_action(self, modules):
scraper = next(module for module in modules if module.key == "scraping")
scraper = next(module for module in modules if module.key == "scraper")
if self.context.type in ["movie", "season", "episode"]:
scraper.run(self.context)
if self.context.state == Content and self.context.type == "season":
Expand Down
6 changes: 3 additions & 3 deletions backend/program/scrapers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
from program.scrapers.jackett import Jackett


class Scraping:
class Scraper:
def __init__(self, _):
self.key = "scraping"
self.key = "scraper"
self.initialized = False
self.settings = settings_manager.settings.scraper
self.sm = ServiceManager(None, False, Orionoid, Torrentio, Jackett)
if not any(service.initialized for service in self.sm.services):
logger.error(
"You have no scraping services enabled, please enable at least one!"
"You have no scraper services enabled, please enable at least one!"
)
return
self.initialized = True
Expand Down
4 changes: 2 additions & 2 deletions backend/program/settings/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pydantic import ValidationError

from utils import data_dir_path
from program.settings.models import AppModel
from program.settings.models import AppModel, NotifyingBaseModel
from utils.logger import logger
from utils.observable import Observable

Expand All @@ -19,7 +19,7 @@ def __init__(self):
self.filename = "settings.json"
self.settings_file = data_dir_path / self.filename

AppModel.set_notify_observers(self.notify_observers)
NotifyingBaseModel.set_notify_observers(self.notify_observers)

if not os.path.exists(self.settings_file):
self.settings = AppModel()
Expand Down
23 changes: 12 additions & 11 deletions backend/program/settings/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Iceberg settings models"""

from typing import Optional
from pydantic import BaseModel, root_validator
from pathlib import Path

from pydantic import BaseModel, root_validator


class NotifyingBaseModel(BaseModel):
Expand All @@ -19,8 +20,8 @@ def set_notify_observers(cls, notify_observers_callable):

def __setattr__(self, name, value):
super().__setattr__(name, value)
if self.__class__.notify_observers:
self.__class__.notify_observers()
if self.__class__._notify_observers:
self.__class__._notify_observers()

class PlexModel(NotifyingBaseModel):
user: str = ""
Expand All @@ -31,8 +32,8 @@ class DebridModel(NotifyingBaseModel):
api_key: str = ""

class SymlinkModel(NotifyingBaseModel):
host_path: str = ""
container_path: str = ""
host_path: Path = Path()
container_path: Path = Path()

# Content Services
class ContentNotifyingBaseModel(NotifyingBaseModel):
Expand Down Expand Up @@ -79,17 +80,17 @@ class TorrentioConfig(NotifyingBaseModel):
filter: str = "sort=qualitysize%7Cqualityfilter=480p,scr,cam,unknown"

class ScraperModel(NotifyingBaseModel):
after_2: int = 0.5,
after_5: int = 2,
after_10: int = 24,
after_2: float = 0.5
after_5: int = 2
after_10: int = 24
jackett: JackettConfig = JackettConfig()
orionoid: OrionoidConfig = OrionoidConfig()
torrentio: TorrentioConfig = TorrentioConfig()

class ParserModel(NotifyingBaseModel):
highest_quality: bool = False,
include_4k: bool = False,
repack_proper: bool = True,
highest_quality: bool = False
include_4k: bool = False
repack_proper: bool = True
language: list[str] = ["English"]


Expand Down
11 changes: 4 additions & 7 deletions backend/program/symlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def __init__(self, _):
logger.error("Symlink initialization failed due to invalid configuration.")
return
logger.info("Rclone path symlinks are pointed to: %s", self.settings.host_path)
logger.info("Symlinks will be placed in: %s", self.library_path)
logger.info("Symlinks will be placed in: %s", self.settings.container_path)
logger.info("Symlink initialized!")
self.initialized = True

def validate(self):
"""Validate paths and create the initial folders."""
host_path = Path(self.settings.host_path) if self.settings.host_path else None
container_path = Path(self.settings.container_path) if self.settings.container_path else None
host_path = self.settings.host_path
container_path = self.settings.container_path
if not host_path or not container_path or host_path == Path('.') or container_path == Path('.'):
logger.error("Host or container path not provided, is empty, or is set to the current directory.")
return False
Expand All @@ -47,9 +47,6 @@ def validate(self):
if not host_path.is_dir():
logger.error(f"Host path is not a directory or does not exist: {host_path}")
return False
# if not container_path.is_dir():
# logger.error(f"Container path is not a directory or does not exist: {container_path}")
# return False
if Path(self.settings.host_path / "__all__").exists() and Path(self.settings.host_path / "__all__").is_dir():
logger.debug("Detected Zurg host path. Using __all__ folder for host path.")
self.settings.host_path = self.settings.host_path / "__all__"
Expand All @@ -71,7 +68,7 @@ def validate(self):
def create_initial_folders(self):
"""Create the initial library folders."""
try:
self.library_path = self.settings.host_path.parent / "library"
self.library_path = self.settings.container_path / "library"
self.library_path_movies = self.library_path / "movies"
self.library_path_shows = self.library_path / "shows"
self.library_path_anime_movies = self.library_path / "anime_movies"
Expand Down
2 changes: 1 addition & 1 deletion backend/utils/default_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"api_key": ""
}
},
"scraping": {
"scraper": {
"after_2": 0.5,
"after_5": 2,
"after_10": 24,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const onboarding: Handle = async ({ event, resolve }) => {
if (!data.success || !data.data) {
error(500, 'API Error');
}
const toCheck = ['content', 'scraping', 'plex', 'real_debrid', 'symlink'];
const toCheck = ['content', 'scraper', 'plex', 'real_debrid', 'symlink'];
const allServicesTrue: boolean = toCheck.every((service) => data.data[service] === true);
if (!allServicesTrue) {
redirect(302, '/onboarding');
Expand Down
28 changes: 14 additions & 14 deletions frontend/src/lib/forms/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ export function mediaServerSettingsToSet(form: SuperValidated<MediaServerSetting
}

// Scrapers Settings -----------------------------------------------------------------------------------
export const scrapersSettingsToGet: string[] = ['scraping'];
export const scrapersSettingsServices: string[] = ['scraping'];
export const scrapersSettingsToGet: string[] = ['scraper'];
export const scrapersSettingsServices: string[] = ['scraper'];

export const scrapersSettingsSchema = z.object({
after_2: z.number().nonnegative().default(0.5),
Expand All @@ -239,24 +239,24 @@ export type ScrapersSettingsSchema = typeof scrapersSettingsSchema;

export function scrapersSettingsToPass(data: any) {
return {
after_2: data.data.scraping.after_2,
after_5: data.data.scraping.after_5,
after_10: data.data.scraping.after_10,
torrentio_url: data.data.scraping.torrentio?.url || 'https://torrentio.strem.fun',
torrentio_enabled: data.data.scraping.torrentio.enabled,
orionoid_enabled: data.data.scraping.orionoid.enabled,
jackett_enabled: data.data.scraping.jackett.enabled,
torrentio_filter: data.data.scraping.torrentio?.filter || '',
orionoid_api_key: data.data.scraping.orionoid?.api_key || '',
jackett_url: data.data.scraping.jackett?.url || '',
jackett_api_key: data.data.scraping.jackett?.api_key || ''
after_2: data.data.scraper.after_2,
after_5: data.data.scraper.after_5,
after_10: data.data.scraper.after_10,
torrentio_url: data.data.scraper.torrentio?.url || 'https://torrentio.strem.fun',
torrentio_enabled: data.data.scraper.torrentio.enabled,
orionoid_enabled: data.data.scraper.orionoid.enabled,
jackett_enabled: data.data.scraper.jackett.enabled,
torrentio_filter: data.data.scraper.torrentio?.filter || '',
orionoid_api_key: data.data.scraper.orionoid?.api_key || '',
jackett_url: data.data.scraper.jackett?.url || '',
jackett_api_key: data.data.scraper.jackett?.api_key || ''
};
}

export function scrapersSettingsToSet(form: SuperValidated<ScrapersSettingsSchema>) {
return [
{
key: 'scraping',
key: 'scraper',
value: {
after_2: form.data.after_2,
after_5: form.data.after_5,
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
export let data: PageData;
const MandatoryServices = ['plex', 'content', 'scraping', 'real_debrid', 'symlink'];
const MandatoryServices = ['plex', 'content', 'scraper', 'real_debrid', 'symlink'];
const ContentServices = ['mdblist', 'overseerr', 'plex_watchlist'];
const ScrapingServices = ['torrentio', 'jackett', 'orionoid'];
const ScraperServices = ['torrentio', 'jackett', 'orionoid'];
function sortServices(services: string[], data: Record<string, boolean>) {
let sortedData = {} as Record<string, boolean>;
Expand Down Expand Up @@ -53,8 +53,8 @@
<h2 class="text-lg md:text-xl font-semibold">Content services</h2>
<ServiceStatus statusData={sortServices(ContentServices, services.data)} />
<br />
<h2 class="text-lg md:text-xl font-semibold">Scraping services</h2>
<ServiceStatus statusData={sortServices(ScrapingServices, services.data)} />
<h2 class="text-lg md:text-xl font-semibold">Scraper services</h2>
<ServiceStatus statusData={sortServices(ScraperServices, services.data)} />
{:catch}
<p class="text-muted-foreground">Failed to fetch services status</p>
{/await}
Expand Down

0 comments on commit db29f42

Please sign in to comment.