Skip to content

feat: yank magnet without metadata and trackers#40

Merged
Beastwick18 merged 2 commits intoBeastwick18:mainfrom
slundi:yank-magnet-without-tracker-metadata
May 12, 2025
Merged

feat: yank magnet without metadata and trackers#40
Beastwick18 merged 2 commits intoBeastwick18:mainfrom
slundi:yank-magnet-without-tracker-metadata

Conversation

@slundi
Copy link
Contributor

@slundi slundi commented May 6, 2025

Close: #37

Copy link
Owner

@Beastwick18 Beastwick18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍, just would make sure to handle errors with Url::parse instead of unwrapping

@slundi slundi force-pushed the yank-magnet-without-tracker-metadata branch from 310ea71 to 978ccb2 Compare May 6, 2025 18:28
@slundi
Copy link
Contributor Author

slundi commented May 6, 2025

Hello,

Thanks for your complete review, I just had to copy-paste and test :)

@slundi slundi requested a review from Beastwick18 May 6, 2025 18:32
@slundi slundi force-pushed the yank-magnet-without-tracker-metadata branch from 978ccb2 to efea4e0 Compare May 8, 2025 07:24
Copy link

@brian6932 brian6932 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done in a different PR, but want to mention anyway, this bool should be applied to client handlers as well as yanks. Either the bool should be renamed more generically, and used for both, or 2 bools can be made.

None | Some(true) => item.magnet_link.to_owned(),

true => item.magnet_link.to_owned(),

true => item.magnet_link.to_owned(),

.sub("{magnet}", &item.magnet_link)

@slundi
Copy link
Contributor Author

slundi commented May 8, 2025

I can improve it, it shouldn't be difficult

@slundi
Copy link
Contributor Author

slundi commented May 8, 2025

@brian6932

I was beginning to implement per client but:

impl DownloadClient for RqbitClient {
    async fn download(
        item: Item,
        conf: ClientConfig,
        client: reqwest::Client,
    ) -> SingleDownloadResult {
        let conf = match conf.rqbit.clone() {
            Some(q) => q,
            None => {
                return SingleDownloadResult::error("Failed to get rqbit config");
            }
        };
        let link = match conf.use_magnet.unwrap_or(true) {
            true => {
                if let Some(full) = conf.yank_full_magnet {
                    if full {
                        item.magnet_link.to_owned()
                    } else {
                        match minimal_magnet_link(item.magnet_link.clone()){
                            Ok(magnet) => magnet.to_owned(),
                            Err(_) => todo!(),  // context not available here
                        }
                    }
                } else {
                    item.magnet_link.to_owned()
                }
            }
            false => item.torrent_link.to_owned(),
        };
        // ...
    }
}

But, in case of error, I don't have the context (to do something like return ctx.notify_error(e)), how should it be solved? return the item.magnet_link anyway?

@slundi slundi marked this pull request as draft May 8, 2025 19:48
@brian6932
Copy link

how should it be solved? return the item.magnet_link anyway?

I'm no rust expert, but it sounds pretty ok to me. There's not much of a chance for error. At that point it's an issue with nyaa sending non-compliant magnet links (I don't think it's possible for any listings to not have one in the first place). The most I can say about saftey's that it may be good to add a BTMH magnet v2 URI test case, for forwards compatibility.

@slundi slundi force-pushed the yank-magnet-without-tracker-metadata branch 2 times, most recently from 45095f5 to d6f10db Compare May 9, 2025 19:28
@slundi slundi marked this pull request as ready for review May 9, 2025 19:37
Copy link
Owner

@Beastwick18 Beastwick18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything LGTM functionality wise, so I can implement the changes mentioned after merging if that sounds good!

@slundi slundi force-pushed the yank-magnet-without-tracker-metadata branch from d6f10db to 9f37186 Compare May 11, 2025 19:28
@slundi slundi force-pushed the yank-magnet-without-tracker-metadata branch from 9f37186 to 674ba69 Compare May 11, 2025 20:01
@Beastwick18
Copy link
Owner

Everything looks good, thanks for adding this!

@Beastwick18 Beastwick18 merged commit 9437d9b into Beastwick18:main May 12, 2025
4 checks passed
@Beastwick18
Copy link
Owner

Whoops, just noticed the condition is backwards for keycombo 'ym'. It yanks the minimal link when yank_full_magnet = true and the full one when yank_full_magnet = false. Fixed that 8026e52

@slundi slundi deleted the yank-magnet-without-tracker-metadata branch May 12, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to yank/open magnet links without trackers and/or metadata query params

3 participants