Changes between Version 8 and Version 9 of Plugins/Execute


Ignore:
Timestamp:
09/09/2010 09:16:17 PM (14 years ago)
Author:
narren
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Plugins/Execute

    v8 v9  
    115115smtp.quit() 
    116116}}} 
     117 
     118=== Extract archives script === 
     119 
     120This script will search for archives in downloaded content and extract them. Actions are logged as entries in syslog. 
     121This script can be easily extended to support more compression and archive formats. 
     122 
     123{{{ 
     124#!/bin/bash 
     125formats=(zip rar) 
     126commands=([zip]="unzip -u" [rar]="unrar -o- e") 
     127extraction_subdir='exracted' 
     128 
     129torrentid=$1 
     130torrentname=$2 
     131torrentpath=$3 
     132 
     133log() 
     134{ 
     135    logger -t deluge-extractarchives "$@" 
     136} 
     137 
     138log "Torrent complete: $@" 
     139cd "${torrentpath}" 
     140for format in "${formats[@]}"; do 
     141    while read file; do  
     142    log "Extracting \"$file\"" 
     143    cd $(dirname "$file") 
     144    file=$(basename "$file") 
     145    # if extraction_subdir is not empty, extract to subdirectory 
     146    if [[ ! -z "$extraction_subdir" ]] ; then 
     147        mkdir "$extraction_subdir" 
     148        cd "$extraction_subdir" 
     149        file="../$file" 
     150    fi 
     151    ${commands[$format]} "$file" 
     152    done < <(find "$torrentpath/$torrentname" -iname "*.${format}" ) 
     153done 
     154}}}