Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed alldebrid instantavail file processing #916

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/program/services/downloaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def run(self, item: MediaItem):
download_success = True
break
else:
raise NoMatchingFilesException(f"No valid files found for stream {stream.infohash}")
raise NoMatchingFilesException(f"No valid files found")
dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
logger.debug(f"Stream {stream.infohash} failed: {e}")
if 'download_result' in locals() and download_result.id:
Expand Down
23 changes: 21 additions & 2 deletions src/program/services/downloaders/alldebrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,27 @@ def get_instant_availability(self, infohash: str, item_type: str) -> Optional[To
info = self.get_torrent_info(torrent_id)
if info.status == "Ready":
files = self.get_files_and_links(torrent_id)
processed_files = [DebridFile.create(filename=file["n"], filesize_bytes=file["s"], filetype=item_type) for file in files]
if processed_files is not None:
processed_files = []

def process_entry(entry):
if isinstance(entry, dict):
# file entries
if 'n' in entry and 's' in entry and 'l' in entry:
if debrid_file := DebridFile.create(
filename=entry['n'],
filesize_bytes=entry['s'],
filetype=item_type
):
processed_files.append(debrid_file)
# directory entries
elif 'e' in entry:
for sub_entry in entry['e']:
process_entry(sub_entry)

dreulavelle marked this conversation as resolved.
Show resolved Hide resolved
for file_entry in files:
process_entry(file_entry)

if processed_files:
return_value = TorrentContainer(infohash=infohash, files=processed_files)
except Exception as e:
logger.error(f"Failed to get instant availability: {e}")
Expand Down