From 78f77c20a554b69db71bb8a6ac411a18600543a2 Mon Sep 17 00:00:00 2001 From: mhdzumair Date: Wed, 24 Apr 2024 09:41:08 +0530 Subject: [PATCH] bugfix #174: Fix resolving stream link for series when filename and extra details are yet to parse from background worker for RD & support for maximum torrent download check --- resources/exceptions/torrent_limit.mp4 | Bin 0 -> 81867 bytes streaming_providers/realdebrid/client.py | 6 +++++ streaming_providers/realdebrid/utils.py | 31 +++++++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 resources/exceptions/torrent_limit.mp4 diff --git a/resources/exceptions/torrent_limit.mp4 b/resources/exceptions/torrent_limit.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..37882020296b4ece948d61125188feb0187cdc6a GIT binary patch literal 81867 zcmeFZWmsIx5-vQryZfNQ-5r7jcXxMpLU0J~5L^R+5Zqlt@Zb<6KyZS)!=0RLm;3E~ z&i(i0d4TEZ)m3X%S9QtTy#N3JKyz0wM=KWxI{*M2@a+@y%WC9q!eZyh&H?}cV9lM) z%m83`l6Iy>uAng$&`^($Zx_XP+BWB;8dB�q4jM4n0{p*?|l|69;EAAPcDJ%*M>a z0W>x;Gh=6F23?S11Px%4QxunEUzrK_DSXpDoStCfSj3op>b$k@n4fCcDm zW-h=6G&M7}buh6JVBuxvWd<7A8`*lfmBU5h&doux67J3#Ipt+HYtAV47jg{lK5#Jd&IT|>a zo4c5~3NWw&T`iqK6d*>dKwAd~8zW25H-n!$S%EILRwkf_`MHA`Xz%==o0wSH8M%IY z5G#9EGiO^P&>&F1v8|i4k(YsqgPo(1E9kokXpUT+jjZfJEIUMnuDX6y@7>;Bk1b) zPDc=_jhPpSw*V^#^G{6!J1cw8SD=fDnZ22bo2vjj^S8%zHu^TF&Sox_AaZ9DgI~n` zcHP-Tz{J@cXlD$X*l%Kiz6h|gF){<4z6m41%*Y99I(}pPpHCxC0ZtxJhl{J3qX0Y5 z$`Pa`kVSx$2;ybr1Tuhc>IC?MOnB1lWiWv6@!?Xw13W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J8SIrywSEIa$#C78fZh2 zC@{TDY|#=8jEyp~C(iAwaI&cPHFeh#p z9M~(i>esawz>PIGVKC{{X}^ynU@#VcM+YM-;Fg}F)l!|nQ++$Ir2+M>Ki1Xrqk3_H zJc!1njLc@Hjz}OzV`hzX#1;jV0G7K6`^?M>Hm0YHfP3^drt4|v1sYT*OtX3^Cx@k} zwF9;cnDZ%9v*kE=)&j2Wl#Famt*Em4MBxCoqufK;+@QyAT14{VnOaL#O(K8#xe-v%}s@E;ES zm=Bd99EN8(^tO(%e12vI%)QOt2x$+T!3O~YnX#h-_ARRb#exAwiF91z01yS!AU*;C zjMD&wft&#kkn>>vIp8z}gHhO5Hl)WfYZy>F|97`@h`$hj!GSr@4xn*5<~@L~0~)9Pd&a3t?HXK* zH(BEB5^tCI3#`+FXX2;8JvZz<-~_JU<6Huk`m2BoK_IXIK?wMr8aPX1;xJJlO%f14 z00bZo69cZhfiw770*J%Jf%NaO*FYR52~>3rdo2N+fq>uy&fpiRBR~MlX$OJ^5Wq6P zYXKmr0zn!G;5C?D4G1#OHS|89_VB;%4;;WpOgf-ng5T(l13>`@KtG2a1%ez9gt6CP zzXSU)C=0;*&^7cvp!V?J(;uLI4#_P@ZvX%5Ezl?jl$)RtAIOj8>t(&V`WpNV9RGr2 zY48kQgZF`P^pai%bujolXeb260c)qFK!$WQu><1Z0gUaJelvD5bu str: rd_client = RealDebrid(token=user_data.streaming_provider.token, user_ip=user_ip) torrent_info = rd_client.get_available_torrent(info_hash) if not torrent_info: + response = rd_client.get_active_torrents() + if response["limit"] == response["nb"]: + raise ProviderException( + "Torrent limit reached. Please try again later.", "torrent_limit.mp4" + ) + if info_hash in response["list"]: + raise ProviderException( + "Torrent is already being downloading", "torrent_not_downloaded.mp4" + ) + torrent_id = rd_client.add_magent_link(magnet_link).get("id") torrent_info = rd_client.get_torrent_info(torrent_id) else: @@ -60,7 +75,7 @@ def get_direct_link_from_realdebrid( torrent_id, "downloaded", max_retries, retry_interval ) - return create_download_link(rd_client, torrent_info, filename, file_index) + return create_download_link(rd_client, torrent_info, filename, file_index, episode) def update_rd_cache_status(streams: list[TorrentStreams], user_data: UserData): @@ -79,7 +94,7 @@ def update_rd_cache_status(streams: list[TorrentStreams], user_data: UserData): def select_file_index_from_torrent( - torrent_info: dict[str, Any], filename: str, file_index: int + torrent_info: dict[str, Any], filename: str, file_index: int, episode: int ) -> int: """Select the file index from the torrent info.""" if file_index is not None and file_index < len(torrent_info["links"]): @@ -91,6 +106,12 @@ def select_file_index_from_torrent( if file["path"] == "/" + filename: return index + if episode: + # Select the file with the matching episode number + for index, file in enumerate(selected_files): + if PTN.parse(file["path"]).get("episode") == episode: + return index + # If no file index is provided, select the largest file largest_file = max(selected_files, key=lambda file: file["bytes"]) return selected_files.index(largest_file)