From aab1e7f01652b59f04c724c1d2b2e874a2661796 Mon Sep 17 00:00:00 2001 From: LimeDrive Date: Thu, 12 Sep 2024 11:33:08 +0200 Subject: [PATCH 1/4] Fix resolution filter ( RTN output change ) --- .../utils/filter/quality_exclusion_filter.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/stream_fusion/utils/filter/quality_exclusion_filter.py b/stream_fusion/utils/filter/quality_exclusion_filter.py index 3ad7ac7..7212b0a 100644 --- a/stream_fusion/utils/filter/quality_exclusion_filter.py +++ b/stream_fusion/utils/filter/quality_exclusion_filter.py @@ -19,22 +19,21 @@ def filter(self, data): ] def _is_stream_allowed(self, stream) -> bool: - if any(q.upper() in self.excluded_qualities for q in stream.parsed_data.quality): + if stream.parsed_data.quality.upper() in self.excluded_qualities: logger.debug(f"Stream excluded due to main quality: {stream.parsed_data.quality}") return False if stream.parsed_data.resolution: - for item in stream.parsed_data.resolution: - item_upper = item.upper() - if item_upper in self.excluded_qualities: - logger.debug(f"Stream excluded due to quality spec: {item}") - return False - if self.exclude_rips and item_upper in self.RIPS: - logger.debug(f"Stream excluded due to RIP: {item}") - return False - if self.exclude_cams and item_upper in self.CAMS: - logger.debug(f"Stream excluded due to CAM: {item}") - return False + resolution_upper = stream.parsed_data.resolution.upper() + if resolution_upper in self.excluded_qualities: + logger.debug(f"Stream excluded due to quality spec: {stream.parsed_data.resolution}") + return False + if self.exclude_rips and resolution_upper in self.RIPS: + logger.debug(f"Stream excluded due to RIP: {stream.parsed_data.resolution}") + return False + if self.exclude_cams and resolution_upper in self.CAMS: + logger.debug(f"Stream excluded due to CAM: {stream.parsed_data.resolution}") + return False logger.debug("Stream allowed") return True From de26e1c1a22a17e329602e6d8a6a7a29aece9562 Mon Sep 17 00:00:00 2001 From: LimeDrive Date: Thu, 12 Sep 2024 11:33:44 +0200 Subject: [PATCH 2/4] Update pyproject.toml version to 1.1.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3b1f8f8..90869db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stream-fusion" -version = "1.1.0" +version = "1.1.1" description = "StreamFusion is an advanced plugin for Stremio that significantly enhances its streaming capabilities with debrid service." authors = ["LimeDrive "] readme = "README.md" From 71f33461a6154edfc1c55b410647ee94bdc277cf Mon Sep 17 00:00:00 2001 From: LimeDrive Date: Thu, 12 Sep 2024 13:22:17 +0200 Subject: [PATCH 3/4] Update ResultsPerQualityFilter and DMMTorrentInfo classes --- .../filter/results_per_quality_filter.py | 2 +- stream_fusion/utils/zilean/zilean_api.py | 77 ++++++++++++------- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/stream_fusion/utils/filter/results_per_quality_filter.py b/stream_fusion/utils/filter/results_per_quality_filter.py index 19f4205..85d0036 100644 --- a/stream_fusion/utils/filter/results_per_quality_filter.py +++ b/stream_fusion/utils/filter/results_per_quality_filter.py @@ -1,7 +1,7 @@ from stream_fusion.utils.filter.base_filter import BaseFilter from stream_fusion.logging_config import logger - +#TODO: Check if this filter is still needed and RTN changes for it. class ResultsPerQualityFilter(BaseFilter): def __init__(self, config): super().__init__(config) diff --git a/stream_fusion/utils/zilean/zilean_api.py b/stream_fusion/utils/zilean/zilean_api.py index 7e398a7..b83bcca 100644 --- a/stream_fusion/utils/zilean/zilean_api.py +++ b/stream_fusion/utils/zilean/zilean_api.py @@ -1,24 +1,20 @@ import requests from typing import List, Optional, Tuple -from pydantic import BaseModel, Field +from pydantic import BaseModel, ConfigDict, Field from requests.adapters import HTTPAdapter from urllib3.util.retry import Retry - from stream_fusion.settings import settings from stream_fusion.logging_config import logger - class DMMQueryRequest(BaseModel): queryText: Optional[str] = None - class DMMImdbFile(BaseModel): imdbId: Optional[str] = None category: Optional[str] = None title: Optional[str] = None - adult: bool = False - year: int = 0 - + adult: Optional[bool] = None + year: Optional[int] = None class DMMImdbSearchResult(BaseModel): title: Optional[str] = None @@ -27,29 +23,58 @@ class DMMImdbSearchResult(BaseModel): score: float = 0.0 category: Optional[str] = None - class DMMTorrentInfo(BaseModel): - info_hash: Optional[str] = None - resolution: Tuple[str, ...] = Field(default_factory=tuple) + model_config = ConfigDict(populate_by_name=True) + + info_hash: str + raw_title: str + size: str + parsed_title: Optional[str] = None + normalized_title: Optional[str] = None + trash: Optional[bool] = None year: Optional[int] = None - remastered: Optional[bool] = None - codec: Tuple[str, ...] = Field(default_factory=tuple) + resolution: Optional[str] = None + seasons: Tuple[int, ...] = Field(default_factory=tuple) + episodes: Tuple[int, ...] = Field(default_factory=tuple) + complete: Optional[bool] = None + volumes: Tuple[int, ...] = Field(default_factory=tuple) + languages: Tuple[str, ...] = Field(default_factory=tuple) + quality: Optional[str] = None + hdr: Tuple[str, ...] = Field(default_factory=tuple) + codec: Optional[str] = None audio: Tuple[str, ...] = Field(default_factory=tuple) - quality: Tuple[str, ...] = Field(default_factory=tuple) - episode: Tuple[int, ...] = Field(default_factory=tuple) - season: Tuple[int, ...] = Field(default_factory=tuple) - language: Tuple[str, ...] = Field(default_factory=tuple) - parsed_title: Optional[str] = None - raw_title: Optional[str] = None - size: int = 0 + channels: Tuple[str, ...] = Field(default_factory=tuple) + dubbed: Optional[bool] = None + subbed: Optional[bool] = None + date: Optional[str] = None + group: Optional[str] = None + edition: Optional[str] = None + bit_depth: Optional[str] = None + bitrate: Optional[str] = None + network: Optional[str] = None + extended: Optional[bool] = None + converted: Optional[bool] = None + hardcoded: Optional[bool] = None + region: Optional[str] = None + ppv: Optional[bool] = None + three_d: Optional[bool] = Field(None, alias='_3d') + site: Optional[str] = None + proper: Optional[bool] = None + repack: Optional[bool] = None + retail: Optional[bool] = None + upscaled: Optional[bool] = None + remastered: Optional[bool] = None + unrated: Optional[bool] = None + documentary: Optional[bool] = None + episode_code: Optional[str] = None + country: Optional[str] = None + container: Optional[str] = None + extension: Optional[str] = None + torrent: Optional[bool] = None category: Optional[str] = None imdb_id: Optional[str] = None imdb: Optional[DMMImdbFile] = None - class Config: - frozen = True - - class ZileanAPI: def __init__( self, @@ -61,8 +86,8 @@ def __init__( if not self.base_url: logger.error("Zilean API URL is not set in the environment variables.") raise ValueError("Zilean API URL is not set in the environment variables.") - self.session = requests.Session() + self.session = requests.Session() retry_strategy = Retry( total=max_retries, backoff_factor=0.1, @@ -92,13 +117,11 @@ def _request(self, method: str, endpoint: str, **kwargs): raise def _convert_to_dmm_torrent_info(self, entry: dict) -> DMMTorrentInfo: - for key in ['resolution', 'codec', 'audio', 'quality', 'episode', 'season', 'language']: + for key in ['seasons', 'episodes', 'volumes', 'languages', 'hdr', 'audio', 'channels']: if key in entry and isinstance(entry[key], list): entry[key] = tuple(entry[key]) - if 'imdb' in entry and entry['imdb']: entry['imdb'] = DMMImdbFile(**entry['imdb']) - return DMMTorrentInfo(**entry) def dmm_search(self, query: DMMQueryRequest) -> List[DMMTorrentInfo]: From fef60cab09d0f72c59a7c639c0db3ee30a913bbe Mon Sep 17 00:00:00 2001 From: LimeDrive Date: Thu, 12 Sep 2024 13:22:47 +0200 Subject: [PATCH 4/4] Update pyproject.toml version to 1.1.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 90869db..18658a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "stream-fusion" -version = "1.1.1" +version = "1.1.2" description = "StreamFusion is an advanced plugin for Stremio that significantly enhances its streaming capabilities with debrid service." authors = ["LimeDrive "] readme = "README.md"