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

How to resume a download use '.aria2' file #792

Open
iahu opened this issue Dec 2, 2016 · 45 comments
Open

How to resume a download use '.aria2' file #792

iahu opened this issue Dec 2, 2016 · 45 comments
Labels

Comments

@iahu
Copy link

iahu commented Dec 2, 2016

Can I resume a download task use '.aria2' file ?

@tatsuhiro-t
Copy link
Collaborator

aria2 creates a file whose name is the same as the file you are downloading and has a suffix ".aria2" (e.g., foo.txt.aria2). It is called control file.
It contains all information to resume download. Note that control file must exist in the same directory with the downloading file.

@iahu
Copy link
Author

iahu commented Dec 3, 2016

Thanks @tatsuhiro-t . I really searched how to do the resume job, but could not got a example.
Could you give a example usage of it for me ?
Thanks again.

@tatsuhiro-t
Copy link
Collaborator

When you hit ctrl-C while downloading is still in progress, aria2 leaves control file. Running the same command line, aria2 starts resuming last download.

@HaleTom
Copy link

HaleTom commented Apr 15, 2017

Is it possible to restart the download without the original link, but only the .aria2 file? I want to resume my torrent and can't find the tracker...

@tatsuhiro-t
Copy link
Collaborator

Changing tracker is no problem as long as the info hash stays the same.

@HaleTom
Copy link

HaleTom commented Apr 16, 2017

How do I use the info hash in the .aria2 to resume the download without finding a new magnet/download link?

@tatsuhiro-t
Copy link
Collaborator

https://aria2.github.io/manual/en/html/technical-notes.html describes the format of .aria2 control file.
Once the info hash is obtained, then creating magnet link is easy.

@IamCarbonMan
Copy link

I think @HaleTom is looking for a command line option or something similar to resume a download without knowing the original download link, using only the .aria2 file.

@HaleTom
Copy link

HaleTom commented May 4, 2017

@IamCarbonMan Yup, a user shouldn't need to dig into a file-format specification to resume a magnet download.

@matiffeder
Copy link

I'm also looking for the solution of resume without link, please tell me if anyone knows. Thank you!

@stefanos82
Copy link

stefanos82 commented Jun 29, 2017

@HaleTom That is exactly what I thought .aria2 files were supposed to do.

UNIX-like systems users are privileged in this case, because the majority of them use bash by default that comes with history and it's pretty easy to re-enter the original command to resume your download.

What about those poor Windows users?

Indeed it would be more than awesome to have such an option by default as you have suggested.

What it would be nice, would be to have something like a new flag that builds config settings for each download:

aria2c --build-config <magnet-link>

After you interrupt it and want to resume, all you must do would be something like:

aria2c --use-config <aria2-file>.aria2

This config should reside in the same location where the file is downloaded and as soon as the file gets downloaded successfully to get deleted automatically.

@tatsuhiro-t Does it sound silly as an idea?

@alphatr
Copy link

alphatr commented Aug 2, 2017

Hi @HaleTom , I write a tools to transform .aria2 file to a magnet link http://alphatr.github.io/aria2-reader.html

@HaleTom
Copy link

HaleTom commented Aug 4, 2017

@stefanos82 I use uget as a front-end to aria2c, so I can't use my bash history :(

@stefanos82
Copy link

@HaleTom no worries.

May I ask what operating system are you using? I could suggest an alternative to your issue as a workaround.

@HaleTom
Copy link

HaleTom commented Aug 4, 2017

@stefanos82 I'm using Manjaro linux. I've temporarily switched to using deluge for torrents. Still, I am interested in your suggestion, and others may be, too.

@stefanos82
Copy link

stefanos82 commented Aug 4, 2017

Perfect! The workaround is rather simple: just install ClipIt clipboard manager in case you haven't installed it already and use the link(s) from your clipboard manager history to resume any link you want.

Just make sure you have your link(s) copied to clipit; that's how I roll to be honest with you. It's easier to press Ctrl+C than having to look into my browser history to find that website I downloaded that file.

@stefanos82
Copy link

@HaleTom I have downloaded uget and played a bit with it. It's a pretty straight-forward application and lets you resume your magnet links by default.

It comes bundled with clipboard monitoring support and not only that, it logs everything you download or delete.

The only way aria2 would not resume your magnet link with uget would be when you delete the folder that contains the downloaded content without deleting your .aria2 file; this way will restart the download from the start.

Is this your case?

@markmark1
Copy link

I need to resume aria2c files as well how do I resume from cmd line

@smasterfree
Copy link

i write cmd tool to parse the .aria2 file with python. it can extract magnet link from the control file.
check https://github.com/smasterfree/aria-control-file-parser :)

@markmark1
Copy link

markmark1 commented Nov 19, 2017 via email

@smasterfree
Copy link

i update readme and add a cmd line warpper.

how to run

python aria2_to_magnet.py -f dahufa.aria2

output

magnet:?xt=urn:btih:959E2ECEB954313D3869EFF7924CA7CD8DE739

@markmark1
Copy link

markmark1 commented Nov 20, 2017 via email

@kiinoo
Copy link

kiinoo commented Jul 22, 2018

Could not find the magnet link from aria2 using your tools @alphatr @smasterfree , does that mean it is impossible to resueme downloading from .aria2 file?

see attachment for example
S.mp4.aria2.zip

@smasterfree
Copy link

@kiinoo

yes, maybe a broken control file?

@kiinoo
Copy link

kiinoo commented Jul 25, 2018

no, it is a regular file. but maybe it is not a 'magnet' file so we can extrac the link? (im not familiar with magnet/bittorrent concepts)

@MusoCity
Copy link

I was downloading a large 15GB file with Steinberg Download Assistant that is using Aria2.
There was a power cut and now it won't resume the 90% complete download,
I have Cubase_LE_AI_Elements_10.0.40_Installer_win.zip.sda-download and Cubase_LE_AI_Elements_10.0.40_Installer_win.zip.sda-download.aria2
Cubase_LE_AI_Elements_10.0.40_Installer_win.zip.sda-download.aria2.zip
How can I resume this ? is there a front end for windows that I can add the aria2 file to or do I do it with a command line in Windows ?

@stefanos82
Copy link

@MusoCity Have you tried to use the -c | --continue command so you can resume your download?

@MusoCity
Copy link

Yes, I got
aria2c -c Cubase_LE_AI_Elements_10.0.40_Installer_win.zip.sda-down
load.aria2
Exception caught
Exception: [download_helper.cc:451] errorCode=1 Unrecognized URI or unsupported
protocol: Cubase_LE_AI_Elements_10.0.40_Installer_win.zip.sda-download.aria2

@stefanos82
Copy link

That's not how you download your file I'm afraid...you need the original link you first started the download so you can resume the whole procedure.

On what operating system are you, Windows, Mac, or GNU / Linux?

@MusoCity
Copy link

It's Win, the Steinberg Download Assistant lets you pick the item to download so you don't get a link
SDA

@wzzxczj
Copy link

wzzxczj commented Oct 22, 2021

Hi @HaleTom , I write a tools to transform .aria2 file to a magnet link http://alphatr.github.io/aria2-reader.html

这链接怎么用来着,点进去就是一个选择文件的按钮,没了。
How to use this link? Only a button for sellect file, that all...

Ahh... It's work after close the Tampermonkey...

@bound-variable
Copy link

An answer, which worked for me, on Stack Exchange is,

url=$(echo "magnet:?xt=urn:btih:$(xxd -p -seek 10 -l 20 'FILENAME.aria2')")

aria2c --continue=true $url

@badrelmers
Copy link

it is very strange that this issue is open from 2016 while there is a beautiful solution to resume downloads without the original link

simply add this to aria2c command: --save-session-interval=5 --input-file=session.txt --save-session=session.txt

this will save to uncompleted downloaded files to a file called session.txt in the current folder every 5s and if you restart the pc or close aria2...etc then start aria with the same command and it will resume from where it stopped , you do not need to gave it the list of urls

@HaleTom
Copy link

HaleTom commented Jun 28, 2023

@badrelmers will this remove the session.txt on a completed download?

Or is there an additional step that won't be performed by a GUI downloader, eg uGet?

@badrelmers
Copy link

@HaleTom

@badrelmers will this remove the session.txt on a completed download?

when a download is successfully completed then aria will remove the link from session.txt automatically

Or is there an additional step that won't be performed by a GUI downloader, eg uGet?

i don t use uGet so i cannot comment, I use this one and it accept the session.txt file
https://github.com/ziahamza/webui-aria2

@Disonantemus
Copy link

An answer, which worked for me, on Stack Exchange is,

url=$(echo "magnet:?xt=urn:btih:$(xxd -p -seek 10 -l 20 'FILENAME.aria2')")

aria2c --continue=true $url

Useless echo?

#!/bin/bash
url="magnet:?xt=urn:btih:$(xxd -p -seek 10 -l 20 "$1")"
aria2c --continue=true "$url"

Also, I'm gonna try the session solution 4 next script.

@HaleTom
Copy link

HaleTom commented Jul 31, 2023

@badrelmers when using your command, I get:

Exception: [download_helper.cc:562] errorCode=1 Failed to open the file session.txt, cause: File not found or it is a directory

So it seems there would need to be some scripting wrapping around this to check if the file exists, and only add the option if it does.

Do you know if a session.txt is removed when the last download within it is complete?

@badrelmers
Copy link

@HaleTom

it seems there would need to be some scripting wrapping around this to check if the file exists, and only add the option if it does.

yes you have to create the session.txt file first, something like that will do the job: this will create an empty session.txt if it does not exist:

if not exist session.txt type NUL > session.txt

Do you know if a session.txt is removed when the last download within it is complete?

no, the session.txt will not be deleted

@HaleTom
Copy link

HaleTom commented Aug 5, 2023

@Disonantemus I came up with the following which allows the script to be called from any directory:

#!/bin/bash
# Resume a torrent from a .aria2 file
# Assumes download in same directory as the .aria2c file, overwrite with --dir=
# Credit: https://github.com/aria2/aria2/issues/792
url="magnet:?xt=urn:btih:$(xxd -p -seek 10 -l 20 "$1")"
cd "$(dirname "$1")" || exit 1
shift # Allow further aria2c command line options
exec aria2c "$url" "$@"

This will not leave any lingering files like --save-session=session.txt.

To easily update your trackers for fast fownloads, see here.

@SalimF
Copy link

SalimF commented Nov 3, 2023

What I do, I write the download link to a text file on my download folder within my bash script like this

echo $1 >>link.txt 
aria2c $1

@ZoheirAlayash
Copy link

ZoheirAlayash commented Feb 9, 2024

it is very strange that this issue is open from 2016 while there is a beautiful solution to resume downloads without the original link

simply add this to aria2c command: --save-session-interval=5 --input-file=session.txt --save-session=session.txt

this will save to uncompleted downloaded files to a file called session.txt in the current folder every 5s and if you restart the pc or close aria2...etc then start aria with the same command and it will resume from where it stopped , you do not need to gave it the list of urls

This is my original cmd. aria2c.exe -j1 -x1 -i uris.txt --save-session failed.txt. The file uris.txt include the uris for the datasets that I want to download. The download was successful, but out of 4000 datasets around 300 failed and thus noted in the failed.txt file.

I re-ran command aria2c.exe -j1 -x1 -i failed.txt --save-session failed2.txt but still the datasets failed to download.

I assume that running aria2c.exe -j1 -x1 -i uris.txt --save-session failed.txt instead would start downloading the whole 4000 datasets.

@ZoheirAlayash
Copy link

This is my original cmd. aria2c.exe -j1 -x1 -i uris.txt --save-session failed.txt. The file uris.txt include the uris for the datasets that I want to download. The download was successful, but out of 4000 datasets around 300 failed and thus noted in the failed.txt file.

I re-ran command aria2c.exe -j1 -x1 -i failed.txt --save-session failed2.txt but still the datasets failed to download.

I assume that running aria2c.exe -j1 -x1 -i uris.txt --save-session failed.txt instead would start downloading the whole 4000 datasets.

@jakariyaa
Copy link

Okay here is my solution to resume download:

my aria2 config file (~/.config/aria2/aria2.conf) contains the following line:

save-session-interval=60
save-session=${HOME}/aria2-session.txt

In the event of failed or to resume downloads later, I just run aria2 with the input-file command supplied with the seesion file as below:

aria2c --input-file aria2-session.txt


Explained in more details in the official documentation:
https://aria2.github.io/manual/en/html/aria2c.html#cmdoption-save-session
https://aria2.github.io/manual/en/html/aria2c.html#cmdoption-i

@0wwafa
Copy link

0wwafa commented Oct 29, 2024

Here you go:
https://zibri.github.io/aria2magnet/

image

@jpixy
Copy link

jpixy commented Nov 8, 2024

Hi everyone. I want to know how to do it in this case:

I have 2 servers, and every server has its own aria2 downloader, we can call them as A and B. Now I want to move all A's tasks into B. In other words, how can I import the uncompleted tasks in aria2 ?

I have tried to copy the downloading file and its own .aria file , copy both into B's downloads folder, and restart B. but there is no new tasks shown in B's list.

But if I copy all A servers folders, includes the conf, downloads folders to a new server (not B server, but a new server), and restart aria service, the every tasks can shown in the list, nothing changed, just like A clone.

So I want to confirm one thing, the session file in conf folder is important , right ? I need to move / merge it into new server, right ?

If it should be like that. what should I do , if I just want to move only one uncompleted task from A to B ? how can I locate the mapping item in A's session file, and copy that line into B's session file ?

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests