Skip to content

Commit d2a6b5b

Browse files
authored
fix: fixed alldebrid instantavail file processing (#916)
1 parent fc7ed05 commit d2a6b5b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/program/services/downloaders/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def run(self, item: MediaItem):
6363
download_success = True
6464
break
6565
else:
66-
raise NoMatchingFilesException(f"No valid files found for stream {stream.infohash}")
66+
raise NoMatchingFilesException(f"No valid files found")
6767
except Exception as e:
6868
logger.debug(f"Stream {stream.infohash} failed: {e}")
6969
if 'download_result' in locals() and download_result.id:

src/program/services/downloaders/alldebrid.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,27 @@ def get_instant_availability(self, infohash: str, item_type: str) -> Optional[To
132132
info = self.get_torrent_info(torrent_id)
133133
if info.status == "Ready":
134134
files = self.get_files_and_links(torrent_id)
135-
processed_files = [DebridFile.create(filename=file["n"], filesize_bytes=file["s"], filetype=item_type) for file in files]
136-
if processed_files is not None:
135+
processed_files = []
136+
137+
def process_entry(entry):
138+
if isinstance(entry, dict):
139+
# file entries
140+
if 'n' in entry and 's' in entry and 'l' in entry:
141+
if debrid_file := DebridFile.create(
142+
filename=entry['n'],
143+
filesize_bytes=entry['s'],
144+
filetype=item_type
145+
):
146+
processed_files.append(debrid_file)
147+
# directory entries
148+
elif 'e' in entry:
149+
for sub_entry in entry['e']:
150+
process_entry(sub_entry)
151+
152+
for file_entry in files:
153+
process_entry(file_entry)
154+
155+
if processed_files:
137156
return_value = TorrentContainer(infohash=infohash, files=processed_files)
138157
except Exception as e:
139158
logger.error(f"Failed to get instant availability: {e}")

0 commit comments

Comments
 (0)