Skip to content

Commit

Permalink
fix: orionoid and mediafusion fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
dreulavelle committed Sep 30, 2024
1 parent 895ad0f commit 52f466e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/program/downloaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_cached_streams(self, hashes: list[str], needed_media, break_on_first = T
results = []
priority_index = 0

with ThreadPoolExecutor(thread_name_prefix="Downloader") as executor:
with ThreadPoolExecutor(thread_name_prefix="Downloader", max_workers=4) as executor:
futures = []

def cancel_all():
Expand Down
42 changes: 19 additions & 23 deletions src/program/scrapers/mediafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def validate(self) -> bool:
return False

payload = {
"streaming_provider": {
"token": self.api_key,
"service": self.downloader,
"enable_watchlist_catalogs": False
"sp": {
"sv": self.downloader,
"tk": self.api_key,
"ewc": False
},
"selected_catalogs": self.settings.catalogs,
"selected_resolutions": ["4K", "2160p", "1440p", "1080p", "720p"],
"enable_catalogs": False,
"max_size": "inf",
"max_streams_per_resolution": "10",
"torrent_sorting_priority": ["cached", "resolution", "size", "seeders", "created_at"],
"show_full_torrent_name": True,
"api_password": None
"sc": self.settings.catalogs,
"sr": ["4k", "2160p", "1440p", "1080p", "720p", "480p", None],
"ec": False,
"eim": False,
"sftn": True,
"tsp": ["cached"], # sort order, but this doesnt matter as we sort later
"nf": ["Disable"], # nudity filter
"cf": ["Disable"] # certification filter
}

url = f"{self.settings.url}/encrypt-user-data"
Expand Down Expand Up @@ -116,16 +116,7 @@ def run(self, item: MediaItem) -> Dict[str, str]:
logger.error(f"Mediafusion exception thrown: {e}")
return {}

def scrape(self, item: MediaItem) -> Dict[str, str]:
"""Scrape the given media item"""
data, stream_count = self.api_scrape(item)
if data:
logger.log("SCRAPER", f"Found {len(data)} streams out of {stream_count} for {item.log_string}")
else:
logger.log("NOT_FOUND", f"No streams found for {item.log_string}")
return data

def api_scrape(self, item: MediaItem) -> tuple[Dict[str, str], int]:
def scrape(self, item: MediaItem) -> tuple[Dict[str, str], int]:
"""Wrapper for `Mediafusion` scrape method"""
identifier, scrape_type, imdb_id = _get_stremio_identifier(item)

Expand All @@ -152,4 +143,9 @@ def api_scrape(self, item: MediaItem) -> tuple[Dict[str, str], int]:

torrents[info_hash] = raw_title

return torrents, len(response.data.streams)
if torrents:
logger.log("SCRAPER", f"Found {len(torrents)} streams for {item.log_string}")
else:
logger.log("NOT_FOUND", f"No streams found for {item.log_string}")

return torrents
2 changes: 1 addition & 1 deletion src/program/scrapers/orionoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,4 @@ def scrape(self, item: MediaItem) -> Dict[str, str]:
continue
torrents[stream.file.hash] = stream.file.name

return torrents, len(response.data.data.streams)
return torrents

0 comments on commit 52f466e

Please sign in to comment.