Created
December 14, 2016 09:28
-
-
Save mjsilva/3f71b1f21e62dc354a4578b3ffc11515 to your computer and use it in GitHub Desktop.
Using transmission-cli remove all torrents with "Error: No data found!"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $torrents = shell_exec("transmission-remote -n 'transmission:transmission' -l"); | |
| $torrents = explode("\n", $torrents); | |
| $torrents = array_map(function($value) | |
| { | |
| $value = str_replace(" ", " ", trim($value)); | |
| return explode(" ", $value); | |
| }, $torrents); | |
| foreach ($torrents as $torrent) { | |
| $id = $torrent[0]; | |
| if (!$id) { | |
| continue; | |
| } | |
| $id = str_replace("*", "", $torrent[0]); | |
| $info = shell_exec("transmission-remote -n 'transmission:transmission' -t $id -i"); | |
| echo "Removing torrent with id $id\n"; | |
| if (strpos($info, "Error: No data found!") !== false) { | |
| shell_exec("transmission-remote -n 'transmission:transmission' -t $id -r"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment