-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Spoked
authored and
Spoked
committed
Feb 7, 2024
1 parent
0f40b70
commit b73e95c
Showing
16 changed files
with
109 additions
and
80 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,7 +1,8 @@ | ||
data/ | ||
logs/ | ||
settings.json | ||
.vscode | ||
.vscode/* | ||
!.vscode/launch.json | ||
__pycache__ | ||
.git | ||
docker-compose.yml | ||
|
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,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run Iceberg", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "backend/main.py", | ||
} | ||
] | ||
} |
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
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 @@ | ||
0.4.6 |
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
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
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,37 @@ | ||
from program.media.container import MediaItemContainer | ||
from program.updaters.trakt import Updater as Trakt | ||
|
||
|
||
class ContentServiceBase: | ||
"""Base class for content providers""" | ||
|
||
def __init__(self, media_items: MediaItemContainer): | ||
self.media_items = media_items | ||
self.updater = Trakt() | ||
self.not_found_ids = [] | ||
self.next_run_time = 0 | ||
|
||
def validate(self): | ||
"""Validate the content provider settings.""" | ||
raise NotImplementedError("The 'validate' method must be implemented by subclasses.") | ||
|
||
def run(self): | ||
"""Fetch new media from the content provider.""" | ||
raise NotImplementedError("The 'run' method must be implemented by subclasses.") | ||
|
||
def process_items(self, items, requested_by): | ||
"""Process fetched media items and log the results.""" | ||
new_items = [item for item in items if self.is_valid_item(item)] | ||
if not new_items: | ||
return | ||
container = self.updater.create_items(new_items) | ||
added_items = self.media_items.extend(container) | ||
for item in added_items: | ||
if hasattr(item, "set"): | ||
item.set("requested_by", requested_by) | ||
return added_items | ||
|
||
def is_valid_item(self, item) -> bool: | ||
"""Check if the item is valid for processing and not already in media_items""" | ||
is_unique = item not in self.media_items | ||
return item is not None and is_unique |
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
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
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
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
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
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
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
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,4 +1,7 @@ | ||
from pathlib import Path | ||
import os | ||
|
||
data_dir_path = Path(os.path.abspath(__file__)).parent.parent.parent / "data" | ||
|
||
root_dir = Path(__file__).resolve().parents[2] | ||
|
||
data_dir_path = root_dir / "data" | ||
version_file_path = root_dir / "VERSION" |
Oops, something went wrong.