Skip to content
Draft
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
3 changes: 2 additions & 1 deletion mlm_mam/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,13 @@ impl<'a> MaM<'a> {
}
}

pub async fn get_torrent_file(&self, dl_hash: &str) -> Result<Bytes> {
pub async fn get_torrent_file(&self, dl_hash: &str, mam_id: u64) -> Result<Bytes> {
let resp = self
.client
.get(format!(
"https://www.myanonamouse.net/tor/download.php/{dl_hash}"
))
.query(&[("tid", mam_id)])
.send()
.await?
.error_for_status()
Expand Down
10 changes: 7 additions & 3 deletions server/src/torrent_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn grab_torrent(
);

let user_info = mam.user_info().await?;
let torrent_file_bytes = get_mam_torrent_file(mam, &torrent.dl_link).await?;
let torrent_file_bytes = get_mam_torrent_file(mam, &torrent.dl_link, torrent.mam_id).await?;
let torrent_file = Torrent::read_from_bytes(torrent_file_bytes.clone())?;
let hash = torrent_file.info_hash();

Expand Down Expand Up @@ -336,9 +336,13 @@ async fn get_existing_qbit_torrent(
None
}

pub(crate) async fn get_mam_torrent_file(mam: &MaM<'_>, dl_link: &str) -> Result<Bytes> {
pub(crate) async fn get_mam_torrent_file(
mam: &MaM<'_>,
dl_link: &str,
mam_id: u64,
) -> Result<Bytes> {
loop {
let result = mam.get_torrent_file(dl_link).await;
let result = mam.get_torrent_file(dl_link, mam_id).await;

match result {
Ok(v) => return Ok(v),
Expand Down