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

Sort saved .torrent files into labels #2643

Open
blixten85 opened this issue Mar 25, 2024 · 1 comment
Open

Sort saved .torrent files into labels #2643

blixten85 opened this issue Mar 25, 2024 · 1 comment

Comments

@blixten85
Copy link

Is your feature request related to a problem?

When you highlight all the torrents in your list and choose to save all the torrent files it gets saved into a .zip file

Describe the solution you'd like

I would like to add a label feature to this, so they get sorted into a folder with it's label name.
Makes it much easier to restore it if you have all the torrents saved into folders matching the label.
tv goes to tv, movies goes to movies etc.

Additional context

No response

@stickz
Copy link
Collaborator

stickz commented Mar 25, 2024

Okay, contributions are welcome to add folders inside the zip archive based on the torrent label. Here is the code.

foreach($hashes as $hash)
{
$req = new rXMLRPCRequest( array(
new rXMLRPCCommand("get_session"),
new rXMLRPCCommand("d.get_tied_to_file",$hash)) );
if($req->run() && !$req->fault)
{
$fname = $req->val[0].$hash.".torrent";
if(empty($req->val[0]) || !is_readable($fname))
{
if(strlen($req->val[1]) && is_readable($req->val[1]))
$fname = $req->val[1];
else
$fname = null;
}
if($fname)
{
$filepaths[] = $fname;
$files[] = new Torrent( $fname );
}
}
}
if(isset($files))
{
ignore_user_abort(true);
set_time_limit(0);
$fn = 1;
$zippath = FileUtil::getTempFilename('source','zip');
$zip = new ZipArchive;
$zip->open($zippath, ZipArchive::CREATE);
foreach(array_combine($filepaths, $files) as $filepath => $file)
{
$filename = $file->info['name']."-".$fn.".torrent";
$zip->addFile($filepath, $filename);
$fn++;
}
$zip->close();
if(SendFile::send($zippath, "application/zip", null, false))
unlink($zippath);
exit();
}

The feature needs to be submitted to the develop branch. Also, I would like to request a conf.php file to toggle the feature.

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

No branches or pull requests

2 participants